Permalink
Browse files

Fix sys_config_cleanup.inc to reset given the new variables added by …

…the new statement_performance_analayzer and diagnostics routines. Also added a way to ignore the update of the user within the sys_config triggers, so that tests can properly reset the settings back to default (NULL set_by).
  • Loading branch information...
1 parent c781ffb commit da4942c73d65dfed77eca4de27526dbc922fc941 @MarkLeith MarkLeith committed Aug 17, 2015
@@ -1,7 +1,16 @@
# Reset the sys.sys_config table
-# Note, we can *not* reset the set_by column back to NULL
+# Note, we have to disable the triggers to reset the set_by column back to NULL
# as the sys.sys_config_update_set_user trigger will overwrite it to the current user
-UPDATE sys.sys_config SET value = 64 WHERE variable = 'statement_truncate_len';
+SET @sys.ignore_sys_config_triggers := true;
-DELETE FROM sys.sys_config WHERE variable NOT IN ('statement_truncate_len');
+DELETE FROM sys.sys_config;
+
+INSERT IGNORE INTO sys.sys_config (variable, value) VALUES
+ ('statement_truncate_len', 64),
+ ('statement_performance_analyzer.limit', 100),
+ ('statement_performance_analyzer.view', NULL),
+ ('diagnostics.allow_i_s_tables', 'OFF'),
+ ('diagnostics.include_raw', 'OFF');
+
+SET @sys.ignore_sys_config_triggers := NULL;
@@ -458,5 +458,12 @@ SET SESSION sql_mode = @@global.sql_mode;
SET @sys.statement_performance_analyzer.limit = NULL;
SET @sys.statement_performance_analyzer.view = NULL;
UPDATE performance_schema.setup_consumers SET enabled = 'YES';
-UPDATE sys.sys_config SET value = 64 WHERE variable = 'statement_truncate_len';
-DELETE FROM sys.sys_config WHERE variable NOT IN ('statement_truncate_len');
+SET @sys.ignore_sys_config_triggers := true;
+DELETE FROM sys.sys_config;
+INSERT IGNORE INTO sys.sys_config (variable, value) VALUES
+('statement_truncate_len', 64),
+('statement_performance_analyzer.limit', 100),
+('statement_performance_analyzer.view', NULL),
+('diagnostics.allow_i_s_tables', 'OFF'),
+('diagnostics.include_raw', 'OFF');
+SET @sys.ignore_sys_config_triggers := NULL;
@@ -18,15 +18,22 @@ diagnostics.allow_i_s_tables OFF NULL
diagnostics.include_raw OFF NULL
statement_performance_analyzer.limit 100 NULL
statement_performance_analyzer.view NULL NULL
-statement_truncate_len 128 root@localhost
+statement_truncate_len 128 NULL
INSERT INTO sys.sys_config (variable, value) VALUES ('foo', 'bar');
SELECT variable, value, set_by FROM sys.sys_config;
variable value set_by
diagnostics.allow_i_s_tables OFF NULL
diagnostics.include_raw OFF NULL
-foo bar root@localhost
+foo bar NULL
statement_performance_analyzer.limit 100 NULL
statement_performance_analyzer.view NULL NULL
-statement_truncate_len 128 root@localhost
-UPDATE sys.sys_config SET value = 64 WHERE variable = 'statement_truncate_len';
-DELETE FROM sys.sys_config WHERE variable NOT IN ('statement_truncate_len');
+statement_truncate_len 128 NULL
+SET @sys.ignore_sys_config_triggers := true;
+DELETE FROM sys.sys_config;
+INSERT IGNORE INTO sys.sys_config (variable, value) VALUES
+('statement_truncate_len', 64),
+('statement_performance_analyzer.limit', 100),
+('statement_performance_analyzer.view', NULL),
+('diagnostics.allow_i_s_tables', 'OFF'),
+('diagnostics.include_raw', 'OFF');
+SET @sys.ignore_sys_config_triggers := NULL;
@@ -13,7 +13,9 @@
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-INSERT IGNORE INTO sys_config (variable, value) VALUES
+-- NOTE: This needs to be replicated within the sys_config_clean.inc file
+
+INSERT IGNORE INTO sys.sys_config (variable, value) VALUES
('statement_truncate_len', 64),
('statement_performance_analyzer.limit', 100),
('statement_performance_analyzer.view', NULL),
@@ -27,7 +27,7 @@ DELIMITER $$
CREATE DEFINER='root'@'localhost' TRIGGER sys_config_insert_set_user BEFORE INSERT on sys_config
FOR EACH ROW
BEGIN
- IF NEW.set_by IS NULL THEN
+ IF @sys.ignore_sys_config_triggers != true AND NEW.set_by IS NULL THEN
SET NEW.set_by = USER();
END IF;
END$$
@@ -28,7 +28,7 @@ DELIMITER $$
CREATE DEFINER='root'@'localhost' TRIGGER sys_config_update_set_user BEFORE UPDATE on sys_config
FOR EACH ROW
BEGIN
- IF NEW.set_by IS NULL THEN
+ IF @sys.ignore_sys_config_triggers != true AND NEW.set_by IS NULL THEN
SET NEW.set_by = USER();
END IF;
END$$

0 comments on commit da4942c

Please sign in to comment.