diff options
97 files changed, 1032 insertions, 568 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 559117749f2..cfc05cbf794 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -3173,17 +3173,24 @@ err: DBUG_RETURN(retval == ERROR_STOP ? 1 : 0); } +uint e_key_get_latest_version_func(uint) { return 1; } +uint e_key_get_func(uint, uint, uchar*, uint*) { return 1; } +uint e_ctx_size_func(uint, uint) { return 1; } +int e_ctx_init_func(void *, const uchar*, uint, const uchar*, uint, + int, uint, uint) { return 1; } +int e_ctx_update_func(void *, const uchar*, uint, uchar*, uint*) { return 1; } +int e_ctx_finish_func(void *, uchar*, uint*) { return 1; } +uint e_encrypted_length_func(uint, uint, uint) { return 1; } -uint dummy1() { return 1; } struct encryption_service_st encryption_handler= { - (uint(*)(uint))dummy1, - (uint(*)(uint, uint, uchar*, uint*))dummy1, - (uint(*)(uint, uint))dummy1, - (int (*)(void*, const uchar*, uint, const uchar*, uint, int, uint, uint))dummy1, - (int (*)(void*, const uchar*, uint, uchar*, uint*))dummy1, - (int (*)(void*, uchar*, uint*))dummy1, - (uint (*)(uint, uint, uint))dummy1 + e_key_get_latest_version_func, + e_key_get_func, + e_ctx_size_func, + e_ctx_init_func, + e_ctx_update_func, + e_ctx_finish_func, + e_encrypted_length_func }; /* diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 45ad2612d44..e19c0b79540 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -953,7 +953,8 @@ static int handle_request_for_tables(char *tables, size_t length, puts(query); if (mysql_real_query(sock, query, query_length)) { - sprintf(message, "when executing '%s%s... %s'", op, tab_view, options); + my_snprintf(message, sizeof(message), "when executing '%s%s... %s'", + op, tab_view, options); DBerror(sock, message); my_free(query); DBUG_RETURN(1); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 1a6c22573e0..bfbf1214a69 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -8272,6 +8272,12 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, DBUG_ENTER("run_query_stmt"); DBUG_PRINT("query", ("'%-.60s'", query)); + if (!mysql) + { + handle_no_active_connection(command, cn, ds); + DBUG_VOID_RETURN; + } + /* Init a new stmt if it's not already one created for this connection */ @@ -8809,18 +8815,56 @@ void init_re(void) */ const char *ps_re_str = "^(" - "[[:space:]]*REPLACE[[:space:]]|" - "[[:space:]]*INSERT[[:space:]]|" - "[[:space:]]*UPDATE[[:space:]]|" - "[[:space:]]*DELETE[[:space:]]|" - "[[:space:]]*SELECT[[:space:]]|" + "[[:space:]]*ALTER[[:space:]]+SEQUENCE[[:space:]]|" + "[[:space:]]*ALTER[[:space:]]+TABLE[[:space:]]|" + "[[:space:]]*ALTER[[:space:]]+USER[[:space:]]|" + "[[:space:]]*ANALYZE[[:space:]]|" + "[[:space:]]*ASSIGN[[:space:]]|" + //"[[:space:]]*CALL[[:space:]]|" // XXX run_query_stmt doesn't read multiple result sets + "[[:space:]]*CHANGE[[:space:]]|" + "[[:space:]]*CHECKSUM[[:space:]]|" + "[[:space:]]*COMMIT[[:space:]]|" + "[[:space:]]*COMPOUND[[:space:]]|" + "[[:space:]]*CREATE[[:space:]]+DATABASE[[:space:]]|" + "[[:space:]]*CREATE[[:space:]]+INDEX[[:space:]]|" + "[[:space:]]*CREATE[[:space:]]+ROLE[[:space:]]|" + "[[:space:]]*CREATE[[:space:]]+SEQUENCE[[:space:]]|" "[[:space:]]*CREATE[[:space:]]+TABLE[[:space:]]|" + "[[:space:]]*CREATE[[:space:]]+USER[[:space:]]|" + "[[:space:]]*CREATE[[:space:]]+VIEW[[:space:]]|" + "[[:space:]]*DELETE[[:space:]]|" "[[:space:]]*DO[[:space:]]|" + "[[:space:]]*DROP[[:space:]]+DATABASE[[:space:]]|" + "[[:space:]]*DROP[[:space:]]+INDEX[[:space:]]|" + "[[:space:]]*DROP[[:space:]]+ROLE[[:space:]]|" + "[[:space:]]*DROP[[:space:]]+SEQUENCE[[:space:]]|" + "[[:space:]]*DROP[[:space:]]+TABLE[[:space:]]|" + "[[:space:]]*DROP[[:space:]]+USER[[:space:]]|" + "[[:space:]]*DROP[[:space:]]+VIEW[[:space:]]|" + "[[:space:]]*FLUSH[[:space:]]|" + "[[:space:]]*GRANT[[:space:]]|" "[[:space:]]*HANDLER[[:space:]]+.*[[:space:]]+READ[[:space:]]|" + "[[:space:]]*INSERT[[:space:]]|" + "[[:space:]]*INSTALL[[:space:]]+|" + "[[:space:]]*KILL[[:space:]]|" + "[[:space:]]*OPTIMIZE[[:space:]]|" + "[[:space:]]*PRELOAD[[:space:]]|" + "[[:space:]]*RENAME[[:space:]]+TABLE[[:space:]]|" + "[[:space:]]*RENAME[[:space:]]+USER[[:space:]]|" + "[[:space:]]*REPAIR[[:space:]]|" + "[[:space:]]*REPLACE[[:space:]]|" + "[[:space:]]*RESET[[:space:]]|" + "[[:space:]]*REVOKE[[:space:]]|" + "[[:space:]]*ROLLBACK[[:space:]]|" + "[[:space:]]*SELECT[[:space:]]|" "[[:space:]]*SET[[:space:]]+OPTION[[:space:]]|" - "[[:space:]]*DELETE[[:space:]]+MULTI[[:space:]]|" - "[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|" - "[[:space:]]*INSERT[[:space:]]+SELECT[[:space:]])"; + "[[:space:]]*SHOW[[:space:]]|" + "[[:space:]]*SHUTDOWN[[:space:]]|" + "[[:space:]]*SLAVE[[:space:]]|" + "[[:space:]]*TRUNCATE[[:space:]]|" + "[[:space:]]*UNINSTALL[[:space:]]+|" + "[[:space:]]*UPDATE[[:space:]]" + ")"; /* Filter for queries that can be run using the diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 184cd1b4504..bedb8ffb2ec 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -67,7 +67,6 @@ unsigned long mysql_server_version = 0; /* server capabilities */ bool have_changed_page_bitmaps = false; bool have_backup_locks = false; -bool have_backup_safe_binlog_info = false; bool have_lock_wait_timeout = false; bool have_galera_enabled = false; bool have_flush_engine_logs = false; @@ -359,8 +358,6 @@ get_mysql_vars(MYSQL *connection) mysql_variable mysql_vars[] = { {"have_backup_locks", &have_backup_locks_var}, - {"have_backup_safe_binlog_info", - &have_backup_safe_binlog_info_var}, {"log_bin", &log_bin_var}, {"lock_wait_timeout", &lock_wait_timeout_var}, {"gtid_mode", >id_mode_var}, @@ -393,23 +390,12 @@ get_mysql_vars(MYSQL *connection) } if (opt_binlog_info == BINLOG_INFO_AUTO) { - - if (have_backup_safe_binlog_info_var != NULL) - opt_binlog_info = BINLOG_INFO_LOCKLESS; - else if (log_bin_var != NULL && !strcmp(log_bin_var, "ON")) + if (log_bin_var != NULL && !strcmp(log_bin_var, "ON")) opt_binlog_info = BINLOG_INFO_ON; else opt_binlog_info = BINLOG_INFO_OFF; } - if (have_backup_safe_binlog_info_var == NULL && - opt_binlog_info == BINLOG_INFO_LOCKLESS) { - - msg("Error: --binlog-info=LOCKLESS is not supported by the " - "server"); - return(false); - } - if (lock_wait_timeout_var != NULL) { have_lock_wait_timeout = true; } @@ -1821,4 +1807,3 @@ mdl_unlock_all() mysql_close(mdl_con); spaceid_to_tablename.clear(); } - diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 889d3ca3bac..7f3a04ff7ea 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -362,9 +362,6 @@ struct ddl_tracker_t { static ddl_tracker_t ddl_tracker; -/* Whether xtrabackup_binlog_info should be created on recovery */ -static bool recover_binlog_info; - /* Simple datasink creation tracking...add datasinks in the reverse order you want them destroyed. */ #define XTRABACKUP_MAX_DATASINKS 10 @@ -2048,9 +2045,6 @@ xtrabackup_read_metadata(char *filename) } /* Optional fields */ - if (fscanf(fp, "recover_binlog_info = %d\n", &t) == 1) { - recover_binlog_info = (t == 1); - } end: fclose(fp); @@ -2069,13 +2063,11 @@ xtrabackup_print_metadata(char *buf, size_t buf_len) "backup_type = %s\n" "from_lsn = " UINT64PF "\n" "to_lsn = " UINT64PF "\n" - "last_lsn = " UINT64PF "\n" - "recover_binlog_info = %d\n", + "last_lsn = " UINT64PF "\n", metadata_type, metadata_from_lsn, metadata_to_lsn, - metadata_last_lsn, - MY_TEST(opt_binlog_info == BINLOG_INFO_LOCKLESS)); + metadata_last_lsn); } /*********************************************************************** @@ -5627,18 +5619,6 @@ xtrabackup_prepare_func(char** argv) TRX_SYS_MYSQL_LOG_INFO + TRX_SYS_MYSQL_LOG_NAME + sys_header); msg("Last binlog file %s, position %llu", name, pos); - - /* output to xtrabackup_binlog_pos_innodb and - (if backup_safe_binlog_info was available on - the server) to xtrabackup_binlog_info. In the - latter case xtrabackup_binlog_pos_innodb - becomes redundant and is created only for - compatibility. */ - ok = store_binlog_info( - "xtrabackup_binlog_pos_innodb", name, pos) - && (!recover_binlog_info || store_binlog_info( - XTRABACKUP_BINLOG_INFO, - name, pos)); } mtr.commit(); diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h index 90f5e28e2c7..3dc0891f3b4 100644 --- a/extra/mariabackup/xtrabackup.h +++ b/extra/mariabackup/xtrabackup.h @@ -140,7 +140,7 @@ extern uint opt_safe_slave_backup_timeout; extern const char *opt_history; -enum binlog_info_enum { BINLOG_INFO_OFF, BINLOG_INFO_LOCKLESS, BINLOG_INFO_ON, +enum binlog_info_enum { BINLOG_INFO_OFF, BINLOG_INFO_ON, BINLOG_INFO_AUTO}; extern ulong opt_binlog_info; diff --git a/include/wsrep.h b/include/wsrep.h index 14d624aec26..d9800b7014f 100644 --- a/include/wsrep.h +++ b/include/wsrep.h @@ -50,9 +50,9 @@ #define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__) #define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__) -#define WSREP_SYNC_WAIT(thd_, before_) \ - { if (WSREP_CLIENT(thd_) && \ - wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } +#define WSREP_SYNC_WAIT(thd_, before_) \ + do { if (WSREP_CLIENT(thd_) && \ + wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } while(0) #define WSREP_ERROR_LABEL wsrep_error_label #else #define IF_WSREP(A,B) B @@ -64,7 +64,7 @@ #define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) #define WSREP_TO_ISOLATION_END #define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) -#define WSREP_SYNC_WAIT(thd_, before_) +#define WSREP_SYNC_WAIT(thd_, before_) do { } while(0) #define WSREP_ERROR_LABEL goto wsrep_error_label; wsrep_error_label #endif /* WITH_WSREP */ diff --git a/man/mysqldumpslow.1 b/man/mysqldumpslow.1 index 78a85264627..1a08e0e2c5e 100644 --- a/man/mysqldumpslow.1 +++ b/man/mysqldumpslow.1 @@ -210,6 +210,30 @@ should be chosen from the following list: .IP \(bu 2.3 .\} t, +aa: Sort by rows affected or average rows affected +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +l, +ae: Sort by rows examined or aggregate rows examined +.RE +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +l, at: Sort by query time or average query time .RE .sp diff --git a/mysql-test/r/analyze_stmt.result b/mysql-test/r/analyze_stmt.result index c3c98593210..3ae49c5eeb6 100644 --- a/mysql-test/r/analyze_stmt.result +++ b/mysql-test/r/analyze_stmt.result @@ -247,7 +247,7 @@ drop table t1; # create table t1 (i int); insert into t1 values (1); -analyze select * from t1 into @var; +analyze select * into @var from t1 ; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 NULL 100.00 NULL drop table t1; @@ -281,10 +281,10 @@ drop table t1; # create table t1(a int); insert into t1 values (1),(2); -analyze select a from t1 where a <2 into @var; +analyze select a into @var from t1 where a <2 ; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 2.00 100.00 50.00 Using where -analyze select a from t1 into @var; +analyze select a into @var from t1 ; ERROR 42000: Result consisted of more than one row analyze insert into t1 select * from t1; id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 16acf3fcbea..d2cee26cfb1 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -3421,6 +3421,36 @@ t2 CREATE TABLE `t2` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1,t2; # +# MDEV-14926 AddressSanitizer: heap-use-after-free in make_date_time on weird combination of functions +# +DO INET_ATON( FROM_UNIXTIME( @@timestamp, ( TRIM( UNHEX(HEX('%m.%d.%Y') ) ) ) ) ); +CREATE TABLE t1 (d DATE); +INSERT INTO t1 VALUES ('1989-03-10'); +SELECT TIME_FORMAT('23:59:43', BINARY d) AS f FROM t1 GROUP BY 'foo'; +f +1989-03-10 +DROP TABLE t1; +CREATE TABLE t1 (d DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1900-01-01'); +SELECT LENGTH( DATE_FORMAT( d, BINARY DATABASE() ) ) AS f FROM t1 GROUP BY d; +f +4 +DROP TABLE t1; +# +# MDEV-18667 ASAN heap-use-after-free in make_date_time / Arg_comparator::compare_string / Item_func_nullif::compare +# +SELECT NULLIF('foo', FROM_UNIXTIME('2012-12-12 12:12:12', TRIM(0))); +NULLIF('foo', FROM_UNIXTIME('2012-12-12 12:12:12', TRIM(0))) +foo +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: '2012-12-12 12:12:12' +# +# MDEV-18626 ASAN stack-buffer-overflow in int10_to_str / make_date_time upon DATE_FORMAT +# +SELECT DATE_FORMAT(100000000000, '%j'); +DATE_FORMAT(100000000000, '%j') +NULL +# # End of 10.1 tests # # diff --git a/mysql-test/r/log_slow_debug.result b/mysql-test/r/log_slow_debug.result new file mode 100644 index 00000000000..a823f4c2b98 --- /dev/null +++ b/mysql-test/r/log_slow_debug.result @@ -0,0 +1,137 @@ +SET @org_slow_query_log= @@global.slow_query_log; +SET @org_log_output= @@global.log_output; +SET @org_log_slow_admin_statements= @@global.log_slow_admin_statements; +SET @@GLOBAL.slow_query_log=OFF; +SET @@GLOBAL.log_output='TABLE'; +FLUSH SLOW LOGS; +SET @@GLOBAL.slow_query_log=ON; +SET @@GLOBAL.log_slow_admin_statements=ON; +SET SESSION debug_dbug="+d,simulate_slow_query"; +CREATE PROCEDURE show_slow_log() +BEGIN +SELECT CONCAT('[slow] ', sql_text) AS sql_text +FROM mysql.slow_log +WHERE sql_text NOT LIKE '%debug_dbug%'; +END +$$ +# +# Expect all admin statements in the slow log (ON,DEFAULT) +# +SET @@GLOBAL.log_slow_admin_statements=ON; +SET log_slow_filter=DEFAULT; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; +CALL show_slow_log(); +sql_text +[slow] TRUNCATE TABLE mysql.slow_log +[slow] CREATE TABLE t1 (a INT) +[slow] CREATE INDEX t1a ON t1 (a) +[slow] DROP INDEX t1a ON t1 +[slow] DROP TABLE t1 +[slow] CREATE TABLE t2 (a INT) +[slow] ALTER TABLE t2 RENAME t2 +[slow] RENAME TABLE t2 TO t3 +[slow] DROP TABLE t3 +[slow] CREATE TABLE t4 (a INT) +[slow] PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1' +[slow] ALTER TABLE t4 MODIFY a INT DEFAULT 1 +[slow] DEALLOCATE PREPARE stmt +[slow] DROP TABLE t4 +# +# Expect all admin statements in the slow log (ON,admin) +# +SET @@GLOBAL.log_slow_admin_statements=ON; +SET log_slow_filter=admin; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; +CALL show_slow_log(); +sql_text +[slow] CREATE INDEX t1a ON t1 (a) +[slow] DROP INDEX t1a ON t1 +[slow] ALTER TABLE t2 RENAME t2 +[slow] RENAME TABLE t2 TO t3 +[slow] ALTER TABLE t4 MODIFY a INT DEFAULT 1 +# +# Expect none of admin DDL statements in the slow log (ON,filesort) +# +SET @@GLOBAL.log_slow_admin_statements=ON; +SET log_slow_filter=filesort; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; +CALL show_slow_log(); +sql_text +# +# Expect none of admin statements in the slow log (OFF,DEFAULT) +# +SET @@GLOBAL.log_slow_admin_statements=OFF; +SET log_slow_filter=DEFAULT; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; +CALL show_slow_log(); +sql_text +[slow] TRUNCATE TABLE mysql.slow_log +[slow] CREATE TABLE t1 (a INT) +[slow] DROP TABLE t1 +[slow] CREATE TABLE t2 (a INT) +[slow] DROP TABLE t3 +[slow] CREATE TABLE t4 (a INT) +[slow] PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1' +[slow] DEALLOCATE PREPARE stmt +[slow] DROP TABLE t4 +# +# Clean up +# +SET SESSION debug_dbug="-d,simulate_slow_query"; +TRUNCATE mysql.slow_log; +SET @@global.slow_query_log= @org_slow_query_log; +SET @@global.log_output= @org_log_output; +SET @@global.log_slow_admin_statements= @org_log_slow_admin_statements; +DROP PROCEDURE show_slow_log; diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 8059923e117..af22654e330 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1318,7 +1318,7 @@ partition p2 values in (1)); end// call p()// drop procedure p// -drop table t1; +drop table t1// create procedure p () begin create table t1 (a int not null,b int not null,c int not null,primary key (a,b)) diff --git a/mysql-test/r/sp-ucs2.result b/mysql-test/r/sp-ucs2.result index b8cc5dfd73d..ca448efa535 100644 --- a/mysql-test/r/sp-ucs2.result +++ b/mysql-test/r/sp-ucs2.result @@ -32,61 +32,55 @@ RETURNS VARCHAR(64) UNICODE BINARY BEGIN RETURN ''; END| -SHOW CREATE FUNCTION f; -DROP FUNCTION f; +SHOW CREATE FUNCTION f| +Function sql_mode Create Function character_set_client collation_connection Database Collation +f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin +BEGIN +RETURN ''; +END latin1 latin1_swedish_ci latin1_swedish_ci +DROP FUNCTION f| CREATE FUNCTION f() RETURNS VARCHAR(64) BINARY UNICODE BEGIN RETURN ''; END| +SHOW CREATE FUNCTION f| Function sql_mode Create Function character_set_client collation_connection Database Collation f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin BEGIN RETURN ''; END latin1 latin1_swedish_ci latin1_swedish_ci -SHOW CREATE FUNCTION f; -DROP FUNCTION f; -# -# Testing keywords ASCII + BINARY -# +DROP FUNCTION f| CREATE FUNCTION f() RETURNS VARCHAR(64) ASCII BINARY BEGIN RETURN ''; END| +SHOW CREATE FUNCTION f| Function sql_mode Create Function character_set_client collation_connection Database Collation -f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin +f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin BEGIN RETURN ''; END latin1 latin1_swedish_ci latin1_swedish_ci -SHOW CREATE FUNCTION f; -DROP FUNCTION f; +DROP FUNCTION f| CREATE FUNCTION f() RETURNS VARCHAR(64) BINARY ASCII BEGIN RETURN ''; END| +SHOW CREATE FUNCTION f| Function sql_mode Create Function character_set_client collation_connection Database Collation f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin BEGIN RETURN ''; END latin1 latin1_swedish_ci latin1_swedish_ci -SHOW CREATE FUNCTION f; -DROP FUNCTION f; -# -# Testing COLLATE in OUT parameter -# +DROP FUNCTION f| CREATE PROCEDURE p1(IN f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_czech_ci, OUT f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_polish_ci) BEGIN SET f2= f1; SET f2= concat(collation(f1), ' ', collation(f2)); END| -Function sql_mode Create Function character_set_client collation_connection Database Collation -f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin -BEGIN -RETURN ''; -END latin1 latin1_swedish_ci latin1_swedish_ci CREATE FUNCTION f1() RETURNS VARCHAR(64) CHARACTER SET ucs2 BEGIN diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 422a76921f3..5dc3c2584a2 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -6798,7 +6798,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist create table t1 (a integer)$ call p1$ a -alter table t1 add b integer; +alter table t1 add b integer$ call p1$ a drop table t1; diff --git a/mysql-test/r/sp_notembedded.result b/mysql-test/r/sp_notembedded.result index 8edb9e79b70..d337d50e18a 100644 --- a/mysql-test/r/sp_notembedded.result +++ b/mysql-test/r/sp_notembedded.result @@ -74,7 +74,7 @@ select res; end| create table t3 (a int)| insert into t3 values (0)| -create view v1 as select a from t3; +create view v1 as select a from t3| create procedure bug10100pt(level int, lim int) begin if level < lim then diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index ef802279c9c..deb0d6797fe 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -640,7 +640,7 @@ TRUNCATE TABLE t1; END| LOCK TABLES t1 WRITE| CALL p1()| -FLUSH TABLES; +FLUSH TABLES| UNLOCK TABLES| CALL p1()| DROP PROCEDURE p1| diff --git a/mysql-test/r/type_year.result b/mysql-test/r/type_year.result index c4b72483c99..99c3c50ea8c 100644 --- a/mysql-test/r/type_year.result +++ b/mysql-test/r/type_year.result @@ -444,6 +444,15 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2010 DROP TABLE t1; # +# MDEV-16958 Assertion `field_length < 5' failed in Field_year::val_str or data corruption upon SELECT with UNION and aggregate functions +# +CREATE TABLE t1 (f YEAR); +INSERT IGNORE INTO t1 VALUES (1971),(1972); +SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1 UNION SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1; +f +1972 +DROP TABLE t1; +# # End of 10.1 tests # # diff --git a/mysql-test/r/userstat.result b/mysql-test/r/userstat.result index 37d07439fee..01a66aa78ec 100644 --- a/mysql-test/r/userstat.result +++ b/mysql-test/r/userstat.result @@ -145,7 +145,7 @@ show table_statistics; Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes show index_statistics; Table_schema Table_name Index_name Rows_read -select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;; +select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;; TOTAL_CONNECTIONS 2 TOTAL_SSL_CONNECTIONS 1 CONCURRENT_CONNECTIONS 0 @@ -156,14 +156,13 @@ ROWS_INSERTED 7 ROWS_UPDATED 5 SELECT_COMMANDS 4 UPDATE_COMMANDS 11 -OTHER_COMMANDS 7 COMMIT_TRANSACTIONS 19 ROLLBACK_TRANSACTIONS 2 DENIED_CONNECTIONS 0 LOST_CONNECTIONS 0 ACCESS_DENIED 0 EMPTY_QUERIES 1 -select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;; +select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;; TOTAL_CONNECTIONS 2 TOTAL_SSL_CONNECTIONS 1 CONCURRENT_CONNECTIONS 0 @@ -174,13 +173,18 @@ ROWS_INSERTED 7 ROWS_UPDATED 5 SELECT_COMMANDS 4 UPDATE_COMMANDS 11 -OTHER_COMMANDS 7 COMMIT_TRANSACTIONS 19 ROLLBACK_TRANSACTIONS 2 DENIED_CONNECTIONS 0 LOST_CONNECTIONS 0 ACCESS_DENIED 0 EMPTY_QUERIES 1 +select OTHER_COMMANDS IN (7,8) from information_schema.client_statistics; +OTHER_COMMANDS IN (7,8) +1 +select OTHER_COMMANDS IN (7,8) from information_schema.user_statistics; +OTHER_COMMANDS IN (7,8) +1 flush table_statistics; flush index_statistics; select * from information_schema.index_statistics; diff --git a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc index cd060e7a370..a2e701cc5fa 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc @@ -156,6 +156,7 @@ WHERE DB = 'information_schema' AND COMMAND = 'Sleep' AND USER = 'ddicttestuser1 --source include/wait_condition.inc --replace_result ENGINE=MyISAM "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" "" eval SHOW CREATE TABLE $table; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS eval SHOW $table; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -176,6 +177,7 @@ connection con100; # but "ddicttestuser1" must not see anything of the root session. --replace_result ENGINE=MyISAM "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" "" eval SHOW CREATE TABLE $table; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS eval SHOW $table; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -202,6 +204,7 @@ GRANT PROCESS ON *.* TO ddicttestuser1@'localhost' IDENTIFIED BY 'ddictpass'; --echo #################################################################################### connection con100; SHOW GRANTS; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -214,6 +217,7 @@ SELECT * FROM information_schema.processlist; --echo #################################################################################### connect (con101,localhost,ddicttestuser1,ddictpass,information_schema); SHOW GRANTS; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -237,6 +241,7 @@ GRANT PROCESS ON *.* TO ''@'localhost'; --echo #################################################################################### connect (anonymous1,localhost,"''",,information_schema); SHOW GRANTS; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -259,6 +264,7 @@ connect (con102,localhost,ddicttestuser1,ddictpass,information_schema); --echo ddicttestuser1 are visible. --echo #################################################################################### SHOW GRANTS; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -284,6 +290,7 @@ SHOW GRANTS FOR ''@'localhost'; if ($fixed_bug_30395) { # Bug#30395 strange results after REVOKE PROCESS ON *.* FROM ... +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; } @@ -306,6 +313,7 @@ connect (con103,localhost,ddicttestuser1,ddictpass,information_schema); --echo Only the processes of ddicttestuser1 user are visible. --echo #################################################################################### SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -328,6 +336,7 @@ connect (con104,localhost,ddicttestuser1,ddictpass,information_schema); --echo Only the processes of ddicttestuser1 are visible. --echo #################################################################################### SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -375,6 +384,7 @@ connect (con200,localhost,ddicttestuser2,ddictpass,information_schema); --echo ddicttestuser2 has now the PROCESS privilege and sees all connections --echo #################################################################################### SHOW GRANTS FOR 'ddicttestuser2'@'localhost'; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -396,6 +406,7 @@ connect (con201,localhost,ddicttestuser2,ddictpass,information_schema); --echo ddicttestuser2 has no more the PROCESS privilege and can only see own connects --echo #################################################################################### SHOW GRANTS; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -419,6 +430,7 @@ connect (con107,localhost,ddicttestuser1,ddictpass,information_schema); SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; --error ER_ACCESS_DENIED_ERROR GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID @@ -443,6 +455,7 @@ connect (con108,localhost,ddicttestuser1,ddictpass,information_schema); --echo Therefore the missing SELECT privilege does not affect SELECTs on PROCESSLIST. --echo #################################################################################### SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; +--replace_result Execute Query --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS SHOW processlist; --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID diff --git a/mysql-test/suite/funcs_1/datadict/processlist_val.inc b/mysql-test/suite/funcs_1/datadict/processlist_val.inc index cfc3c5e751a..a3e3bf57a99 100644 --- a/mysql-test/suite/funcs_1/datadict/processlist_val.inc +++ b/mysql-test/suite/funcs_1/datadict/processlist_val.inc @@ -94,6 +94,7 @@ echo # 1. Just dump what we get --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; +--replace_result Execute Query --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> SHOW FULL PROCESSLIST; # @@ -161,6 +162,7 @@ let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST # 1. Just dump what we get --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 7 <STATE> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; +--replace_result Execute Query --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> SHOW FULL PROCESSLIST; # @@ -203,6 +205,7 @@ echo connection con1; --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; +--replace_result Execute Query --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> SHOW FULL PROCESSLIST; @@ -228,6 +231,7 @@ connection con2; # Just dump what we get --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; +--replace_result Execute Query --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> SHOW FULL PROCESSLIST; # @@ -279,6 +283,7 @@ WHERE ID = @test_user_con2_id AND Command IN('Query','Execute') # 1. Just dump what we get --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; +--replace_result Execute Query --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> SHOW FULL PROCESSLIST; # @@ -385,8 +390,10 @@ echo ; --replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; +--replace_result Execute Query --replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> SHOW FULL PROCESSLIST; +--replace_result Execute Query --replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> SHOW PROCESSLIST; UNLOCK TABLES; diff --git a/mysql-test/suite/galera/r/galera_kill_largechanges.result b/mysql-test/suite/galera/r/galera_kill_largechanges.result index f4de101fef8..b6393590629 100644 --- a/mysql-test/suite/galera/r/galera_kill_largechanges.result +++ b/mysql-test/suite/galera/r/galera_kill_largechanges.result @@ -1,8 +1,7 @@ -call mtr.add_suppression("WSREP: Last Applied Action message in non-primary configuration from member .*"); connection node_1; SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; -CREATE TABLE ten (f1 INTEGER); -INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10),(11); CREATE TABLE t1 (f1 VARCHAR(128)) ENGINE=InnoDB; connection node_2; Killing server ... @@ -10,12 +9,11 @@ connection node_1; INSERT INTO t1 SELECT REPEAT('a', 128) FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5, ten AS a6; connection node_2; connection node_2a; -SELECT COUNT(*) = 1000000 FROM t1; -COUNT(*) = 1000000 -1 -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -VARIABLE_VALUE = 2 -1 -connection node_1; +SELECT COUNT(*) FROM t1; +COUNT(*) +1771561 +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE +2 DROP TABLE t1; DROP TABLE ten; diff --git a/mysql-test/suite/galera/r/galera_kill_nochanges.result b/mysql-test/suite/galera/r/galera_kill_nochanges.result index 3ccf73f0d46..8795608a303 100644 --- a/mysql-test/suite/galera/r/galera_kill_nochanges.result +++ b/mysql-test/suite/galera/r/galera_kill_nochanges.result @@ -10,10 +10,10 @@ SET SESSION wsrep_sync_wait = 0; SET SESSION wsrep_sync_wait = DEFAULT; connection node_2; connection node_2a; -SELECT COUNT(*) = 1 FROM t1; -COUNT(*) = 1 -1 -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -VARIABLE_VALUE = 2 +SELECT COUNT(*) FROM t1; +COUNT(*) 1 +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +VARIABLE_VALUE +2 DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_kill_smallchanges.result b/mysql-test/suite/galera/r/galera_kill_smallchanges.result index 2ee291004b0..f500db8871b 100644 --- a/mysql-test/suite/galera/r/galera_kill_smallchanges.result +++ b/mysql-test/suite/galera/r/galera_kill_smallchanges.result @@ -1,4 +1,5 @@ -call mtr.add_suppression("WSREP: Last Applied Action message in non-primary configuration from member .*"); +connection node_1; +connection node_2; connection node_1; SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; @@ -8,8 +9,8 @@ connection node_1; INSERT INTO t1 VALUES (1); connection node_2; connection node_2a; -SELECT COUNT(*) = 1 FROM t1; -COUNT(*) = 1 +SELECT COUNT(*) FROM t1; +COUNT(*) 1 SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 2 diff --git a/mysql-test/suite/galera/suite.pm b/mysql-test/suite/galera/suite.pm index 8b7b7034fac..6e53e6e2e31 100644 --- a/mysql-test/suite/galera/suite.pm +++ b/mysql-test/suite/galera/suite.pm @@ -75,6 +75,7 @@ push @::global_suppressions, qr|WSREP: Protocol violation. JOIN message sender .* is not in state transfer \(JOINED\). Message ignored.|, qr|WSREP: Unsupported protocol downgrade: incremental data collection disabled. Expect abort.|, qr(WSREP: Action message in non-primary configuration from member [0-9]*), + qr(WSREP: Last Applied Action message in non-primary configuration from member [0-9]*), qr(WSREP: discarding established .*), qr|WSREP: .*core_handle_uuid_msg.*|, qr(WSREP: --wsrep-causal-reads=ON takes precedence over --wsrep-sync-wait=0. WSREP_SYNC_WAIT_BEFORE_READ is on), diff --git a/mysql-test/suite/galera/t/galera_kill_largechanges.test b/mysql-test/suite/galera/t/galera_kill_largechanges.test index 2803a43d85a..c671764fa9e 100644 --- a/mysql-test/suite/galera/t/galera_kill_largechanges.test +++ b/mysql-test/suite/galera/t/galera_kill_largechanges.test @@ -4,9 +4,11 @@ --source include/big_test.inc --source include/galera_cluster.inc ---source include/have_innodb.inc -call mtr.add_suppression("WSREP: Last Applied Action message in non-primary configuration from member .*"); +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 # Enable the master to continue running during the split-brain situation that @@ -14,8 +16,8 @@ call mtr.add_suppression("WSREP: Last Applied Action message in non-primary conf --let $wsrep_provider_options_orig = `SELECT @@wsrep_provider_options` SET GLOBAL wsrep_provider_options = 'pc.ignore_sb=true'; -CREATE TABLE ten (f1 INTEGER); -INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB; +INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10),(11); CREATE TABLE t1 (f1 VARCHAR(128)) ENGINE=InnoDB; --connection node_2 @@ -33,13 +35,16 @@ INSERT INTO t1 SELECT REPEAT('a', 128) FROM ten AS a1, ten AS a2, ten AS a3, ten --source include/galera_connect.inc --connection node_2a -SELECT COUNT(*) = 1000000 FROM t1; -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +SELECT COUNT(*) FROM t1; +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --connection node_1 --disable_query_log --eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; --enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + DROP TABLE t1; DROP TABLE ten; diff --git a/mysql-test/suite/galera/t/galera_kill_nochanges.test b/mysql-test/suite/galera/t/galera_kill_nochanges.test index 9360ad542f6..aa1648ca3ae 100644 --- a/mysql-test/suite/galera/t/galera_kill_nochanges.test +++ b/mysql-test/suite/galera/t/galera_kill_nochanges.test @@ -20,6 +20,7 @@ INSERT INTO t1 VALUES (1); SET SESSION wsrep_sync_wait = 0; --let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status' --source include/wait_condition.inc + SET SESSION wsrep_sync_wait = DEFAULT; --connection node_2 @@ -30,8 +31,8 @@ SET SESSION wsrep_sync_wait = DEFAULT; --source include/galera_connect.inc --connection node_2a -SELECT COUNT(*) = 1 FROM t1; -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +SELECT COUNT(*) FROM t1; +SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --let $node_2=node_2a --source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_kill_smallchanges.test b/mysql-test/suite/galera/t/galera_kill_smallchanges.test index 148c3dbc132..15e1727de03 100644 --- a/mysql-test/suite/galera/t/galera_kill_smallchanges.test +++ b/mysql-test/suite/galera/t/galera_kill_smallchanges.test @@ -3,9 +3,11 @@ # --source include/galera_cluster.inc ---source include/have_innodb.inc -call mtr.add_suppression("WSREP: Last Applied Action message in non-primary configuration from member .*"); +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc --connection node_1 @@ -30,7 +32,7 @@ INSERT INTO t1 VALUES (1); --source include/galera_connect.inc --connection node_2a -SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) FROM t1; SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --connection node_1 @@ -38,4 +40,7 @@ SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_N --eval SET GLOBAL wsrep_provider_options = '$wsrep_provider_options_orig'; --enable_query_log +--let $node_2=node_2a +--source include/auto_increment_offset_restore.inc + DROP TABLE t1; diff --git a/mysql-test/suite/handler/ps.test b/mysql-test/suite/handler/ps.test index 68091190c85..783d862435e 100644 --- a/mysql-test/suite/handler/ps.test +++ b/mysql-test/suite/handler/ps.test @@ -7,5 +7,7 @@ flush status; handler handler_a read first; # handler...read must be prepared in --ps-protocol mode --replace_result $PS_PROTOCOL OK +--disable_ps_protocol show status like 'Com_stmt_prepare%'; +--enable_ps_protocol drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb-corrupted-table.test b/mysql-test/suite/innodb/t/innodb-corrupted-table.test index 60da461a33c..a7f4ad4afd4 100644 --- a/mysql-test/suite/innodb/t/innodb-corrupted-table.test +++ b/mysql-test/suite/innodb/t/innodb-corrupted-table.test @@ -34,6 +34,7 @@ alter table t1 add primary key (pk); --enable_reconnect --source include/wait_until_connected_again.inc +--enable_prepare_warnings show create table t1; select * from t1; alter table t1 add j int; diff --git a/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_func.test b/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_func.test index 6617c4ad2ea..c37fc7ab114 100644 --- a/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_func.test +++ b/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_func.test @@ -19,7 +19,7 @@ # option_mysqld_max_prepared_stmt_count # # # ################################################################################ - +--source include/no_protocol.inc --echo ** Setup ** --echo diff --git a/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test b/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test index 0f6084b65f6..380f2568b9c 100644 --- a/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test +++ b/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test @@ -46,17 +46,23 @@ INSERT INTO t1 VALUES('aa','bb'); SET SESSION sql_buffer_result = 1; +--disable_ps_protocol SHOW STATUS LIKE 'Created_tmp_tables'; +--enable_ps_protocol --echo Expected value : 0. SELECT * FROM t1; +--disable_ps_protocol SHOW STATUS LIKE 'Created_tmp_tables'; +--enable_ps_protocol --echo Expected value : 1. SELECT * FROM t1; +--disable_ps_protocol SHOW STATUS LIKE 'Created_tmp_tables'; +--enable_ps_protocol --echo Expected value : 2. --echo '#--------------------FN_DYNVARS_156_02-------------------------#' @@ -66,12 +72,16 @@ SHOW STATUS LIKE 'Created_tmp_tables'; SET SESSION sql_buffer_result = 0; +--disable_ps_protocol SHOW STATUS LIKE 'Created_tmp_tables'; +--enable_ps_protocol --echo Expected value : 2. SELECT * FROM t1; +--disable_ps_protocol SHOW STATUS LIKE 'Created_tmp_tables'; +--enable_ps_protocol --echo Expected value : 2. --echo '#--------------------FN_DYNVARS_156_03-------------------------#' diff --git a/mysql-test/suite/vcol/t/wrong_arena.test b/mysql-test/suite/vcol/t/wrong_arena.test index 3d65dac9219..8ac1af5c36b 100644 --- a/mysql-test/suite/vcol/t/wrong_arena.test +++ b/mysql-test/suite/vcol/t/wrong_arena.test @@ -14,7 +14,9 @@ create table t1 (a datetime, # other issues e int as ((a,1) in ((1,1),(2,1),(NULL,1))) # cmp_item_row::alloc_comparators() ); +enable_prepare_warnings; show create table t1; +disable_prepare_warnings; connect con1, localhost, root; disable_warnings; insert t1 (a) values ('2010-10-10 10:10:10'); diff --git a/mysql-test/t/analyze_stmt.test b/mysql-test/t/analyze_stmt.test index d02139fe0c8..15fc00a321d 100644 --- a/mysql-test/t/analyze_stmt.test +++ b/mysql-test/t/analyze_stmt.test @@ -196,7 +196,7 @@ drop table t1; --echo # create table t1 (i int); insert into t1 values (1); -analyze select * from t1 into @var; +analyze select * into @var from t1 ; drop table t1; --echo # @@ -223,9 +223,9 @@ drop table t1; create table t1(a int); insert into t1 values (1),(2); -analyze select a from t1 where a <2 into @var; +analyze select a into @var from t1 where a <2 ; --error ER_TOO_MANY_ROWS -analyze select a from t1 into @var; +analyze select a into @var from t1 ; analyze insert into t1 select * from t1; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index d391e5f5059..6c5b1cab95f 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1907,6 +1907,36 @@ SELECT * FROM t2; SHOW CREATE TABLE t2; DROP TABLE t1,t2; + +--echo # +--echo # MDEV-14926 AddressSanitizer: heap-use-after-free in make_date_time on weird combination of functions +--echo # + +DO INET_ATON( FROM_UNIXTIME( @@timestamp, ( TRIM( UNHEX(HEX('%m.%d.%Y') ) ) ) ) ); + +CREATE TABLE t1 (d DATE); +INSERT INTO t1 VALUES ('1989-03-10'); +SELECT TIME_FORMAT('23:59:43', BINARY d) AS f FROM t1 GROUP BY 'foo'; +DROP TABLE t1; + +CREATE TABLE t1 (d DATE) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('1900-01-01'); +SELECT LENGTH( DATE_FORMAT( d, BINARY DATABASE() ) ) AS f FROM t1 GROUP BY d; +DROP TABLE t1; + +--echo # +--echo # MDEV-18667 ASAN heap-use-after-free in make_date_time / Arg_comparator::compare_string / Item_func_nullif::compare +--echo # + +SELECT NULLIF('foo', FROM_UNIXTIME('2012-12-12 12:12:12', TRIM(0))); + +--echo # +--echo # MDEV-18626 ASAN stack-buffer-overflow in int10_to_str / make_date_time upon DATE_FORMAT +--echo # + +SELECT DATE_FORMAT(100000000000, '%j'); + + --echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/kill_processlist-6619.test b/mysql-test/t/kill_processlist-6619.test index d984924f9db..c272e68a877 100644 --- a/mysql-test/t/kill_processlist-6619.test +++ b/mysql-test/t/kill_processlist-6619.test @@ -6,6 +6,7 @@ --connect (con1,localhost,root,,) --let $con_id = `SELECT CONNECTION_ID()` +--replace_result Execute Query --replace_column 1 # 3 # 6 # 7 # SHOW PROCESSLIST; SET DEBUG_SYNC='before_execute_sql_command SIGNAL ready WAIT_FOR go'; @@ -29,5 +30,6 @@ let $wait_condition= WHERE info is NULL; --source include/wait_condition.inc +--replace_result Execute Query --replace_column 1 # 3 # 6 # 7 # SHOW PROCESSLIST; diff --git a/mysql-test/t/log_slow_debug.test b/mysql-test/t/log_slow_debug.test new file mode 100644 index 00000000000..35b5b93423d --- /dev/null +++ b/mysql-test/t/log_slow_debug.test @@ -0,0 +1,126 @@ +-- source include/have_debug.inc + +SET @org_slow_query_log= @@global.slow_query_log; +SET @org_log_output= @@global.log_output; +SET @org_log_slow_admin_statements= @@global.log_slow_admin_statements; + +SET @@GLOBAL.slow_query_log=OFF; +SET @@GLOBAL.log_output='TABLE'; +FLUSH SLOW LOGS; +SET @@GLOBAL.slow_query_log=ON; +SET @@GLOBAL.log_slow_admin_statements=ON; +SET SESSION debug_dbug="+d,simulate_slow_query"; + +DELIMITER $$; +CREATE PROCEDURE show_slow_log() +BEGIN + SELECT CONCAT('[slow] ', sql_text) AS sql_text + FROM mysql.slow_log + WHERE sql_text NOT LIKE '%debug_dbug%'; +END +$$ +DELIMITER ;$$ + + +--echo # +--echo # Expect all admin statements in the slow log (ON,DEFAULT) +--echo # + +SET @@GLOBAL.log_slow_admin_statements=ON; +SET log_slow_filter=DEFAULT; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; +CALL show_slow_log(); + + +--echo # +--echo # Expect all admin statements in the slow log (ON,admin) +--echo # + +SET @@GLOBAL.log_slow_admin_statements=ON; +SET log_slow_filter=admin; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; +CALL show_slow_log(); + + +--echo # +--echo # Expect none of admin DDL statements in the slow log (ON,filesort) +--echo # + +SET @@GLOBAL.log_slow_admin_statements=ON; +SET log_slow_filter=filesort; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; +CALL show_slow_log(); + + +--echo # +--echo # Expect none of admin statements in the slow log (OFF,DEFAULT) +--echo # + +SET @@GLOBAL.log_slow_admin_statements=OFF; +SET log_slow_filter=DEFAULT; +TRUNCATE TABLE mysql.slow_log; +CREATE TABLE t1 (a INT); +CREATE INDEX t1a ON t1 (a); +DROP INDEX t1a ON t1; +DROP TABLE t1; +CREATE TABLE t2 (a INT); +ALTER TABLE t2 RENAME t2; +RENAME TABLE t2 TO t3; +DROP TABLE t3; +CREATE TABLE t4 (a INT); +PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t4; +CALL show_slow_log(); + + +--echo # +--echo # Clean up +--echo # + +SET SESSION debug_dbug="-d,simulate_slow_query"; +TRUNCATE mysql.slow_log; +SET @@global.slow_query_log= @org_slow_query_log; +SET @@global.log_output= @org_log_output; +SET @@global.log_slow_admin_statements= @org_log_slow_admin_statements; +DROP PROCEDURE show_slow_log; diff --git a/mysql-test/t/log_tables.test b/mysql-test/t/log_tables.test index a4158ba6a24..f822ec8d758 100644 --- a/mysql-test/t/log_tables.test +++ b/mysql-test/t/log_tables.test @@ -855,7 +855,9 @@ SET GLOBAL slow_query_log = @old_slow_query_log; # select CONNECTION_ID() into @thread_id; +--disable_ps_protocol truncate table mysql.general_log; +--enable_ps_protocol set global general_log = on; --disable_result_log set @lparam = "000 001 002 003 004 005 006 007 008 009" diff --git a/mysql-test/t/old-mode.test b/mysql-test/t/old-mode.test index d7e8ce8ee55..e092ee78a2e 100644 --- a/mysql-test/t/old-mode.test +++ b/mysql-test/t/old-mode.test @@ -22,7 +22,8 @@ drop table t1,t2; --replace_column 1 <Id> 3 <Host> 6 <Time> 7 <State> # Embedded server is hardcoded to show "Writing to net" as STATE. ---replace_result "Writing to net" "NULL" +# ps-protocol will have Execute not Query +--replace_result "Writing to net" "NULL" "Execute" "Query" --replace_regex /localhost[:0-9]*/localhost/ SHOW PROCESSLIST; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 3b2445ad83d..0f965cc810a 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1197,7 +1197,7 @@ end// call p()// drop procedure p// -drop table t1; +drop table t1// create procedure p () begin diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 13ca9a528c6..3adbe95f837 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -47,7 +47,9 @@ insert into t1 values (5,5,5); check table t1 changed; check table t1 medium; check table t1 extended; +--disable_ps_protocol show index from t1; +--enable_ps_protocol --disable_metadata --error ER_DUP_ENTRY insert into t1 values (5,5,5); @@ -72,7 +74,9 @@ drop table t1; show variables like "wait_timeout%"; show variables like "WAIT_timeout%"; show variables like "this_doesn't_exists%"; +--disable_ps_protocol show table status from test like "this_doesn't_exists%"; +--enable_ps_protocol show databases; show databases like "test%"; --disable_metadata @@ -409,7 +413,9 @@ CREATE TABLE t1( PRIMARY KEY(field1(1000)) ); --enable_metadata +--disable_ps_protocol show index from t1; +--enable_ps_protocol --disable_metadata drop table t1; @@ -707,11 +713,15 @@ set names utf8; --echo ---------------------------------------------------------------- +--disable_ps_protocol SHOW CHARACTER SET LIKE 'utf8'; +--enable_ps_protocol --echo ---------------------------------------------------------------- +--disable_ps_protocol SHOW COLLATION LIKE 'latin1_bin'; +--enable_ps_protocol --echo ---------------------------------------------------------------- @@ -727,7 +737,9 @@ SHOW CREATE TABLE t1; --echo ---------------------------------------------------------------- +--disable_ps_protocol SHOW INDEX FROM t1; +--enable_ps_protocol --echo ---------------------------------------------------------------- @@ -774,8 +786,10 @@ SHOW COLUMNS FROM t1; --echo ---------------------------------------------------------------- +--disable_ps_protocol --replace_column 6 # SHOW TRIGGERS LIKE 't1'; +--enable_ps_protocol --echo ---------------------------------------------------------------- @@ -1364,9 +1378,11 @@ let $wait_timeout= 10; let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%GET_LOCK%' AND ID != CONNECTION_ID(); --source include/wait_condition.inc --replace_column 1 ### 3 ### 6 ### 7 ### +--replace_result "Execute" "Query" SHOW PROCESSLIST; SET NAMES utf8; --replace_column 1 ### 3 ### 6 ### 7 ### +--replace_result "Execute" "Query" SHOW PROCESSLIST; SELECT RELEASE_LOCK('t'); --connection con1 diff --git a/mysql-test/t/sp-ucs2.test b/mysql-test/t/sp-ucs2.test index 3532169e5a1..a1aec8071b4 100644 --- a/mysql-test/t/sp-ucs2.test +++ b/mysql-test/t/sp-ucs2.test @@ -52,16 +52,16 @@ CREATE FUNCTION f() BEGIN RETURN ''; END| -SHOW CREATE FUNCTION f; -DROP FUNCTION f; +SHOW CREATE FUNCTION f| +DROP FUNCTION f| CREATE FUNCTION f() RETURNS VARCHAR(64) BINARY UNICODE BEGIN RETURN ''; END| -SHOW CREATE FUNCTION f; -DROP FUNCTION f; +SHOW CREATE FUNCTION f| +DROP FUNCTION f| # @@ -72,16 +72,16 @@ CREATE FUNCTION f() BEGIN RETURN ''; END| -SHOW CREATE FUNCTION f; -DROP FUNCTION f; +SHOW CREATE FUNCTION f| +DROP FUNCTION f| CREATE FUNCTION f() RETURNS VARCHAR(64) BINARY ASCII BEGIN RETURN ''; END| -SHOW CREATE FUNCTION f; -DROP FUNCTION f; +SHOW CREATE FUNCTION f| +DROP FUNCTION f| # # Testing COLLATE in OUT parameter diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index cafcee0391e..ac80c6cbf87 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -8051,7 +8051,7 @@ create procedure p1() begin select * from t1; end$ call p1$ create table t1 (a integer)$ call p1$ -alter table t1 add b integer; +alter table t1 add b integer$ call p1$ delimiter ;$ diff --git a/mysql-test/t/sp_notembedded.test b/mysql-test/t/sp_notembedded.test index 41bfd871c39..1b481767fbe 100644 --- a/mysql-test/t/sp_notembedded.test +++ b/mysql-test/t/sp_notembedded.test @@ -118,7 +118,7 @@ end| # a procedure which use tables and recursion create table t3 (a int)| insert into t3 values (0)| -create view v1 as select a from t3; +create view v1 as select a from t3| create procedure bug10100pt(level int, lim int) begin if level < lim then diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index a9759b99269..7d6faba9789 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -689,7 +689,7 @@ END| LOCK TABLES t1 WRITE| CALL p1()| -FLUSH TABLES; +FLUSH TABLES| UNLOCK TABLES| CALL p1()| diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test index 7853b528e8f..4bd8dfdf058 100644 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@ -1570,7 +1570,9 @@ INSERT INTO t2 values(1),(2); EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 GROUP BY a HAVING a > 1); flush status; CREATE TABLE t3 SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 GROUP BY a HAVING a > 1); +--disable_ps_protocol SHOW STATUS LIKE 'Created_tmp_tables'; +--enable_ps_protocol DROP TABLE t1,t2,t3; --echo # diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index fb44362b537..b44ae2a0a76 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -115,8 +115,10 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES ('2002-10-24 14:50:32'),('2002-10-24 14:50:33'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'); flush status; +--disable_ps_protocol select * from t1 group by d; show status like "created_tmp%tables"; +--enable_ps_protocol drop table t1; # Fix for BUG#8921: Check that temporary table is ingored by view commands. diff --git a/mysql-test/t/tmp_table_count-7586.test b/mysql-test/t/tmp_table_count-7586.test index e7bac127815..8bfb0e7c5cf 100644 --- a/mysql-test/t/tmp_table_count-7586.test +++ b/mysql-test/t/tmp_table_count-7586.test @@ -9,12 +9,16 @@ create view v2 as select a from t2; flush status; select * from v2; +--disable_ps_protocol show status like '%Created_tmp%'; +--enable_ps_protocol explain select * from v2; select * from (select * from t2) T1; +--disable_ps_protocol show status like '%Created_tmp%'; +--enable_ps_protocol explain select * from (select * from t2) T1; diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test index 5a02c038caa..af26a69c581 100644 --- a/mysql-test/t/type_year.test +++ b/mysql-test/t/type_year.test @@ -214,6 +214,17 @@ SELECT * FROM t1 WHERE a=10 AND a>=10; EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=10 AND a>=10; DROP TABLE t1; + +--echo # +--echo # MDEV-16958 Assertion `field_length < 5' failed in Field_year::val_str or data corruption upon SELECT with UNION and aggregate functions +--echo # + +CREATE TABLE t1 (f YEAR); +INSERT IGNORE INTO t1 VALUES (1971),(1972); +SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1 UNION SELECT MAX( NULLIF( f, '1900' ) ) AS f FROM t1; +DROP TABLE t1; + + --echo # --echo # End of 10.1 tests --echo # diff --git a/mysql-test/t/userstat.test b/mysql-test/t/userstat.test index 9ce3a32c442..547138cfeaa 100644 --- a/mysql-test/t/userstat.test +++ b/mysql-test/t/userstat.test @@ -73,8 +73,11 @@ select * from information_schema.index_statistics; select * from information_schema.table_statistics; show table_statistics; show index_statistics; ---query_vertical select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics; ---query_vertical select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics; +--query_vertical select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics; +--query_vertical select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics; +# different values in --ps-protocol +select OTHER_COMMANDS IN (7,8) from information_schema.client_statistics; +select OTHER_COMMANDS IN (7,8) from information_schema.user_statistics; flush table_statistics; flush index_statistics; select * from information_schema.index_statistics; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 76c47be3efc..7fa7807d19a 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2433,6 +2433,7 @@ DROP TABLE t1; # Bug#15943 mysql_next_result hangs on invalid SHOW CREATE VIEW # +--disable_ps_protocol delimiter //; drop table if exists t1; drop view if exists v1; @@ -2443,6 +2444,7 @@ show create view v1; drop view v1; // delimiter ;// +--enable_ps_protocol # @@ -3953,7 +3955,9 @@ CREATE VIEW v1 AS SELECT f1() FROM t1; let $MYSQLD_DATADIR= `SELECT @@datadir`; copy_file std_data/bug48449.frm $MYSQLD_DATADIR/test/v2.frm; +enable_prepare_warnings; SHOW CREATE VIEW v1; +disable_prepare_warnings; DROP VIEW v1,v2; DROP TABLE t1,t2; diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh index 98241da3cba..6a6ab0dc8b5 100644 --- a/scripts/mysqldumpslow.sh +++ b/scripts/mysqldumpslow.sh @@ -38,7 +38,7 @@ GetOptions(\%opt, 'v|verbose+',# verbose 'help+', # write usage info 'd|debug+', # debug - 's=s', # what to sort by (al, at, ar, ae, c, t, l, r, e) + 's=s', # what to sort by (aa, ae, al, ar, at, a, c, e, l, r, t) 'r!', # reverse the sort order (largest last instead of first) 't=i', # just show the top n queries 'a!', # don't abstract all numbers to N and strings to 'S' @@ -202,12 +202,15 @@ Parse and summarize the MySQL slow query log. Options are -v verbose -d debug - -s ORDER what to sort by (al, at, ar, ae, c, l, r, e, t), 'at' is default + -s ORDER what to sort by (aa, ae, al, ar, at, a, c, e, l, r, t), 'at' is default + aa: average rows affected + ae: aggregated rows examined al: average lock time ar: average rows sent at: average query time - aa: average rows affected + a: rows affected c: count + e: rows examined l: lock time r: rows sent t: query time diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 6b09978d128..2d34322c59e 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -584,7 +584,7 @@ static void debug_sync_remove_action(st_debug_sync_control *ds_control, memmove(save_action, action, sizeof(st_debug_sync_action)); /* Move actions down. */ - memmove(ds_control->ds_action + dsp_idx, + memmove((void*)(ds_control->ds_action + dsp_idx), ds_control->ds_action + dsp_idx + 1, (ds_control->ds_active - dsp_idx) * sizeof(st_debug_sync_action)); @@ -595,8 +595,8 @@ static void debug_sync_remove_action(st_debug_sync_control *ds_control, produced by the shift. Again do not use an assignment operator to avoid string allocation/copy. */ - memmove(ds_control->ds_action + ds_control->ds_active, save_action, - sizeof(st_debug_sync_action)); + memmove((void*)(ds_control->ds_action + ds_control->ds_active), + save_action, sizeof(st_debug_sync_action)); } DBUG_VOID_RETURN; diff --git a/sql/encryption.cc b/sql/encryption.cc index 52eab262570..e5b54633066 100644 --- a/sql/encryption.cc +++ b/sql/encryption.cc @@ -25,6 +25,10 @@ struct encryption_service_st encryption_handler; extern "C" { +uint no_get_key(uint, uint, uchar*, uint*) +{ + return ENCRYPTION_KEY_VERSION_INVALID; +} uint no_key(uint) { return ENCRYPTION_KEY_VERSION_INVALID; @@ -47,6 +51,11 @@ static unsigned int get_length(unsigned int slen, unsigned int key_id, return my_aes_get_size(MY_AES_CBC, slen); } +uint ctx_size(unsigned int, unsigned int) +{ + return MY_AES_CTX_SIZE; +} + } /* extern "C" */ int initialize_encryption_plugin(st_plugin_int *plugin) @@ -72,8 +81,7 @@ int initialize_encryption_plugin(st_plugin_int *plugin) if (handle->crypt_ctx_size) encryption_handler.encryption_ctx_size_func= handle->crypt_ctx_size; else - encryption_handler.encryption_ctx_size_func= - (uint (*)(unsigned int, unsigned int))my_aes_ctx_size; + encryption_handler.encryption_ctx_size_func= ctx_size; encryption_handler.encryption_ctx_init_func= handle->crypt_ctx_init ? handle->crypt_ctx_init : ctx_init; @@ -102,8 +110,7 @@ int finalize_encryption_plugin(st_plugin_int *plugin) if (used) { - encryption_handler.encryption_key_get_func= - (uint (*)(uint, uint, uchar*, uint*))no_key; + encryption_handler.encryption_key_get_func= no_get_key; encryption_handler.encryption_key_get_latest_version_func= no_key; encryption_handler.encryption_ctx_size_func= zero_size; } diff --git a/sql/handler.h b/sql/handler.h index 229197a2c78..848c9956868 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1686,7 +1686,6 @@ struct Table_scope_and_contents_source_st uint options; /* OR of HA_CREATE_ options */ uint merge_insert_method; uint extra_size; /* length of extra data segment */ - SQL_I_List<TABLE_LIST> merge_list; handlerton *db_type; /** Row type of the table definition. @@ -1717,6 +1716,7 @@ struct Table_scope_and_contents_source_st TABLE_LIST *pos_in_locked_tables; MDL_ticket *mdl_ticket; bool table_was_deleted; + TABLE_LIST *merge_list; void init() { diff --git a/sql/item.cc b/sql/item.cc index 6c9496c9393..6c605dba776 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -10437,7 +10437,10 @@ bool Item_type_holder::join_types(THD *thd, Item *item) break; } default: - max_length= MY_MAX(max_length, display_length(item)); + if (real_field_type() == MYSQL_TYPE_YEAR) + max_length= MY_MAX(max_length, item->max_length); + else + max_length= MY_MAX(max_length, display_length(item)); }; maybe_null|= item->maybe_null; get_full_info(item); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 82dbca5b23c..23d9c3d2f04 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -455,7 +455,7 @@ err: Create a formated date/time value in a string. */ -static bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, +static bool make_date_time(const LEX_CSTRING &format, MYSQL_TIME *l_time, timestamp_type type, MY_LOCALE *locale, String *str) { char intbuff[15]; @@ -469,7 +469,7 @@ static bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, if (l_time->neg) str->append('-'); - end= (ptr= format->format.str) + format->format.length; + end= (ptr= format.str) + format.length; for (; ptr != end ; ptr++) { if (*ptr != '%' || ptr+1 == end) @@ -589,7 +589,7 @@ static bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time, str->append_with_prefill(intbuff, length, 2, '0'); break; case 'j': - if (type == MYSQL_TIMESTAMP_TIME) + if (type == MYSQL_TIMESTAMP_TIME || !l_time->month || !l_time->year) return 1; length= (uint) (int10_to_str(calc_daynr(l_time->year,l_time->month, l_time->day) - @@ -2012,6 +2012,7 @@ uint Item_func_date_format::format_length(const String *format) String *Item_func_date_format::val_str(String *str) { + StringBuffer<64> format_buffer; String *format; MYSQL_TIME l_time; uint size; @@ -2021,7 +2022,7 @@ String *Item_func_date_format::val_str(String *str) if (get_arg0_date(&l_time, is_time_flag)) return 0; - if (!(format = args[1]->val_str(str)) || !format->length()) + if (!(format= args[1]->val_str(&format_buffer)) || !format->length()) goto null_date; if (fixed_length) @@ -2032,18 +2033,13 @@ String *Item_func_date_format::val_str(String *str) if (size < MAX_DATE_STRING_REP_LENGTH) size= MAX_DATE_STRING_REP_LENGTH; - if (format == str) - str= &value; // Save result here + DBUG_ASSERT(format != str); if (str->alloc(size)) goto null_date; - DATE_TIME_FORMAT date_time_format; - date_time_format.format.str= (char*) format->ptr(); - date_time_format.format.length= format->length(); - /* Create the result string */ str->set_charset(collation.collation); - if (!make_date_time(&date_time_format, &l_time, + if (!make_date_time(format->lex_cstring(), &l_time, is_time_format ? MYSQL_TIMESTAMP_TIME : MYSQL_TIMESTAMP_DATE, locale, str)) diff --git a/sql/log_slow.h b/sql/log_slow.h index c52722f0cd7..9811d298335 100644 --- a/sql/log_slow.h +++ b/sql/log_slow.h @@ -34,4 +34,5 @@ #define QPLAN_FILESORT_PRIORITY_QUEUE (1U << 9) /* ... */ +#define QPLAN_STATUS (1UL << 31) /* not in the slow_log_filter */ #define QPLAN_MAX (1UL << 31) /* reserved as placeholder */ diff --git a/sql/mdl.h b/sql/mdl.h index 2aeaef89f26..b76d70763e7 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -469,6 +469,16 @@ public: DBUG_ASSERT(ticket == NULL); type= type_arg; } + void move_from(MDL_request &from) + { + type= from.type; + duration= from.duration; + ticket= from.ticket; + next_in_list= from.next_in_list; + prev_in_list= from.prev_in_list; + key.mdl_key_init(&from.key); + from.ticket= NULL; // that's what "move" means + } /** Is this a request for a lock which allow data to be updated? diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 1352bb64be8..b985607eeb1 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -9613,7 +9613,7 @@ static int get_options(int *argc_ptr, char ***argv_ptr) global_system_variables.binlog_format= BINLOG_FORMAT_ROW; } - if (!opt_bootstrap && WSREP_PROVIDER_EXISTS && + if (!opt_bootstrap && WSREP_PROVIDER_EXISTS && WSREP_ON && global_system_variables.binlog_format != BINLOG_FORMAT_ROW) { diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 72ba95e30d1..da5e9707595 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1342,8 +1342,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() - Use rowids from unique to run a disk-ordered sweep */ -QUICK_INDEX_SORT_SELECT::QUICK_INDEX_SORT_SELECT(THD *thd_param, - TABLE *table) +QUICK_INDEX_SORT_SELECT::QUICK_INDEX_SORT_SELECT(THD *thd_param, TABLE *table) :unique(NULL), pk_quick_select(NULL), thd(thd_param) { DBUG_ENTER("QUICK_INDEX_SORT_SELECT::QUICK_INDEX_SORT_SELECT"); @@ -5100,6 +5099,16 @@ typedef struct st_partial_index_intersect_info key_map filtered_scans; /* scans to be filtered by cpk conditions */ MY_BITMAP *intersect_fields; /* bitmap of fields used in intersection */ + + void init() + { + common_info= NULL; + intersect_fields= NULL; + records_sent_to_unique= records= length= in_memory= use_cpk_filter= 0; + cost= index_read_cost= in_memory_cost= 0.0; + filtered_scans.init(); + filtered_scans.clear_all(); + } } PARTIAL_INDEX_INTERSECT_INFO; @@ -5236,8 +5245,7 @@ bool prepare_search_best_index_intersect(PARAM *param, if (!n_index_scans) return 1; - bzero(init, sizeof(*init)); - init->filtered_scans.init(); + init->init(); init->common_info= common; init->cost= cutoff_cost; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index d7aec8fd451..3d10166b3d8 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -63,7 +63,7 @@ partition_info *partition_info::get_clone(THD *thd) mem_alloc_error(sizeof(partition_element)); DBUG_RETURN(NULL); } - memcpy(part_clone, part, sizeof(partition_element)); + *part_clone= *part; part_clone->subpartitions.empty(); while ((subpart= (subpart_it++))) { @@ -73,7 +73,7 @@ partition_info *partition_info::get_clone(THD *thd) mem_alloc_error(sizeof(partition_element)); DBUG_RETURN(NULL); } - memcpy(subpart_clone, subpart, sizeof(partition_element)); + *subpart_clone= *subpart; part_clone->subpartitions.push_back(subpart_clone, mem_root); } clone->partitions.push_back(part_clone, mem_root); @@ -1627,12 +1627,11 @@ void partition_info::print_no_partition_found(TABLE *table_arg, myf errflag) TABLE_LIST table_list; THD *thd= current_thd; - bzero(&table_list, sizeof(table_list)); + table_list.reset(); table_list.db= table_arg->s->db.str; table_list.table_name= table_arg->s->table_name.str; - if (check_single_table_access(thd, - SELECT_ACL, &table_list, TRUE)) + if (check_single_table_access(thd, SELECT_ACL, &table_list, TRUE)) { my_message(ER_NO_PARTITION_FOR_GIVEN_VALUE, ER_THD(thd, ER_NO_PARTITION_FOR_GIVEN_VALUE_SILENT), errflag); diff --git a/sql/protocol.h b/sql/protocol.h index 6397e3dd5e6..1a6cb3bdc3c 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -230,60 +230,29 @@ class Protocol_discard : public Protocol_text { public: Protocol_discard(THD *thd_arg) : Protocol_text(thd_arg) {} - /* The real writing is done only in write() */ - virtual bool write() { return 0; } - virtual bool send_result_set_metadata(List<Item> *list, uint flags) - { - // Don't pas Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF flags - return Protocol_text::send_result_set_metadata(list, 0); - } - - // send_error is intentionally not overloaded. - virtual bool send_eof(uint server_status, uint statement_warn_count) - { - return 0; - } - - void prepare_for_resend() - { -#ifndef DBUG_OFF - field_pos= 0; -#endif - } + bool write() { return 0; } + bool send_result_set_metadata(List<Item> *, uint) { return 0; } + bool send_eof(uint, uint) { return 0; } + void prepare_for_resend() { IF_DBUG(field_pos= 0,); } /* Provide dummy overrides for any storage methods so that we avoid allocating and copying of data */ - virtual bool store_null() - { return false; } - virtual bool store_tiny(longlong from) - { return false; } - virtual bool store_short(longlong from) - { return false; } - virtual bool store_long(longlong from) - { return false; } - virtual bool store_longlong(longlong from, bool unsigned_flag) - { return false; } - virtual bool store_decimal(const my_decimal *) - { return false; } - virtual bool store(const char *from, size_t length, CHARSET_INFO *cs) - { return false; } - virtual bool store(const char *from, size_t length, - CHARSET_INFO *fromcs, CHARSET_INFO *tocs) - { return false; } - virtual bool store(MYSQL_TIME *time, int decimals) - { return false; } - virtual bool store_date(MYSQL_TIME *time) - { return false; } - virtual bool store_time(MYSQL_TIME *time, int decimals) - { return false; } - virtual bool store(float nr, uint32 decimals, String *buffer) - { return false; } - virtual bool store(double from, uint32 decimals, String *buffer) - { return false; } - virtual bool store(Field *field) - { return false; } + bool store_null() { return false; } + bool store_tiny(longlong) { return false; } + bool store_short(longlong) { return false; } + bool store_long(longlong) { return false; } + bool store_longlong(longlong, bool) { return false; } + bool store_decimal(const my_decimal *) { return false; } + bool store(const char *, size_t, CHARSET_INFO *) { return false; } + bool store(const char *, size_t, CHARSET_INFO *, CHARSET_INFO *) { return false; } + bool store(MYSQL_TIME *, int) { return false; } + bool store_date(MYSQL_TIME *) { return false; } + bool store_time(MYSQL_TIME *, int) { return false; } + bool store(float, uint32, String *) { return false; } + bool store(double, uint32, String *) { return false; } + bool store(Field *) { return false; } }; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 537dcc77c8c..1d1cca0568e 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -8500,70 +8500,17 @@ static bool print_grants_for_role(THD *thd, ACL_ROLE * role) } -/** checks privileges for SHOW GRANTS and SHOW CREATE USER - - @note that in case of SHOW CREATE USER the parser guarantees - that a role can never happen here, so *rolename will never - be assigned to -*/ -static bool check_show_access(THD *thd, LEX_USER *lex_user, char **username, - char **hostname, char **rolename) -{ - DBUG_ENTER("check_show_access"); - - if (lex_user->user.str == current_user.str) - { - *username= thd->security_ctx->priv_user; - *hostname= thd->security_ctx->priv_host; - } - else if (lex_user->user.str == current_role.str) - { - *rolename= thd->security_ctx->priv_role; - } - else if (lex_user->user.str == current_user_and_current_role.str) - { - *username= thd->security_ctx->priv_user; - *hostname= thd->security_ctx->priv_host; - *rolename= thd->security_ctx->priv_role; - } - else - { - Security_context *sctx= thd->security_ctx; - bool do_check_access; - - lex_user= get_current_user(thd, lex_user); - if (!lex_user) - DBUG_RETURN(TRUE); - - if (lex_user->is_role()) - { - *rolename= lex_user->user.str; - do_check_access= strcmp(*rolename, sctx->priv_role); - } - else - { - *username= lex_user->user.str; - *hostname= lex_user->host.str; - do_check_access= strcmp(*username, sctx->priv_user) || - strcmp(*hostname, sctx->priv_host); - } - - if (do_check_access && check_access(thd, SELECT_ACL, "mysql", 0, 0, 1, 0)) - DBUG_RETURN(TRUE); - } - DBUG_RETURN(FALSE); -} bool mysql_show_create_user(THD *thd, LEX_USER *lex_user) { - char *username= NULL, *hostname= NULL; + const char *username= NULL, *hostname= NULL; char buff[1024]; //Show create user should not take more than 1024 bytes. Protocol *protocol= thd->protocol; bool error= false; ACL_USER *acl_user; DBUG_ENTER("mysql_show_create_user"); - if (check_show_access(thd, lex_user, &username, &hostname, NULL)) + if (get_show_user(thd, lex_user, &username, &hostname, NULL)) DBUG_RETURN(TRUE); List<Item> field_list; @@ -8635,6 +8582,57 @@ void mysql_show_grants_get_fields(THD *thd, List<Item> *fields, fields->push_back(field, thd->mem_root); } +/** checks privileges for SHOW GRANTS and SHOW CREATE USER + + @note that in case of SHOW CREATE USER the parser guarantees + that a role can never happen here, so *rolename will never + be assigned to +*/ +bool get_show_user(THD *thd, LEX_USER *lex_user, const char **username, + const char **hostname, const char **rolename) +{ + if (lex_user->user.str == current_user.str) + { + *username= thd->security_ctx->priv_user; + *hostname= thd->security_ctx->priv_host; + return 0; + } + if (lex_user->user.str == current_role.str) + { + *rolename= thd->security_ctx->priv_role; + return 0; + } + if (lex_user->user.str == current_user_and_current_role.str) + { + *username= thd->security_ctx->priv_user; + *hostname= thd->security_ctx->priv_host; + *rolename= thd->security_ctx->priv_role; + return 0; + } + + Security_context *sctx= thd->security_ctx; + bool do_check_access; + + if (!(lex_user= get_current_user(thd, lex_user))) + return 1; + + if (lex_user->is_role()) + { + *rolename= lex_user->user.str; + do_check_access= strcmp(*rolename, sctx->priv_role); + } + else + { + *username= lex_user->user.str; + *hostname= lex_user->host.str; + do_check_access= strcmp(*username, sctx->priv_user) || + strcmp(*hostname, sctx->priv_host); + } + + if (do_check_access && check_access(thd, SELECT_ACL, "mysql", 0, 0, 1, 0)) + return 1; + return 0; +} /* SHOW GRANTS; Send grants for a user to the client @@ -8650,7 +8648,7 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user) ACL_ROLE *acl_role= NULL; char buff[1024]; Protocol *protocol= thd->protocol; - char *username= NULL, *hostname= NULL, *rolename= NULL; + const char *username= NULL, *hostname= NULL, *rolename= NULL; DBUG_ENTER("mysql_show_grants"); if (!initialized) @@ -8659,8 +8657,9 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user) DBUG_RETURN(TRUE); } - if (check_show_access(thd, lex_user, &username, &hostname, &rolename)) + if (get_show_user(thd, lex_user, &username, &hostname, &rolename)) DBUG_RETURN(TRUE); + DBUG_ASSERT(rolename || username); List<Item> field_list; diff --git a/sql/sql_acl.h b/sql/sql_acl.h index aeda2696894..a4182a4d300 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -246,6 +246,8 @@ ulong get_table_grant(THD *thd, TABLE_LIST *table); ulong get_column_grant(THD *thd, GRANT_INFO *grant, const char *db_name, const char *table_name, const char *field_name); +bool get_show_user(THD *thd, LEX_USER *lex_user, const char **username, + const char **hostname, const char **rolename); void mysql_show_grants_get_fields(THD *thd, List<Item> *fields, const char *name); bool mysql_show_grants(THD *thd, LEX_USER *user); diff --git a/sql/sql_admin.h b/sql/sql_admin.h index ce7308434c5..96594fad0cb 100644 --- a/sql/sql_admin.h +++ b/sql/sql_admin.h @@ -28,7 +28,7 @@ int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, /** Sql_cmd_analyze_table represents the ANALYZE TABLE statement. */ -class Sql_cmd_analyze_table : public Sql_cmd_admin +class Sql_cmd_analyze_table : public Sql_cmd { public: /** @@ -53,7 +53,7 @@ public: /** Sql_cmd_check_table represents the CHECK TABLE statement. */ -class Sql_cmd_check_table : public Sql_cmd_admin +class Sql_cmd_check_table : public Sql_cmd { public: /** @@ -77,7 +77,7 @@ public: /** Sql_cmd_optimize_table represents the OPTIMIZE TABLE statement. */ -class Sql_cmd_optimize_table : public Sql_cmd_admin +class Sql_cmd_optimize_table : public Sql_cmd { public: /** @@ -102,7 +102,7 @@ public: /** Sql_cmd_repair_table represents the REPAIR TABLE statement. */ -class Sql_cmd_repair_table : public Sql_cmd_admin +class Sql_cmd_repair_table : public Sql_cmd { public: /** diff --git a/sql/sql_alter.cc b/sql/sql_alter.cc index 23522795cdc..f6db1847063 100644 --- a/sql/sql_alter.cc +++ b/sql/sql_alter.cc @@ -234,7 +234,7 @@ bool Sql_cmd_alter_table::execute(THD *thd) DBUG_RETURN(TRUE); /* purecov: inspected */ /* If it is a merge table, check privileges for merge children. */ - if (create_info.merge_list.first) + if (create_info.merge_list) { /* The user must have (SELECT_ACL | UPDATE_ACL | DELETE_ACL) on the @@ -272,7 +272,7 @@ bool Sql_cmd_alter_table::execute(THD *thd) */ if (check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL, - create_info.merge_list.first, FALSE, UINT_MAX, FALSE)) + create_info.merge_list, FALSE, UINT_MAX, FALSE)) DBUG_RETURN(TRUE); } @@ -283,9 +283,9 @@ bool Sql_cmd_alter_table::execute(THD *thd) { // Rename of table TABLE_LIST tmp_table; - memset(&tmp_table, 0, sizeof(tmp_table)); - tmp_table.table_name= lex->name.str; - tmp_table.db= select_lex->db; + tmp_table.init_one_table(select_lex->db, strlen(select_lex->db), + lex->name.str, lex->name.length, + lex->name.str, TL_IGNORE); tmp_table.grant.privilege= priv; if (check_grant(thd, INSERT_ACL | CREATE_ACL, &tmp_table, FALSE, UINT_MAX, FALSE)) diff --git a/sql/sql_alter.h b/sql/sql_alter.h index 9114c4bd075..e33efc9476f 100644 --- a/sql/sql_alter.h +++ b/sql/sql_alter.h @@ -370,7 +370,7 @@ private: statements. @todo move Alter_info and other ALTER generic structures from Lex here. */ -class Sql_cmd_common_alter_table : public Sql_cmd_admin +class Sql_cmd_common_alter_table : public Sql_cmd { protected: /** diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 91a80c552cb..8b3e945e891 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -298,9 +298,9 @@ bool get_ev_num_info(EV_NUM_INFO *ev_info, NUM_INFO *info, const char *num) } // get_ev_num_info -void free_string(String *s) +void free_string(void* str, TREE_FREE, void*) { - s->free(); + ((String*)str)->free(); } diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index 820877f2a69..738737f0edc 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -68,7 +68,7 @@ int compare_ulonglong2(void* cmp_arg __attribute__((unused)), int compare_decimal2(int* len, const char *s, const char *t); Procedure *proc_analyse_init(THD *thd, ORDER *param, select_result *result, List<Item> &field_list); -void free_string(String*); +void free_string(void* str, TREE_FREE, void*); class analyse; class field_info :public Sql_alloc @@ -121,8 +121,7 @@ public: must_be_blob(0), was_zero_fill(0), was_maybe_zerofill(0), can_be_still_num(1) { init_tree(&tree, 0, 0, sizeof(String), (qsort_cmp2) sortcmp2, - (tree_element_free) free_string, NULL, - MYF(MY_THREAD_SPECIFIC)); }; + free_string, NULL, MYF(MY_THREAD_SPECIFIC)); }; void add(); void get_opt_type(String*, ha_rows); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6592dcd8f6f..d6aa6456710 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2370,18 +2370,28 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length) } -int THD::send_explain_fields(select_result *result, uint8 explain_flags, bool is_analyze) +int THD::prepare_explain_fields(select_result *result, List<Item> *field_list, + uint8 explain_flags, bool is_analyze) { - List<Item> field_list; if (lex->explain_json) - make_explain_json_field_list(field_list, is_analyze); + make_explain_json_field_list(*field_list, is_analyze); else - make_explain_field_list(field_list, explain_flags, is_analyze); + make_explain_field_list(*field_list, explain_flags, is_analyze); + + return result->prepare(*field_list, NULL); +} - result->prepare(field_list, NULL); - return (result->send_result_set_metadata(field_list, - Protocol::SEND_NUM_ROWS | - Protocol::SEND_EOF)); + +int THD::send_explain_fields(select_result *result, + uint8 explain_flags, + bool is_analyze) +{ + List<Item> field_list; + int rc; + rc= prepare_explain_fields(result, &field_list, explain_flags, is_analyze) || + result->send_result_set_metadata(field_list, Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF); + return rc; } @@ -2456,7 +2466,7 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags, if (is_analyze) { field_list.push_back(item= new (mem_root) - Item_float(this, "r_rows", 0.1234, 10, 4), + Item_float(this, "r_rows", 0.1234, 2, 4), mem_root); item->maybe_null=1; } diff --git a/sql/sql_class.h b/sql/sql_class.h index 7e05274cf06..d701d4cb46c 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3523,6 +3523,8 @@ public: void add_changed_table(TABLE *table); void add_changed_table(const char *key, long key_length); CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length); + int prepare_explain_fields(select_result *result, List<Item> *field_list, + uint8 explain_flags, bool is_analyze); int send_explain_fields(select_result *result, uint8 explain_flags, bool is_analyze); void make_explain_field_list(List<Item> &field_list, uint8 explain_flags, @@ -4588,6 +4590,7 @@ public: virtual ~select_result_sink() {}; }; +class select_result_interceptor; /* Interface for sending tabular data, together with some other stuff: @@ -4680,11 +4683,10 @@ public: /* This returns - - FALSE if the class sends output row to the client - - TRUE if the output is set elsewhere (a file, @variable, or table). - Currently all intercepting classes derive from select_result_interceptor. + - NULL if the class sends output row to the client + - this if the output is set elsewhere (a file, @variable, or table). */ - virtual bool is_result_interceptor()=0; + virtual select_result_interceptor *result_interceptor()=0; }; @@ -4752,7 +4754,7 @@ public: } /* Remove gcc warning */ uint field_count(List<Item> &fields) const { return 0; } bool send_result_set_metadata(List<Item> &fields, uint flag) { return FALSE; } - bool is_result_interceptor() { return true; } + select_result_interceptor *result_interceptor() { return this; } /* Instruct the object to not call my_ok(). Client output will be handled @@ -4780,7 +4782,7 @@ public: virtual bool check_simple_select() const { return FALSE; } void abort_result_set(); virtual void cleanup(); - bool is_result_interceptor() { return false; } + select_result_interceptor *result_interceptor() { return NULL; } }; @@ -5735,13 +5737,18 @@ public: #define CF_UPDATES_DATA (1U << 18) /** + Not logged into slow log as "admin commands" +*/ +#define CF_ADMIN_COMMAND (1U << 19) + +/** SP Bulk execution safe */ -#define CF_SP_BULK_SAFE (1U << 19) +#define CF_SP_BULK_SAFE (1U << 20) /** SP Bulk execution optimized */ -#define CF_SP_BULK_OPTIMIZED (1U << 20) +#define CF_SP_BULK_OPTIMIZED (1U << 21) /* Bits in server_command_flags */ diff --git a/sql/sql_cmd.h b/sql/sql_cmd.h index d6220f9ee44..e33f8e443dc 100644 --- a/sql/sql_cmd.h +++ b/sql/sql_cmd.h @@ -148,8 +148,6 @@ public: */ virtual bool execute(THD *thd) = 0; - virtual bool log_slow_enabled_statement(const THD *thd) const; - protected: Sql_cmd() {} @@ -166,17 +164,4 @@ protected: } }; - -class Sql_cmd_admin: public Sql_cmd -{ -public: - Sql_cmd_admin() - {} - ~Sql_cmd_admin() - {} - bool log_slow_enabled_statement(const THD *thd) const; -}; - - - #endif // SQL_CMD_INCLUDED diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 4c98c9cefdb..e908e703bdd 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -358,8 +358,6 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen) sql_handler->reset(); } sql_handler->table= table; - memcpy(&sql_handler->mdl_request, &tables->mdl_request, - sizeof(tables->mdl_request)); if (!(sql_handler->lock= get_lock_data(thd, &sql_handler->table, 1, GET_LOCK_STORE_LOCKS))) @@ -373,6 +371,8 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen) if (error) goto err; + sql_handler->mdl_request.move_from(tables->mdl_request); + /* Always read all columns */ table->read_set= &table->s->all_set; if (table->vcol_set) @@ -401,9 +401,6 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen) */ table->open_by_handler= 1; - /* Safety, cleanup the pointer to satisfy MDL assertions. */ - tables->mdl_request.ticket= NULL; - if (! reopen) my_ok(thd); DBUG_PRINT("exit",("OK")); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 307473cecbd..c623336fdba 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4381,14 +4381,12 @@ select_create::binlog_show_create_table(TABLE **tables, uint count) DBUG_ASSERT(thd->is_current_stmt_binlog_format_row()); DBUG_ASSERT(tables && *tables && count > 0); - char buf[2048]; - String query(buf, sizeof(buf), system_charset_info); + StringBuffer<2048> query(system_charset_info); int result; TABLE_LIST tmp_table_list; - memset(&tmp_table_list, 0, sizeof(tmp_table_list)); + tmp_table_list.reset(); tmp_table_list.table = *tables; - query.length(0); // Have to zero it since constructor doesn't result= show_create_table(thd, &tmp_table_list, &query, create_info, WITH_DB_NAME); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 399e189a8d0..53056d220b8 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -4838,19 +4838,6 @@ bool LEX::is_partition_management() const } -bool Sql_cmd::log_slow_enabled_statement(const THD *thd) const -{ - return global_system_variables.sql_log_slow && thd->variables.sql_log_slow; -} - - -bool Sql_cmd_admin::log_slow_enabled_statement(const THD *thd) const -{ - return opt_log_slow_admin_statements && - Sql_cmd::log_slow_enabled_statement(thd); -} - - #ifdef MYSQL_SERVER uint binlog_unsafe_map[256]; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1d5de9dc276..d2dde1277a1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -546,10 +546,11 @@ void init_update_queries(void) sql_command_flags[SQLCOM_CREATE_TABLE]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS | CF_CAN_GENERATE_ROW_EVENTS; - sql_command_flags[SQLCOM_CREATE_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS; + sql_command_flags[SQLCOM_CREATE_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | + CF_REPORT_PROGRESS | CF_ADMIN_COMMAND; sql_command_flags[SQLCOM_ALTER_TABLE]= CF_CHANGES_DATA | CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS | - CF_INSERTS_DATA; + CF_INSERTS_DATA | CF_ADMIN_COMMAND; sql_command_flags[SQLCOM_TRUNCATE]= CF_CHANGES_DATA | CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_DROP_TABLE]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS; @@ -560,8 +561,10 @@ void init_update_queries(void) sql_command_flags[SQLCOM_DROP_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_ALTER_DB_UPGRADE]= CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_ALTER_DB]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS; - sql_command_flags[SQLCOM_RENAME_TABLE]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS; - sql_command_flags[SQLCOM_DROP_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS; + sql_command_flags[SQLCOM_RENAME_TABLE]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | + CF_ADMIN_COMMAND; + sql_command_flags[SQLCOM_DROP_INDEX]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS | + CF_REPORT_PROGRESS | CF_ADMIN_COMMAND; sql_command_flags[SQLCOM_CREATE_VIEW]= CF_CHANGES_DATA | CF_REEXECUTION_FRAGILE | CF_AUTO_COMMIT_TRANS; sql_command_flags[SQLCOM_DROP_VIEW]= CF_CHANGES_DATA | CF_AUTO_COMMIT_TRANS; @@ -735,10 +738,14 @@ void init_update_queries(void) The following admin table operations are allowed on log tables. */ - sql_command_flags[SQLCOM_REPAIR]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS; - sql_command_flags[SQLCOM_OPTIMIZE]|= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS; - sql_command_flags[SQLCOM_ANALYZE]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS; - sql_command_flags[SQLCOM_CHECK]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | CF_REPORT_PROGRESS; + sql_command_flags[SQLCOM_REPAIR]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | + CF_REPORT_PROGRESS | CF_ADMIN_COMMAND; + sql_command_flags[SQLCOM_OPTIMIZE]|= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | + CF_REPORT_PROGRESS | CF_ADMIN_COMMAND; + sql_command_flags[SQLCOM_ANALYZE]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | + CF_REPORT_PROGRESS | CF_ADMIN_COMMAND; + sql_command_flags[SQLCOM_CHECK]= CF_WRITE_LOGS_COMMAND | CF_AUTO_COMMIT_TRANS | + CF_REPORT_PROGRESS | CF_ADMIN_COMMAND; sql_command_flags[SQLCOM_CHECKSUM]= CF_REPORT_PROGRESS; sql_command_flags[SQLCOM_CREATE_USER]|= CF_AUTO_COMMIT_TRANS; @@ -1612,10 +1619,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, m_key); thd->set_command(command); - /* - Commands which always take a long time are logged into - the slow log only if opt_log_slow_admin_statements is set. - */ thd->enable_slow_log= true; thd->query_plan_flags= QPLAN_INIT; thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */ @@ -2062,7 +2065,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd, status_var_increment(thd->status_var.com_other); - thd->enable_slow_log&= opt_log_slow_admin_statements; thd->query_plan_flags|= QPLAN_ADMIN; if (check_global_access(thd, REPL_SLAVE_ACL)) break; @@ -2449,31 +2451,6 @@ com_multi_end: } -static bool log_slow_enabled_statement(const THD *thd) -{ - /* - TODO-10.4: Add classes Sql_cmd_create_index and Sql_cmd_drop_index - for symmetry with other admin commands, so these statements can be - handled by this command: - */ - if (thd->lex->m_sql_cmd) - return thd->lex->m_sql_cmd->log_slow_enabled_statement(thd); - - /* - Currently CREATE INDEX or DROP INDEX cause a full table rebuild - and thus classify as slow administrative statements just like - ALTER TABLE. - */ - if ((thd->lex->sql_command == SQLCOM_CREATE_INDEX || - thd->lex->sql_command == SQLCOM_DROP_INDEX) && - !opt_log_slow_admin_statements) - return true; - - return global_system_variables.sql_log_slow && - thd->variables.sql_log_slow; -} - - /* @note This function must call delete_explain_query(). @@ -2502,16 +2479,27 @@ void log_slow_statement(THD *thd) if (!thd->enable_slow_log) goto end; // E.g. SP statement + DBUG_EXECUTE_IF("simulate_slow_query", + thd->server_status|= SERVER_QUERY_WAS_SLOW;); + if (((thd->server_status & SERVER_QUERY_WAS_SLOW) || ((thd->server_status & (SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) && opt_log_queries_not_using_indexes && - !(sql_command_flags[thd->lex->sql_command] & CF_STATUS_COMMAND))) && + !(thd->query_plan_flags & QPLAN_STATUS))) && thd->get_examined_row_count() >= thd->variables.min_examined_row_limit) { thd->status_var.long_query_count++; - if (!log_slow_enabled_statement(thd)) + /* + until opt_log_slow_admin_statements is removed, it + duplicates slow_log_filter=admin + */ + if ((thd->query_plan_flags & QPLAN_ADMIN) && + !opt_log_slow_admin_statements) + goto end; + + if (!global_system_variables.sql_log_slow || !thd->variables.sql_log_slow) goto end; /* @@ -3448,6 +3436,11 @@ mysql_execute_command(THD *thd) goto error; } + if (sql_command_flags[lex->sql_command] & CF_STATUS_COMMAND) + thd->query_plan_flags|= QPLAN_STATUS; + if (sql_command_flags[lex->sql_command] & CF_ADMIN_COMMAND) + thd->query_plan_flags|= QPLAN_ADMIN; + /* Start timeouts */ thd->set_query_timer(); @@ -3510,12 +3503,14 @@ mysql_execute_command(THD *thd) case SQLCOM_SHOW_PROFILE: case SQLCOM_SELECT: { -#ifdef WITH_WSREP if (lex->sql_command == SQLCOM_SELECT) - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ) + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ); else - WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW) -#endif /* WITH_WSREP */ + { + WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); + if (lex->sql_command == SQLCOM_SHOW_PROFILE) + thd->profiling.discard_current_query(); + } thd->status_var.last_query_cost= 0.0; @@ -4080,7 +4075,6 @@ end_with_restore_list: if (check_one_table_access(thd, INDEX_ACL, all_tables)) goto error; /* purecov: inspected */ WSREP_TO_ISOLATION_BEGIN(first_table->db, first_table->table_name, NULL) - thd->query_plan_flags|= QPLAN_ADMIN; bzero((char*) &create_info, sizeof(create_info)); create_info.db_type= 0; @@ -4243,49 +4237,6 @@ end_with_restore_list: DBUG_PRINT("debug", ("lex->only_view: %d, table: %s.%s", lex->only_view, first_table->db, first_table->table_name)); - if (lex->only_view) - { - if (check_table_access(thd, SELECT_ACL, first_table, FALSE, 1, FALSE)) - { - DBUG_PRINT("debug", ("check_table_access failed")); - my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), - "SHOW", thd->security_ctx->priv_user, - thd->security_ctx->host_or_ip, first_table->alias); - goto error; - } - DBUG_PRINT("debug", ("check_table_access succeeded")); - - /* Ignore temporary tables if this is "SHOW CREATE VIEW" */ - first_table->open_type= OT_BASE_ONLY; - - } - else - { - /* - Temporary tables should be opened for SHOW CREATE TABLE, but not - for SHOW CREATE VIEW. - */ - if (thd->open_temporary_tables(all_tables)) - goto error; - - /* - The fact that check_some_access() returned FALSE does not mean that - access is granted. We need to check if first_table->grant.privilege - contains any table-specific privilege. - */ - DBUG_PRINT("debug", ("first_table->grant.privilege: %lx", - first_table->grant.privilege)); - if (check_some_access(thd, SHOW_CREATE_TABLE_ACLS, first_table) || - (first_table->grant.privilege & SHOW_CREATE_TABLE_ACLS) == 0) - { - my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), - "SHOW", thd->security_ctx->priv_user, - thd->security_ctx->host_or_ip, first_table->alias); - goto error; - } - } - - /* Access is granted. Execute the command. */ res= mysqld_show_create(thd, first_table); break; #endif @@ -4637,7 +4588,7 @@ end_with_restore_list: case SQLCOM_DELETE: { WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); - select_result *sel_result=lex->result; + select_result *sel_result= NULL; DBUG_ASSERT(first_table == all_tables && first_table != 0); if (WSREP_CLIENT(thd) && wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) @@ -4668,16 +4619,15 @@ end_with_restore_list: } else { - if (!(sel_result= lex->result) && - !(sel_result= new (thd->mem_root) select_send(thd))) - return 1; + if (!lex->result && !(sel_result= new (thd->mem_root) select_send(thd))) + goto error; } } res = mysql_delete(thd, all_tables, select_lex->where, &select_lex->order_list, unit->select_limit_cnt, select_lex->options, - sel_result); + lex->result ? lex->result : sel_result); if (replaced_protocol) { @@ -6262,7 +6212,6 @@ end_with_restore_list: case SQLCOM_REPAIR: case SQLCOM_TRUNCATE: case SQLCOM_ALTER_TABLE: - thd->query_plan_flags|= QPLAN_ADMIN; DBUG_ASSERT(first_table == all_tables && first_table != 0); /* fall through */ case SQLCOM_SIGNAL: @@ -6506,8 +6455,8 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables) Protocol *save_protocol= NULL; if (lex->analyze_stmt) { - if (result && result->is_result_interceptor()) - ((select_result_interceptor*)result)->disable_my_ok_calls(); + if (result && result->result_interceptor()) + result->result_interceptor()->disable_my_ok_calls(); else { DBUG_ASSERT(thd->protocol); @@ -7062,7 +7011,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table) Check_grant will grant access if there is any column privileges on all of the tables thanks to the fourth parameter (bool show_table). */ - if (check_grant(thd, SELECT_ACL, dst_table, TRUE, UINT_MAX, FALSE)) + if (check_grant(thd, SELECT_ACL, dst_table, TRUE, 1, FALSE)) return TRUE; /* Access denied */ close_thread_tables(thd); @@ -9599,7 +9548,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, goto err; /* If it is a merge table, check privileges for merge children. */ - if (lex->create_info.merge_list.first) + if (lex->create_info.merge_list) { /* The user must have (SELECT_ACL | UPDATE_ACL | DELETE_ACL) on the @@ -9637,8 +9586,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, */ if (check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL, - lex->create_info.merge_list.first, - FALSE, UINT_MAX, FALSE)) + lex->create_info.merge_list, FALSE, UINT_MAX, FALSE)) goto err; } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 272d6615028..f99dc237cd0 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1957,9 +1957,20 @@ static int mysql_test_show_grants(Prepared_statement *stmt) DBUG_ENTER("mysql_test_show_grants"); THD *thd= stmt->thd; List<Item> fields; + char buff[1024]; + const char *username= NULL, *hostname= NULL, *rolename= NULL; - mysql_show_grants_get_fields(thd, &fields, "Grants for"); - + if (get_show_user(thd, thd->lex->grant_user, &username, &hostname, &rolename)) + DBUG_RETURN(1); + + if (username) + strxmov(buff,"Grants for ",username,"@",hostname, NullS); + else if (rolename) + strxmov(buff,"Grants for ",rolename, NullS); + else + DBUG_RETURN(1); + + mysql_show_grants_get_fields(thd, &fields, buff); DBUG_RETURN(send_stmt_metadata(thd, stmt, &fields)); } #endif /*NO_EMBEDDED_ACCESS_CHECKS*/ @@ -1983,7 +1994,7 @@ static int mysql_test_show_slave_status(Prepared_statement *stmt) THD *thd= stmt->thd; List<Item> fields; - show_master_info_get_fields(thd, &fields, 0, 0); + show_master_info_get_fields(thd, &fields, thd->lex->verbose, 0); DBUG_RETURN(send_stmt_metadata(thd, stmt, &fields)); } @@ -2499,6 +2510,7 @@ static bool check_prepared_statement(Prepared_statement *stmt) case SQLCOM_CREATE_INDEX: case SQLCOM_DROP_INDEX: case SQLCOM_ROLLBACK: + case SQLCOM_ROLLBACK_TO_SAVEPOINT: case SQLCOM_TRUNCATE: case SQLCOM_DROP_VIEW: case SQLCOM_REPAIR: @@ -2527,6 +2539,7 @@ static bool check_prepared_statement(Prepared_statement *stmt) case SQLCOM_GRANT: case SQLCOM_GRANT_ROLE: case SQLCOM_REVOKE: + case SQLCOM_REVOKE_ALL: case SQLCOM_REVOKE_ROLE: case SQLCOM_KILL: case SQLCOM_COMPOUND: @@ -2550,8 +2563,26 @@ static bool check_prepared_statement(Prepared_statement *stmt) break; } if (res == 0) - DBUG_RETURN(stmt->is_sql_prepare() ? - FALSE : (send_prep_stmt(stmt, 0) || thd->protocol->flush())); + { + if (!stmt->is_sql_prepare()) + { + if (lex->describe || lex->analyze_stmt) + { + select_send result(thd); + List<Item> field_list; + res= thd->prepare_explain_fields(&result, &field_list, + lex->describe, lex->analyze_stmt) || + send_prep_stmt(stmt, result.field_count(field_list)) || + result.send_result_set_metadata(field_list, + Protocol::SEND_EOF); + } + else + res= send_prep_stmt(stmt, 0); + if (!res) + thd->protocol->flush(); + } + DBUG_RETURN(FALSE); + } error: DBUG_RETURN(TRUE); } diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 55148167b32..81dea4e41b0 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -175,12 +175,6 @@ */ #define OPTION_MASTER_SQL_ERROR (1ULL << 35) -/* - Dont report errors for individual rows, - But just report error on commit (or read ofcourse) - Note! Reserved for use in MySQL Cluster -*/ -#define OPTION_ALLOW_BATCH (1ULL << 36) // THD, intern (slave) #define OPTION_SKIP_REPLICATION (1ULL << 37) // THD, user #define OPTION_RPL_SKIP_PARALLEL (1ULL << 38) #define OPTION_FOUND_COMMENT (1ULL << 39) // SELECT, intern, parser diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 91a6445c870..69aa8a97a87 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3929,7 +3929,7 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list, DBUG_RETURN(1); /* The following should be optimized to only clear critical things */ - bzero(stat, sizeof(JOIN_TAB)* table_count); + bzero((void*)stat, sizeof(JOIN_TAB)* table_count); /* Initialize POSITION objects */ for (i=0 ; i <= table_count ; i++) (void) new ((char*) (join->positions + i)) POSITION; @@ -9028,7 +9028,7 @@ bool JOIN::get_best_combination() 1. Put into main join order a JOIN_TAB that represents a lookup or scan in the temptable. */ - bzero(j, sizeof(JOIN_TAB)); + bzero((void*)j, sizeof(JOIN_TAB)); j->join= this; j->table= NULL; //temporary way to tell SJM tables from others. j->ref.key = -1; diff --git a/sql/sql_select.h b/sql/sql_select.h index a134d601c76..09e8f5a3e10 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -203,7 +203,6 @@ class AGGR_OP; class Filesort; typedef struct st_join_table { - st_join_table() {} TABLE *table; TABLE_LIST *tab_list; KEYUSE *keyuse; /**< pointer to first used key */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e13952cbb6c..ce0e3bc6265 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1206,13 +1206,56 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list, List<Item> *field_list, String *buffer) { bool error= TRUE; + LEX *lex= thd->lex; MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_show_create_get_fields"); DBUG_PRINT("enter",("db: %s table: %s",table_list->db, table_list->table_name)); + if (lex->only_view) + { + if (check_table_access(thd, SELECT_ACL, table_list, FALSE, 1, FALSE)) + { + DBUG_PRINT("debug", ("check_table_access failed")); + my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), + "SHOW", thd->security_ctx->priv_user, + thd->security_ctx->host_or_ip, table_list->alias); + goto exit; + } + DBUG_PRINT("debug", ("check_table_access succeeded")); + + /* Ignore temporary tables if this is "SHOW CREATE VIEW" */ + table_list->open_type= OT_BASE_ONLY; + } + else + { + /* + Temporary tables should be opened for SHOW CREATE TABLE, but not + for SHOW CREATE VIEW. + */ + if (thd->open_temporary_tables(table_list)) + goto exit; + + /* + The fact that check_some_access() returned FALSE does not mean that + access is granted. We need to check if table_list->grant.privilege + contains any table-specific privilege. + */ + DBUG_PRINT("debug", ("table_list->grant.privilege: %lx", + table_list->grant.privilege)); + if (check_some_access(thd, SHOW_CREATE_TABLE_ACLS, table_list) || + (table_list->grant.privilege & SHOW_CREATE_TABLE_ACLS) == 0) + { + my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), + "SHOW", thd->security_ctx->priv_user, + thd->security_ctx->host_or_ip, table_list->alias); + goto exit; + } + } + /* Access is granted. Execute the command. */ + /* We want to preserve the tree for views. */ - thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW; + lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW; { /* @@ -1227,14 +1270,14 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list, bool open_error= open_tables(thd, &table_list, &counter, MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) || - mysql_handle_derived(thd->lex, DT_INIT | DT_PREPARE); + mysql_handle_derived(lex, DT_INIT | DT_PREPARE); thd->pop_internal_handler(); if (open_error && (thd->killed || thd->is_error())) goto exit; } /* TODO: add environment variables show when it become possible */ - if (thd->lex->only_view && !table_list->view) + if (lex->only_view && !table_list->view) { my_error(ER_WRONG_OBJECT, MYF(0), table_list->db, table_list->table_name, "VIEW"); @@ -6338,7 +6381,7 @@ static int get_schema_views_record(THD *thd, TABLE_LIST *tables, { TABLE_LIST table_list; uint view_access; - memset(&table_list, 0, sizeof(table_list)); + table_list.reset(); table_list.db= tables->db; table_list.table_name= tables->table_name; table_list.grant.privilege= thd->col_access; diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 4f1ee2b4c1a..a39e0845a19 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -1794,7 +1794,7 @@ bool Table_triggers_list::drop_all_triggers(THD *thd, char *db, char *name) bool result= 0; DBUG_ENTER("drop_all_triggers"); - bzero(&table, sizeof(table)); + table.reset(); init_sql_alloc(&table.mem_root, 8192, 0, MYF(0)); if (Table_triggers_list::check_n_load(thd, db, name, &table, 1)) @@ -2044,7 +2044,7 @@ bool Table_triggers_list::change_table_name(THD *thd, const char *db, Trigger *err_trigger; DBUG_ENTER("change_table_name"); - bzero(&table, sizeof(table)); + table.reset(); init_sql_alloc(&table.mem_root, 8192, 0, MYF(0)); /* diff --git a/sql/sql_union.cc b/sql/sql_union.cc index abee979ff1c..94b8c662a06 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -843,15 +843,6 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, allocation in setup_ref_array(). */ fake_select_lex->n_child_sum_items+= global_parameters()->n_sum_items; - - saved_error= fake_select_lex->join-> - prepare(fake_select_lex->table_list.first, - 0, 0, - global_parameters()->order_list.elements, // og_num - global_parameters()->order_list.first, // order - false, NULL, NULL, NULL, - fake_select_lex, this); - fake_select_lex->table_list.empty(); } } else @@ -862,6 +853,24 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, */ table->reset_item_list(&item_list); } + if (fake_select_lex != NULL && + (thd->stmt_arena->is_stmt_prepare() || + (thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW))) + { + if (!fake_select_lex->join && + !(fake_select_lex->join= + new JOIN(thd, item_list, thd->variables.option_bits, result))) + { + fake_select_lex->table_list.empty(); + DBUG_RETURN(TRUE); + } + saved_error= fake_select_lex->join-> + prepare(fake_select_lex->table_list.first, 0, 0, + global_parameters()->order_list.elements, // og_num + global_parameters()->order_list.first, // order + false, NULL, NULL, NULL, fake_select_lex, this); + fake_select_lex->table_list.empty(); + } } thd_arg->lex->current_select= lex_select_save; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 91b811fbb93..0cff47437c8 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -215,7 +215,8 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view) LEX *lex= thd->lex; TABLE_LIST decoy; - memcpy (&decoy, view, sizeof (TABLE_LIST)); + decoy= *view; + decoy.mdl_request.key.mdl_key_init(&view->mdl_request.key); if (tdc_open_view(thd, &decoy, OPEN_VIEW_NO_PARSE)) return TRUE; @@ -331,12 +332,11 @@ bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view, { if (!tbl->table_in_first_from_clause) { - if (check_access(thd, SELECT_ACL, tbl->db, - &tbl->grant.privilege, - &tbl->grant.m_internal, - 0, 0) || - check_grant(thd, SELECT_ACL, tbl, FALSE, 1, FALSE)) + if (check_single_table_access(thd, SELECT_ACL, tbl, FALSE)) + { + tbl->hide_view_error(thd); goto err; + } } } } @@ -900,15 +900,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, View definition query is stored in the client character set. */ - char view_query_buff[4096]; - String view_query(view_query_buff, - sizeof (view_query_buff), - thd->charset()); - - char is_query_buff[4096]; - String is_query(is_query_buff, - sizeof (is_query_buff), - system_charset_info); + StringBuffer<4096> view_query(thd->charset()); + StringBuffer<4096> is_query(system_charset_info); char md5[MD5_BUFF_LENGTH]; bool can_be_merged; @@ -2155,7 +2148,7 @@ mysql_rename_view(THD *thd, view definition parsing or use temporary 'view_def' object for it. */ - bzero(&view_def, sizeof(view_def)); + view_def.reset(); view_def.timestamp.str= view_def.timestamp_buffer; view_def.view_suid= TRUE; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 133aad53fb1..5b8c3c6c7ec 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5825,7 +5825,7 @@ create_table_option: from the global list. */ LEX *lex=Lex; - lex->create_info.merge_list= lex->select_lex.table_list; + lex->create_info.merge_list= lex->select_lex.table_list.first; lex->select_lex.table_list= lex->save_list; /* When excluding union list from the global list we assume that @@ -5834,7 +5834,7 @@ create_table_option: */ TABLE_LIST *last_non_sel_table= lex->create_last_non_select_table; DBUG_ASSERT(last_non_sel_table->next_global == - lex->create_info.merge_list.first); + lex->create_info.merge_list); last_non_sel_table->next_global= 0; Lex->query_tables_last= &last_non_sel_table->next_global; @@ -13573,6 +13573,7 @@ load: LOAD data_or_xml { LEX *lex= thd->lex; + mysql_init_select(lex); if (lex->sphead) { diff --git a/sql/table.h b/sql/table.h index c3c138c1278..c3ce5b8af51 100644 --- a/sql/table.h +++ b/sql/table.h @@ -762,6 +762,8 @@ struct TABLE_SHARE /** Instrumentation for this table share. */ PSI_table_share *m_psi; + inline void reset() { bzero((void*)this, sizeof(*this)); } + /* Set share's table cache key and update its db and table name appropriately. @@ -1309,6 +1311,7 @@ public: bool histograms_are_read; MDL_ticket *mdl_ticket; + inline void reset() { bzero((void*)this, sizeof(*this)); } void init(THD *thd, TABLE_LIST *tl); bool fill_item_list(List<Item> *item_list) const; void reset_item_list(List<Item> *item_list) const; @@ -1751,6 +1754,7 @@ struct TABLE_LIST Prepare TABLE_LIST that consists of one table instance to use in open_and_lock_tables */ + inline void reset() { bzero((void*)this, sizeof(*this)); } inline void init_one_table(const char *db_name_arg, size_t db_length_arg, const char *table_name_arg, @@ -1766,9 +1770,9 @@ struct TABLE_LIST else mdl_type= MDL_SHARED_READ; - bzero((char*) this, sizeof(*this)); DBUG_ASSERT(!db_name_arg || strlen(db_name_arg) == db_length_arg); DBUG_ASSERT(!table_name_arg || strlen(table_name_arg) == table_name_length_arg); + reset(); db= (char*) db_name_arg; db_length= db_length_arg; table_name= (char*) table_name_arg; @@ -2272,8 +2276,7 @@ struct TABLE_LIST @sa check_and_update_table_version() */ - inline - bool is_table_ref_id_equal(TABLE_SHARE *s) const + inline bool is_table_ref_id_equal(TABLE_SHARE *s) const { return (m_table_ref_type == s->get_table_ref_type() && m_table_ref_version == s->get_table_ref_version()); @@ -2285,12 +2288,10 @@ struct TABLE_LIST @sa check_and_update_table_version() */ - inline - void set_table_ref_id(TABLE_SHARE *s) + inline void set_table_ref_id(TABLE_SHARE *s) { set_table_ref_id(s->get_table_ref_type(), s->get_table_ref_version()); } - inline - void set_table_ref_id(enum_table_ref_type table_ref_type_arg, + inline void set_table_ref_id(enum_table_ref_type table_ref_type_arg, ulong table_ref_version_arg) { m_table_ref_type= table_ref_type_arg; diff --git a/sql/tztime.cc b/sql/tztime.cc index 82160231b03..1167ea18e7e 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1537,16 +1537,11 @@ my_offset_tzs_get_key(Time_zone_offset *entry, static void tz_init_table_list(TABLE_LIST *tz_tabs) { - bzero(tz_tabs, sizeof(TABLE_LIST) * MY_TZ_TABLES_COUNT); - for (int i= 0; i < MY_TZ_TABLES_COUNT; i++) { - tz_tabs[i].alias= tz_tabs[i].table_name= tz_tables_names[i].str; - tz_tabs[i].table_name_length= tz_tables_names[i].length; - tz_tabs[i].db= tz_tables_db_name.str; - tz_tabs[i].db_length= tz_tables_db_name.length; - tz_tabs[i].lock_type= TL_READ; - + tz_tabs[i].init_one_table(tz_tables_db_name.str, tz_tables_db_name.length, + tz_tables_names[i].str, tz_tables_names[i].length, + NULL, TL_READ); if (i != MY_TZ_TABLES_COUNT - 1) tz_tabs[i].next_global= tz_tabs[i].next_local= &tz_tabs[i+1]; if (i != 0) diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 6c963003e05..ca806106a22 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1541,7 +1541,7 @@ trx_purge_attach_undo_recs( i = 0; - for (;;) { + while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) { purge_node_t* node; trx_purge_rec_t* purge_rec; diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index 47d2a5d7f9d..702ec92867f 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -1676,14 +1676,15 @@ static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2) } -static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) +static void keys_free(void* key_arg, TREE_FREE mode, void *param_arg) { /* Probably I can use info->lastkey here, but I'm not sure, and to be safe I'd better use local lastkey. */ + bulk_insert_param *param= (bulk_insert_param*)param_arg; MARIA_SHARE *share= param->info->s; - uchar lastkey[MARIA_MAX_KEY_BUFF]; + uchar lastkey[MARIA_MAX_KEY_BUFF], *key= (uchar*)key_arg; uint keylen; MARIA_KEYDEF *keyinfo= share->keyinfo + param->keynr; MARIA_KEY tmp_key; @@ -1695,7 +1696,7 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) mysql_rwlock_wrlock(&keyinfo->root_lock); keyinfo->version++; } - return 0; + return; case free_free: /* Note: keylen doesn't contain transid lengths */ keylen= _ma_keylength(keyinfo, key); @@ -1710,13 +1711,14 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) copying middle key up if tree is growing */ memcpy(lastkey, key, tmp_key.data_length + tmp_key.ref_length); - return _ma_ck_write_btree(param->info, &tmp_key); + _ma_ck_write_btree(param->info, &tmp_key); + return; case free_end: if (share->lock_key_trees) mysql_rwlock_unlock(&keyinfo->root_lock); - return 0; + return; } - return 1; + return; } @@ -1772,8 +1774,7 @@ int maria_init_bulk_insert(MARIA_HA *info, size_t cache_size, ha_rows rows) init_tree(&info->bulk_insert[i], cache_size * key[i].maxlength, cache_size * key[i].maxlength, 0, - (qsort_cmp2)keys_compare, - (tree_element_free) keys_free, (void *)params++, MYF(0)); + (qsort_cmp2) keys_compare, keys_free, (void *)params++, MYF(0)); } else info->bulk_insert[i].root=0; diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 289ad4fa6c4..46077a2671e 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -2992,9 +2992,9 @@ int ha_mroonga::create_share_for_create() const TABLE_LIST *table_list = MRN_LEX_GET_TABLE_LIST(lex); MRN_DBUG_ENTER_METHOD(); wrap_handler_for_create = NULL; - memset(&table_for_create, 0, sizeof(TABLE)); + table_for_create.reset(); + table_share_for_create.reset(); memset(&share_for_create, 0, sizeof(MRN_SHARE)); - memset(&table_share_for_create, 0, sizeof(TABLE_SHARE)); if (table_share) { table_share_for_create.comment = table_share->comment; table_share_for_create.connect_string = table_share->connect_string; @@ -14555,8 +14555,8 @@ enum_alter_inplace_result ha_mroonga::wrapper_check_if_supported_inplace_alter( ) { DBUG_RETURN(HA_ALTER_ERROR); } - memcpy(wrap_altered_table, altered_table, sizeof(TABLE)); - memcpy(wrap_altered_table_share, altered_table->s, sizeof(TABLE_SHARE)); + *wrap_altered_table= *altered_table; + *wrap_altered_table_share= *altered_table->s; mrn_init_sql_alloc(ha_thd(), &(wrap_altered_table_share->mem_root)); n_keys = ha_alter_info->index_drop_count; diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 3ba25d84e62..edcb7623217 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -929,13 +929,14 @@ static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2) } -static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) +static void keys_free(void* key_arg, TREE_FREE mode, void *param_arg) { /* Probably I can use info->lastkey here, but I'm not sure, and to be safe I'd better use local lastkey. */ - uchar lastkey[HA_MAX_KEY_BUFF]; + bulk_insert_param *param= (bulk_insert_param*)param_arg; + uchar lastkey[HA_MAX_KEY_BUFF], *key= (uchar*)key_arg; uint keylen; MI_KEYDEF *keyinfo; @@ -946,19 +947,20 @@ static int keys_free(uchar *key, TREE_FREE mode, bulk_insert_param *param) mysql_rwlock_wrlock(¶m->info->s->key_root_lock[param->keynr]); param->info->s->keyinfo[param->keynr].version++; } - return 0; + return; case free_free: keyinfo=param->info->s->keyinfo+param->keynr; keylen=_mi_keylength(keyinfo, key); memcpy(lastkey, key, keylen); - return _mi_ck_write_btree(param->info,param->keynr,lastkey, - keylen - param->info->s->rec_reflength); + _mi_ck_write_btree(param->info, param->keynr, lastkey, + keylen - param->info->s->rec_reflength); + return; case free_end: if (param->info->s->concurrent_insert) mysql_rwlock_unlock(¶m->info->s->key_root_lock[param->keynr]); - return 0; + return; } - return -1; + return; } @@ -1014,8 +1016,7 @@ int mi_init_bulk_insert(MI_INFO *info, size_t cache_size, ha_rows rows) init_tree(&info->bulk_insert[i], cache_size * key[i].maxlength, cache_size * key[i].maxlength, 0, - (qsort_cmp2)keys_compare, - (tree_element_free) keys_free, (void *)params++, MYF(0)); + (qsort_cmp2)keys_compare, keys_free, (void *)params++, MYF(0)); } else info->bulk_insert[i].root=0; diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index 7ce03ca9485..f059d6f4c70 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -63,7 +63,7 @@ static int test_if_open(struct file_info *key,element_count count, static void fix_blob_pointers(MI_INFO *isam,uchar *record); static int test_when_accessed(struct file_info *key,element_count count, struct st_access_param *access_param); -static void file_info_free(struct file_info *info); +static void file_info_free(void*, TREE_FREE, void *); static int close_some_file(TREE *tree); static int reopen_closed_file(TREE *tree,struct file_info *file_info); static int find_record_with_key(struct file_info *file_info,uchar *record); @@ -330,8 +330,7 @@ static int examine_log(char * file_name, char **table_names) init_io_cache(&cache,file,0,READ_CACHE,start_offset,0,MYF(0)); bzero((uchar*) com_count,sizeof(com_count)); init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare, - (tree_element_free) file_info_free, NULL, - MYF(MY_TREE_WITH_DELETE)); + file_info_free, NULL, MYF(MY_TREE_WITH_DELETE)); (void) init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, 0, 0, 0, 0); @@ -751,8 +750,9 @@ static int test_when_accessed (struct file_info *key, } -static void file_info_free(struct file_info *fileinfo) +static void file_info_free(void* arg, TREE_FREE mode, void *unused) { + struct file_info *fileinfo= arg; DBUG_ENTER("file_info_free"); if (update) { diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index cd2ba4c763f..74e741f9b9f 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -1466,49 +1466,41 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info) if (!(create_info->used_fields & HA_CREATE_USED_UNION)) { - TABLE_LIST *child_table; - THD *thd=current_thd; - - create_info->merge_list.next= &create_info->merge_list.first; - create_info->merge_list.elements=0; + TABLE_LIST *child_table, *end= NULL; + THD *thd=ha_thd(); if (children_l != NULL) { - for (child_table= children_l;; - child_table= child_table->next_global) + for (child_table= children_l;; child_table= child_table->next_global) { TABLE_LIST *ptr; if (!(ptr= (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST)))) - goto err; + DBUG_VOID_RETURN; if (!(ptr->table_name= thd->strmake(child_table->table_name, child_table->table_name_length))) - goto err; - if (child_table->db && !(ptr->db= thd->strmake(child_table->db, - child_table->db_length))) - goto err; + DBUG_VOID_RETURN; + if (child_table->db && + !(ptr->db= thd->strmake(child_table->db, child_table->db_length))) + DBUG_VOID_RETURN; - create_info->merge_list.elements++; - (*create_info->merge_list.next)= ptr; - create_info->merge_list.next= &ptr->next_local; + if (create_info->merge_list) + end->next_local= ptr; + else + create_info->merge_list= ptr; + end= ptr; if (&child_table->next_global == children_last_l) break; } } - *create_info->merge_list.next=0; } if (!(create_info->used_fields & HA_CREATE_USED_INSERT_METHOD)) { create_info->merge_insert_method = file->merge_insert_method; } DBUG_VOID_RETURN; - -err: - create_info->merge_list.elements=0; - create_info->merge_list.first=0; - DBUG_VOID_RETURN; } @@ -1516,18 +1508,21 @@ int ha_myisammrg::create_mrg(const char *name, HA_CREATE_INFO *create_info) { char buff[FN_REFLEN]; const char **table_names, **pos; - TABLE_LIST *tables= create_info->merge_list.first; - THD *thd= current_thd; + TABLE_LIST *tables= create_info->merge_list; + THD *thd= ha_thd(); size_t dirlgt= dirname_length(name); + uint ntables= 0; DBUG_ENTER("ha_myisammrg::create_mrg"); + for (tables= create_info->merge_list; tables; tables= tables->next_local) + ntables++; + /* Allocate a table_names array in thread mem_root. */ - if (!(table_names= (const char**) - thd->alloc((create_info->merge_list.elements+1) * sizeof(char*)))) + if (!(pos= table_names= (const char**) thd->alloc((ntables + 1) * sizeof(char*)))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* purecov: inspected */ /* Create child path names. */ - for (pos= table_names; tables; tables= tables->next_local) + for (tables= create_info->merge_list; tables; tables= tables->next_local) { const char *table_name= buff; diff --git a/storage/sequence/sequence.cc b/storage/sequence/sequence.cc index 599374c6f8c..9585f4f5312 100644 --- a/storage/sequence/sequence.cc +++ b/storage/sequence/sequence.cc @@ -348,7 +348,9 @@ static int discover_table_existence(handlerton *hton, const char *db, return !parse_table_name(table_name, strlen(table_name), &from, &to, &step); } -static int dummy_ret_int() { return 0; } +static int dummy_commit_rollback(handlerton *, THD *, bool) { return 0; } + +static int dummy_savepoint(handlerton *, THD *, void *) { return 0; } /***************************************************************************** Example of a simple group by handler for queries like: @@ -487,10 +489,9 @@ static int init(void *p) hton->create= create_handler; hton->discover_table= discover_table; hton->discover_table_existence= discover_table_existence; - hton->commit= hton->rollback= - (int (*)(handlerton *, THD *, bool)) &dummy_ret_int; + hton->commit= hton->rollback= dummy_commit_rollback; hton->savepoint_set= hton->savepoint_rollback= hton->savepoint_release= - (int (*)(handlerton *, THD *, void *)) &dummy_ret_int; + dummy_savepoint; hton->create_group_by= create_group_by_handler; return 0; } diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index c45f88707a5..d132557c47d 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -95,6 +95,8 @@ IF(HAVE_SCHED_GETCPU) ADD_DEFINITIONS(-DHAVE_SCHED_GETCPU) ENDIF() +MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-class-memaccess") + IF(NOT MSVC) CHECK_FUNCTION_EXISTS(posix_memalign HAVE_POSIX_MEMALIGN) diff --git a/storage/xtradb/trx/trx0purge.cc b/storage/xtradb/trx/trx0purge.cc index 11522ea5f9c..a9736e36075 100644 --- a/storage/xtradb/trx/trx0purge.cc +++ b/storage/xtradb/trx/trx0purge.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -989,7 +989,7 @@ trx_purge_attach_undo_recs( i = 0; - for (;;) { + while (UNIV_LIKELY(srv_undo_sources) || !srv_fast_shutdown) { purge_node_t* node; trx_purge_rec_t* purge_rec; diff --git a/unittest/sql/mf_iocache-t.cc b/unittest/sql/mf_iocache-t.cc index 9e7ab23933d..287f1cb837a 100644 --- a/unittest/sql/mf_iocache-t.cc +++ b/unittest/sql/mf_iocache-t.cc @@ -49,6 +49,12 @@ uint encryption_key_get_func(uint, uint, uchar* key, uint* size) return 0; } +uint encryption_ctx_size_func(unsigned int, unsigned int) +{ + return MY_AES_CTX_SIZE; +} + + #ifdef HAVE_EncryptAes128Gcm enum my_aes_mode aes_mode= MY_AES_GCM; #else @@ -72,7 +78,7 @@ struct encryption_service_st encryption_handler= { encryption_key_get_latest_version_func, encryption_key_get_func, - (uint (*)(unsigned int, unsigned int))my_aes_ctx_size, + encryption_ctx_size_func, encryption_ctx_init_func, my_aes_crypt_update, my_aes_crypt_finish, |