From 56fd0d7b0613be431b287cff37f0f20d41f9f153 Mon Sep 17 00:00:00 2001 From: anel Date: Fri, 22 Apr 2022 07:23:07 -0700 Subject: [PATCH] MDEV-28344:sys.ps_setup_save and dependent procedures fail with ER_ILLEGAL_HA_CREATE_OPTION - The problem: ============== - Commit f7216fa63d69448c3de1532a1dd197d0f28faefd created the check function for default temporary storage engine and in case the SE doesn't support temporary tables the error `ER_ILLEGAL_HA_CREATE_OPTION` is raised. Before that commit in such cases temporary tables were created by silently substituting default SE (RocksDB, Connect, PerfSchema) with MyISAM. - The test `pr_diagnostics.test` was modified in that commit with raising the error, since I didn't check the root cause of test itself. - The solution: =============== - This commit update the root case: procedure `ps_setup_save()` that uses temporary tables created from performance schema tables definition using `LIKE`, what is not supported. The suggested fix is to use InnoDB table by using `AS SELECT`. - Note that test `pr_diagnostics` will raise this error for `medium/full` third argument, but not for `current` value of third argument. - Additionally this patch updates the test case of commit f7216fa, by adding missing relation between temporary tables and Performance schema in `perfschema.misc` test. - Reviewed by: --- mysql-test/suite/perfschema/r/misc.result | 13 ++++++++++++ mysql-test/suite/perfschema/t/misc.test | 20 +++++++++++++++++++ .../suite/sysschema/r/pr_diagnostics.result | 2 ++ .../suite/sysschema/t/pr_diagnostics.test | 1 - .../sys_schema/procedures/ps_setup_save.sql | 9 +++------ 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/perfschema/r/misc.result b/mysql-test/suite/perfschema/r/misc.result index 83ca6d5cf3f..b1fa4f6c765 100644 --- a/mysql-test/suite/perfschema/r/misc.result +++ b/mysql-test/suite/perfschema/r/misc.result @@ -174,3 +174,16 @@ select object_type, object_schema, object_name from performance_schema.objects_summary_global_by_type where object_schema="test"; object_type object_schema object_name +# +# MDEV-28344: sys.ps_setup_save and dependent procedures fail +# with ER_ILLEGAL_HA_CREATE_OPTION +# +CREATE TEMPORARY TABLE t1 (t int) ENGINE = PERFORMANCE_SCHEMA; +ERROR HY000: Table storage engine 'PERFORMANCE_SCHEMA' does not support the create option 'TEMPORARY' +CREATE TEMPORARY TABLE t1 LIKE performance_schema.setup_actors; +ERROR HY000: Table storage engine 'PERFORMANCE_SCHEMA' does not support the create option 'TEMPORARY' +SET @default_storage_engine_old = @@default_storage_engine; +SET default_storage_engine = performance_schema; +CREATE TEMPORARY TABLE t1 (t int); +ERROR HY000: Table storage engine 'PERFORMANCE_SCHEMA' does not support the create option 'TEMPORARY' +SET @@default_storage_engine = @default_storage_engine_old; diff --git a/mysql-test/suite/perfschema/t/misc.test b/mysql-test/suite/perfschema/t/misc.test index 848be3beea1..79c23c65616 100644 --- a/mysql-test/suite/perfschema/t/misc.test +++ b/mysql-test/suite/perfschema/t/misc.test @@ -298,3 +298,23 @@ drop tables t1; select object_type, object_schema, object_name from performance_schema.objects_summary_global_by_type where object_schema="test"; + +--echo # +--echo # MDEV-28344: sys.ps_setup_save and dependent procedures fail +--echo # with ER_ILLEGAL_HA_CREATE_OPTION +--echo # + +# It is not allowed to create temporary tables with performance schema +--error ER_ILLEGAL_HA_CREATE_OPTION +CREATE TEMPORARY TABLE t1 (t int) ENGINE = PERFORMANCE_SCHEMA; + +--error ER_ILLEGAL_HA_CREATE_OPTION +CREATE TEMPORARY TABLE t1 LIKE performance_schema.setup_actors; + +SET @default_storage_engine_old = @@default_storage_engine; +SET default_storage_engine = performance_schema; + +--error ER_ILLEGAL_HA_CREATE_OPTION +CREATE TEMPORARY TABLE t1 (t int); + +SET @@default_storage_engine = @default_storage_engine_old; \ No newline at end of file diff --git a/mysql-test/suite/sysschema/r/pr_diagnostics.result b/mysql-test/suite/sysschema/r/pr_diagnostics.result index 90021f636d8..d07295bdbe9 100644 --- a/mysql-test/suite/sysschema/r/pr_diagnostics.result +++ b/mysql-test/suite/sysschema/r/pr_diagnostics.result @@ -6,6 +6,8 @@ SET @sys.debug = 'OFF', @sys.diagnostics.allow_i_s_tables = 'OFF', @sys.diagnostics.include_raw = 'OFF'; CALL sys.diagnostics(0, 0, 'full'); +summary +Disabled 1 thread ERROR 45000: in_max_runtime must be greater than 0 CALL sys.diagnostics(2, 0, 'full'); ERROR 45000: in_interval must be greater than 0 diff --git a/mysql-test/suite/sysschema/t/pr_diagnostics.test b/mysql-test/suite/sysschema/t/pr_diagnostics.test index 01825a1274e..40ea90005a9 100644 --- a/mysql-test/suite/sysschema/t/pr_diagnostics.test +++ b/mysql-test/suite/sysschema/t/pr_diagnostics.test @@ -19,7 +19,6 @@ SET @sys.debug = 'ON', @sys.diagnostics.allow_i_s_tables = 'ON', @sys.diagnostics.include_raw = 'ON'; ---error ER_ILLEGAL_HA_CREATE_OPTION CALL sys.diagnostics(4, 2, 'full'); SET @sys.debug = 'OFF', diff --git a/scripts/sys_schema/procedures/ps_setup_save.sql b/scripts/sys_schema/procedures/ps_setup_save.sql index a5a2197e935..b7843ecd1f2 100644 --- a/scripts/sys_schema/procedures/ps_setup_save.sql +++ b/scripts/sys_schema/procedures/ps_setup_save.sql @@ -80,14 +80,11 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp_setup_instruments; DROP TEMPORARY TABLE IF EXISTS tmp_threads; - CREATE TEMPORARY TABLE tmp_setup_actors LIKE performance_schema.setup_actors; - CREATE TEMPORARY TABLE tmp_setup_consumers LIKE performance_schema.setup_consumers; - CREATE TEMPORARY TABLE tmp_setup_instruments LIKE performance_schema.setup_instruments; + CREATE TEMPORARY TABLE tmp_setup_actors AS SELECT * FROM performance_schema.setup_actors; + CREATE TEMPORARY TABLE tmp_setup_consumers AS SELECT * FROM performance_schema.setup_consumers; + CREATE TEMPORARY TABLE tmp_setup_instruments AS SELECT * FROM performance_schema.setup_instruments; CREATE TEMPORARY TABLE tmp_threads (THREAD_ID bigint unsigned NOT NULL PRIMARY KEY, INSTRUMENTED enum('YES','NO') NOT NULL); - INSERT INTO tmp_setup_actors SELECT * FROM performance_schema.setup_actors; - INSERT INTO tmp_setup_consumers SELECT * FROM performance_schema.setup_consumers; - INSERT INTO tmp_setup_instruments SELECT * FROM performance_schema.setup_instruments; INSERT INTO tmp_threads SELECT THREAD_ID, INSTRUMENTED FROM performance_schema.threads; ELSE SIGNAL SQLSTATE VALUE '90000'