mariadb/mysql-test/main/slowlog_integrity.test
Oleksandr Byelkin 47f87c5f88 MDEV-20281 "[ERROR] Failed to write to mysql.slow_log:" without error reason
Add "backup" (in case of absence issued by error) reasons for failed logging.
2025-01-25 20:37:51 +01:00

113 lines
3.8 KiB
Text

source include/not_embedded.inc;
--echo #
--echo # MDEV-20281 "[ERROR] Failed to write to mysql.slow_log:" without
--echo # error reason
--echo #
call mtr.add_suppression("Failed to write to mysql.slow_log:");
--disable_ps_protocol
SET @old_slow_query_log= @@global.slow_query_log;
SET @old_log_output= @@global.log_output;
SET @old_long_query_time= @@long_query_time;
SET GLOBAL log_output= "TABLE";
SET GLOBAL slow_query_log= ON;
SET SESSION long_query_time= 0;
select 1 from dual;
show create table mysql.slow_log;
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= "FILE";
SET GLOBAL slow_query_log= OFF;
drop table mysql.slow_log;
--echo # one field missing
CREATE TABLE mysql.slow_log (
`start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='Slow log';
SET GLOBAL log_output= "TABLE";
SET GLOBAL slow_query_log= ON;
SET SESSION long_query_time= 0;
select 1 from dual;
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= "FILE";
SET GLOBAL slow_query_log= OFF;
drop table mysql.slow_log;
--echo # crazy types
CREATE TABLE mysql.slow_log (
`start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` ENUM('apple','orange','pear') NOT NULL,
`query_time` ENUM('apple','orange','pear') NOT NULL,
`lock_time` ENUM('apple','orange','pear') NOT NULL,
`rows_sent` ENUM('apple','orange','pear') NOT NULL,
`rows_examined` ENUM('apple','orange','pear') NOT NULL,
`db` ENUM('apple','orange','pear') NOT NULL,
`last_insert_id` ENUM('apple','orange','pear') NOT NULL,
`insert_id` ENUM('apple','orange','pear') NOT NULL,
`server_id` ENUM('apple','orange','pear') NOT NULL,
`sql_text` ENUM('apple','orange','pear') NOT NULL,
`thread_id` ENUM('apple','orange','pear') NOT NULL,
`rows_affected` ENUM('apple','orange','pear') NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='Slow log';
SET GLOBAL log_output= "TABLE";
SET GLOBAL slow_query_log= ON;
SET SESSION long_query_time= 0;
select 1 from dual;
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= "FILE";
SET GLOBAL slow_query_log= OFF;
drop table mysql.slow_log;
--echo # restore normal slow log table
CREATE TABLE mysql.slow_log (
`start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6),
`user_host` mediumtext NOT NULL,
`query_time` time(6) NOT NULL,
`lock_time` time(6) NOT NULL,
`rows_sent` bigint(20) unsigned NOT NULL,
`rows_examined` bigint(20) unsigned NOT NULL,
`db` varchar(512) NOT NULL,
`last_insert_id` int(11) NOT NULL,
`insert_id` int(11) NOT NULL,
`server_id` int(10) unsigned NOT NULL,
`sql_text` mediumtext NOT NULL,
`thread_id` bigint(21) unsigned NOT NULL,
`rows_affected` bigint(20) unsigned NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci COMMENT='Slow log';
SET @@long_query_time= @old_long_query_time;
SET @@global.log_output= @old_log_output;
SET @@global.slow_query_log= @old_slow_query_log;
--enable_ps_protocol
--let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err
--let SEARCH_PATTERN=incorrect number of fields in the log table
--source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=Can't write data \(possible incorrect log table structure\)
--source include/search_pattern_in_file.inc
--echo # End of 10.5 tests