1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-09 22:24:09 +03:00

MDEV-29827 collateral cleanup

* removed universal suppression of everything "Event Schedule" everywhere
* added suppressions in tests as needed
* moved events test to the events suite
* renamed -master.opt -> .opt
* added standard test header
* verified in the test that the error, indeed, was written into the log
* removed useless suppressions
* removed ER_EVENTS_NO_ACL, replaced with ER_OPTION_PREVENTS_STATEMENT
* fixed error message to say exactly what option disabled event scheduler
  instead of "this or that or that, you figure it out"
* also fixed old message for SET event_scheduler=
  (it was also non-translatable)
* changed to use sql_print_error() when an error is not sent to the user
* removed duplicate hard-coded error message
This commit is contained in:
Sergei Golubchik
2023-07-02 00:51:56 +02:00
parent d6c6102cad
commit 279b0db8c6
24 changed files with 69 additions and 59 deletions

View File

@@ -93,7 +93,6 @@ INSERT INTO global_suppressions VALUES
("Enabling keys got errno"),
("Error reading master configuration"),
("Error reading packet"),
("Event Scheduler"),
("Failed to open log"),
("Failed to open the existing master info file"),
("Forcing shutdown of [0-9]* plugins"),

View File

@@ -1,3 +1,4 @@
call mtr.add_suppression('Event Scheduler: .* Duplicate entry');
SET GLOBAL event_scheduler=1;
CREATE TABLE t1 (a int primary key, b int) engine=innodb;
insert into t1 values (1,1),(2,2),(3,3);

View File

@@ -2,6 +2,7 @@
--source include/have_innodb.inc
#--source include/have_metadata_lock_info.inc
call mtr.add_suppression('Event Scheduler: .* Duplicate entry');
#
# Testing of problems with ALTER TABLE and events on the same table(s)
#

View File

@@ -1,8 +0,0 @@
call mtr.add_suppression("Event Scheduler will not function when starting with --skip-grant-tables or --bootstrap.");
CREATE EVENT test ON SCHEDULE AT CURRENT_TIMESTAMP DO DO NULL;
ERROR HY000: Event scheduler cannot function with --skip-grant-tables, --bootstrap, or embedded build
select (@@global.event_scheduler='DISABLED') as expect_1;
expect_1
1
set global event_scheduler=1;
ERROR HY000: The MariaDB server is running with the --event-scheduler=DISABLED or --skip-grant-tables option so it cannot execute this statement

View File

@@ -1,3 +1,6 @@
#
# MDEV-6984 Can't migrate from MySQL 5.6.21 to MariaDB 10
#
update mysql.global_priv set priv=json_set(priv, '$.plugin', 'mysql_native_password', '$.authentication_string', password('foo')) where user='root';
Phase 1/8: Checking and upgrading mysql database
Processing databases

View File

@@ -1,9 +1,9 @@
#
# MDEV-6984 Can't migrate from MySQL 5.6.21 to MariaDB 10
#
--source include/not_embedded.inc
--source include/have_perfschema.inc
--echo #
--echo # MDEV-6984 Can't migrate from MySQL 5.6.21 to MariaDB 10
--echo #
#
# When 'root' account is password protected and MYSQL_UPGRADE doesn't
# know the password (meaning, MYSQL_UPGRADE is run automatically

View File

@@ -1,4 +1,3 @@
call mtr.add_suppression("Event Scheduler will not function when starting with --skip-grant-tables or --bootstrap.");
use test;
CREATE TABLE t1(c INT);
CREATE TRIGGER t1_bi BEFORE INSERT ON t1
@@ -53,7 +52,7 @@ DROP FUNCTION f3;
# Bug #26807 "set global event_scheduler=1" and --skip-grant-tables crashes server
#
set global event_scheduler=1;
ERROR HY000: The MariaDB server is running with the --event-scheduler=DISABLED or --skip-grant-tables option so it cannot execute this statement
ERROR HY000: The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement
#
# Bug#26285 Selecting information_schema crahes server
#

View File

@@ -1,6 +1,5 @@
# This tests not performed with embedded server
-- source include/not_embedded.inc
call mtr.add_suppression("Event Scheduler will not function when starting with --skip-grant-tables or --bootstrap.");
-- disable_ps_protocol
use test;

View File

@@ -1,6 +1,7 @@
set sql_mode="";
call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
call mtr.add_suppression("Incorrect definition of table mysql.event:.*");
call mtr.add_suppression("Event Scheduler: .* DROP command denied to user");
drop database if exists events_test;
drop database if exists db_x;
drop database if exists mysqltest_db2;

View File

@@ -9,6 +9,7 @@ set sql_mode="";
call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
call mtr.add_suppression("Incorrect definition of table mysql.event:.*");
call mtr.add_suppression("Event Scheduler: .* DROP command denied to user");
--disable_warnings
drop database if exists events_test;

View File

@@ -1,3 +1,4 @@
call mtr.add_suppression('Event Scheduler:');
SET SQL_MODE="";
drop database if exists events_test;
drop database if exists mysqltest_db1;

View File

@@ -1,7 +1,7 @@
# Tests will be skipped for the view protocol because the view protocol creates
# an additional util connection and other statistics data
-- source include/no_view_protocol.inc
call mtr.add_suppression('Event Scheduler:');
#### t/events_bugs.test
#
# Last change:

View File

@@ -1,6 +1,6 @@
call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
call mtr.add_suppression('Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted');
call mtr.add_suppression('Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler');
set global event_scheduler=off;
drop database if exists events_test;
create database events_test;
use events_test;
create table execution_log(name char(10));
@@ -20,7 +20,7 @@ create table event_like like mysql.event;
insert into event_like select * from mysql.event;
alter table mysql.event
change column body body longtext character set utf8 collate utf8_bin;
"Now we restart the server"
# Now we restart the server
call mtr.add_suppression("Incorrect definition of table mysql.event:.*");
# restart
use events_test;
@@ -54,8 +54,8 @@ ERROR HY000: Event Scheduler: An error occurred when initializing system tables.
show variables like 'event_scheduler';
Variable_name Value
event_scheduler OFF
Make sure that we still can create and drop databases,
and no warnings are produced.
# Make sure that we still can create and drop databases,
# and no warnings are produced.
drop database if exists mysqltest_database_not_exists;
Warnings:
Note 1008 Can't drop database 'mysqltest_database_not_exists'; database doesn't exist
@@ -63,10 +63,10 @@ create database mysqltest_db1;
drop database mysqltest_db1;
Warnings:
Error 1545 Failed to open mysql.event
Restore the original mysql.event table
# Restore the original mysql.event table
drop table mysql.event;
rename table event_like to mysql.event;
check that we can now enable events without restart
# check that we can now enable events without restart
set global event_scheduler=original;
Warnings:
Note 1408 Event Scheduler: Loaded 3 events
@@ -82,7 +82,7 @@ Db Name Definer Time zone Type Execute at Interval value Interval field Starts E
events_test abc1 root@localhost SYSTEM RECURRING # 1 SECOND # # ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
events_test abc2 root@localhost SYSTEM RECURRING # 1 SECOND # # ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
events_test abc3 root@localhost SYSTEM RECURRING # 1 SECOND # # ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
Now let's restart the server again
# Now let's restart the server again
# restart
use events_test;
select @@event_scheduler;
@@ -103,7 +103,7 @@ CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DISABLE DO SELECT 1;
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation
test e1 root@localhost SYSTEM RECURRING # 1 SECOND # # DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci
"Now we restart the server"
# Now we restart the server
# restart
USE test;
SELECT @@event_scheduler;

View File

@@ -1,6 +1,7 @@
# Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc
call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted");
call mtr.add_suppression('Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted');
call mtr.add_suppression('Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler');
let $collation_server=`select @@collation_server`;
#
@@ -11,9 +12,6 @@ let $collation_server=`select @@collation_server`;
# Switch off the scheduler for now.
set global event_scheduler=off;
--disable_warnings
drop database if exists events_test;
--enable_warnings
create database events_test;
use events_test;
create table execution_log(name char(10));
@@ -43,7 +41,7 @@ insert into event_like select * from mysql.event;
# Now let's alter the table and restart the server
alter table mysql.event
change column body body longtext character set utf8 collate utf8_bin;
--echo "Now we restart the server"
--echo # Now we restart the server
call mtr.add_suppression("Incorrect definition of table mysql.event:.*");
--source include/restart_mysqld.inc
@@ -77,16 +75,16 @@ set global event_scheduler=on;
--error ER_STARTUP
set global event_scheduler=off;
show variables like 'event_scheduler';
--echo Make sure that we still can create and drop databases,
--echo and no warnings are produced.
--echo # Make sure that we still can create and drop databases,
--echo # and no warnings are produced.
drop database if exists mysqltest_database_not_exists;
create database mysqltest_db1;
drop database mysqltest_db1;
--echo Restore the original mysql.event table
--echo # Restore the original mysql.event table
drop table mysql.event;
rename table event_like to mysql.event;
--echo check that we can now enable events without restart
--echo # check that we can now enable events without restart
set global event_scheduler=original;
select @@global.event_scheduler;
set global event_scheduler=on;
@@ -96,7 +94,7 @@ select @@global.event_scheduler;
--replace_result $collation_server latin1_swedish_ci
show events;
--echo Now let's restart the server again
--echo # Now let's restart the server again
--source include/restart_mysqld.inc
@@ -132,7 +130,7 @@ CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DISABLE DO SELECT 1;
--replace_column 6 # 9 # 10 #
SHOW EVENTS;
--echo "Now we restart the server"
--echo # Now we restart the server
--source include/restart_mysqld.inc
USE test;
SELECT @@event_scheduler;

View File

@@ -1,3 +1,4 @@
call mtr.add_suppression("Event Scheduler: .* Table 'events_test.t1' doesn't exist");
CREATE DATABASE IF NOT EXISTS events_test;
USE events_test;
SET @event_scheduler=@@global.event_scheduler;

View File

@@ -1,6 +1,8 @@
# Can't test with embedded server that doesn't support events
-- source include/not_embedded.inc
call mtr.add_suppression("Event Scheduler: .* Table 'events_test.t1' doesn't exist");
CREATE DATABASE IF NOT EXISTS events_test;
USE events_test;

View File

@@ -0,0 +1,12 @@
call mtr.add_suppression("Event Scheduler will not function when starting with --skip-grant-tables");
#
# MDEV-29827 Misleading error messages about event scheduler when using --skip-grant-tables
#
FOUND 1 /Event Scheduler will not function when starting with --skip-grant-tables/ in mysqld.1.err
CREATE EVENT test ON SCHEDULE AT CURRENT_TIMESTAMP DO DO NULL;
ERROR HY000: The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement
select (@@global.event_scheduler='DISABLED') as expect_1;
expect_1
1
set global event_scheduler=1;
ERROR HY000: The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement

View File

@@ -1,12 +1,20 @@
# Can't test with embedded server that doesn't support grants
-- source include/not_embedded.inc
call mtr.add_suppression("Event Scheduler will not function when starting with --skip-grant-tables or --bootstrap.");
call mtr.add_suppression("Event Scheduler will not function when starting with --skip-grant-tables");
# [MARIADB-29827] Verify that if server is started with
--echo #
--echo # MDEV-29827 Misleading error messages about event scheduler when using --skip-grant-tables
--echo #
# Verify that if server is started with
# --event-scheduler=ON --skip-grant-tables, we get an error
# with a distinct explanation that the latter disables the former.
--error ER_EVENTS_NO_ACL
let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_PATTERN=Event Scheduler will not function when starting with --skip-grant-tables;
source include/search_pattern_in_file.inc;
--error ER_OPTION_PREVENTS_STATEMENT
CREATE EVENT test ON SCHEDULE AT CURRENT_TIMESTAMP DO DO NULL;
# Although --event-scheduler=ON was specified (see -master.opt), it should

View File

@@ -1,3 +1,4 @@
call mtr.add_suppression('Event Scheduler:');
create database mysqltest1;
use mysqltest1;
create table t1 (a int, b int, c int);

View File

@@ -7,6 +7,8 @@
--source include/not_embedded.inc
--source include/default_charset.inc
call mtr.add_suppression('Event Scheduler:');
let MYSQLD_DATADIR=`select @@datadir`;
create database mysqltest1;

View File

@@ -121,7 +121,8 @@ bool Events::check_if_system_tables_error()
if (opt_noacl)
{
my_error(ER_EVENTS_NO_ACL, MYF(0));
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0),
opt_bootstrap ? "--bootstrap" : "--skip-grant-tables");
DBUG_RETURN(TRUE);
}
else if (!inited)
@@ -404,13 +405,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
char buffer[1024];
String log_query(buffer, sizeof(buffer), &my_charset_bin);
if (create_query_string(thd, &log_query))
{
my_message_sql(ER_STARTUP,
"Event Error: An error occurred while creating query "
"string, before writing it into binary log.",
MYF(ME_ERROR_LOG));
ret= true;
}
ret= true; // EE_OUTOFMEMORY set by my_malloc()
else
{
/*
@@ -895,10 +890,9 @@ Events::init(THD *thd, bool opt_noacl_or_bootstrap)
DBUG_RETURN(FALSE);
else if (opt_noacl_or_bootstrap)
{
my_message(ER_STARTUP,
"Event Scheduler will not function when starting "
"with --skip-grant-tables or --bootstrap.",
MYF(ME_ERROR_LOG));
if (opt_event_scheduler == Events::EVENTS_ON)
sql_print_error("Event Scheduler will not function when starting with %s",
opt_bootstrap ? "--bootstrap" : "--skip-grant-tables");
opt_event_scheduler= EVENTS_DISABLED;
DBUG_RETURN(FALSE);
}
@@ -944,7 +938,7 @@ Events::init(THD *thd, bool opt_noacl_or_bootstrap)
}
/*
Since we allow event DDL even if the scheduler is disabled,
Since we allow event DDL even if the scheduler is off,
check the system tables, as we might need them.
If run with --skip-grant-tables or --bootstrap, we have already
@@ -963,7 +957,6 @@ Events::init(THD *thd, bool opt_noacl_or_bootstrap)
goto end;
}
DBUG_ASSERT(opt_event_scheduler == Events::EVENTS_ON ||
opt_event_scheduler == Events::EVENTS_OFF);
@@ -1305,9 +1298,7 @@ Events::load_events_from_db(THD *thd)
}
my_printf_error(ER_STARTUP,
"Event Scheduler: Loaded %d event%s",
MYF(ME_ERROR_LOG |
(global_system_variables.log_warnings) ?
ME_NOTE: 0),
MYF(ME_ERROR_LOG | ME_NOTE),
count, (count == 1) ? "" : "s");
ret= FALSE;

View File

@@ -10784,5 +10784,3 @@ ER_JSON_INVALID_VALUE_FOR_KEYWORD
eng "Invalid value for keyword %s"
ER_JSON_SCHEMA_KEYWORD_UNSUPPORTED
eng "%s keyword is not supported"
ER_EVENTS_NO_ACL
eng "Event scheduler cannot function with --skip-grant-tables, --bootstrap, or embedded build"

View File

@@ -1133,7 +1133,7 @@ static bool event_scheduler_check(sys_var *self, THD *thd, set_var *var)
if (Events::opt_event_scheduler == Events::EVENTS_DISABLED)
{
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0),
"--event-scheduler=DISABLED or --skip-grant-tables");
opt_noacl ? "--skip-grant-tables" : "--event-scheduler=DISABLED");
return true;
}
/* DISABLED is only accepted on the command line */