mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id
The problem is that creating a event could fail if the value of the variable server_id didn't fit in the originator column of the event system table. The cause is two-fold: it was possible to set server_id to a value outside the documented range (from 0 to 2^32-1) and the originator column of the event table didn't have enough room for values in this range. The log tables (general_log and slow_log) also don't have a proper column type to store the server_id and having a large server_id value could prevent queries from being logged. The solution is to ensure that all system tables that store the server_id value have a proper column type (int unsigned) and that the variable can't be set to a value that is not within the range. mysql-test/r/events_bugs.result: Add test case result for Bug#36540 mysql-test/r/log_tables.result: Update column type. mysql-test/r/system_mysql_db.result: Update column type. mysql-test/r/variables.result: Add test case result for server_id value range. mysql-test/suite/sys_vars/r/server_id_basic_64.result: Update test case results. mysql-test/t/events_bugs.test: Add test case for Bug#36540 mysql-test/t/log_tables.test: Fix column type. mysql-test/t/variables.test: Add test case for server_id value range. scripts/mysql_system_tables.sql: Columns that store the server_id value must be of type INT UNSIGNED, fix event (originator), general_log and slow_log (server_id) tables in accordance. scripts/mysql_system_tables_fix.sql: Columns that store the server_id value must be of type INT UNSIGNED, fix event (originator), general_log and slow_log (server_id) tables in accordance. sql/mysqld.cc: Set min and max values for the server_id variable. Unfortunately we can't easily change server_id variable type from ulong to uint32 because of the sys_var classes.
This commit is contained in:
@ -1209,6 +1209,18 @@ select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mo
|
||||
select name from mysql.event where name = 'p' and sql_mode = @full_mode;
|
||||
drop event e1;
|
||||
|
||||
#
|
||||
# Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id
|
||||
#
|
||||
|
||||
SET @old_server_id = @@GLOBAL.server_id;
|
||||
SET GLOBAL server_id = (1 << 32) - 1;
|
||||
SELECT @@GLOBAL.server_id;
|
||||
CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1;
|
||||
SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS;
|
||||
DROP EVENT ev1;
|
||||
SET GLOBAL server_id = @old_server_id;
|
||||
|
||||
###########################################################################
|
||||
#
|
||||
# End of tests
|
||||
|
@ -287,7 +287,7 @@ CREATE TABLE `general_log` (
|
||||
ON UPDATE CURRENT_TIMESTAMP,
|
||||
`user_host` mediumtext NOT NULL,
|
||||
`thread_id` int(11) NOT NULL,
|
||||
`server_id` int(11) NOT NULL,
|
||||
`server_id` int(10) unsigned NOT NULL,
|
||||
`command_type` varchar(64) NOT NULL,
|
||||
`argument` mediumtext NOT NULL
|
||||
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
|
||||
@ -303,7 +303,7 @@ CREATE TABLE `slow_log` (
|
||||
`db` varchar(512) NOT NULL,
|
||||
`last_insert_id` int(11) NOT NULL,
|
||||
`insert_id` int(11) NOT NULL,
|
||||
`server_id` int(11) NOT NULL,
|
||||
`server_id` int(10) unsigned NOT NULL,
|
||||
`sql_text` mediumtext NOT NULL
|
||||
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
|
||||
|
||||
|
@ -1164,5 +1164,21 @@ SET GLOBAL expire_logs_days = @old_eld;
|
||||
select @@storage_engine;
|
||||
--disable_metadata
|
||||
|
||||
#
|
||||
# Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id
|
||||
#
|
||||
|
||||
SET @old_server_id = @@GLOBAL.server_id;
|
||||
SET GLOBAL server_id = (1 << 32) - 1;
|
||||
SELECT @@GLOBAL.server_id;
|
||||
SET GLOBAL server_id = (1 << 32);
|
||||
SELECT @@GLOBAL.server_id;
|
||||
SET GLOBAL server_id = (1 << 60);
|
||||
SELECT @@GLOBAL.server_id;
|
||||
SET GLOBAL server_id = 0;
|
||||
SELECT @@GLOBAL.server_id;
|
||||
SET GLOBAL server_id = -1;
|
||||
SELECT @@GLOBAL.server_id;
|
||||
SET GLOBAL server_id = @old_server_id;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
Reference in New Issue
Block a user