Skip to content

Commit 90b6725

Browse files
Paweł Andruszkiewiczrennox
authored andcommitted
BUG#35550282 Handle mysql_audit schema
Starting with 8.1.0 (8.0.34), MDS stores the audit plugin configuration in the `mysql_audit` schema. This schema already exists when the MDS instance is created, causing the dump&load from MDS into MDS to fail with the duplicate objects error. As a fix, when using `util.dumpInstance()` with the `ocimds` option set to true, the `mysql_audit` schema is automatically excluded from the dump. Change-Id: I1e1329e4eb1ab395b9ddbf40fb2c9495c8b29e6f
1 parent 4ed2fb2 commit 90b6725

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

modules/util/dump/dump_instance_options.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0,
@@ -85,6 +85,12 @@ void Dump_instance_options::on_unpacked_options() {
8585
}
8686
}
8787

88+
if (mds_compatibility().has_value()) {
89+
// if MDS compatibility option is set, the schema name used by the OCI to
90+
// store the audit plugin's configuration should not be dumped
91+
filters().schemas().exclude("mysql_audit");
92+
}
93+
8894
m_filter_conflicts |= filters().schemas().error_on_conflicts();
8995
m_filter_conflicts |= filters().users().error_on_conflicts();
9096
}

unittest/scripts/auto/py_shell/scripts/util_dump_instance_norecord.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3574,6 +3574,24 @@ def account_for_grant():
35743574
#@<> Drop roles {VER(>=8.0.0)}
35753575
session.run_sql("DROP ROLE IF EXISTS ?;", [ test_role ])
35763576

3577+
#@<> BUG#35550282 - exclude `mysql_audit` schema if the `ocimds` option is set
3578+
# setup
3579+
schema_name = "mysql_audit"
3580+
3581+
session.run_sql("DROP SCHEMA IF EXISTS !", [schema_name])
3582+
session.run_sql("CREATE SCHEMA !", [schema_name])
3583+
3584+
#@<> BUG#35550282 - option is not set, schema is dumped
3585+
EXPECT_SUCCESS(None, test_output_absolute, { "ddlOnly": True, "showProgress": False })
3586+
EXPECT_TRUE(os.path.isfile(os.path.join(test_output_absolute, encode_schema_basename(schema_name) + ".sql")))
3587+
3588+
#@<> BUG#35550282 - option is set, schema is not dumped
3589+
EXPECT_SUCCESS(None, test_output_absolute, { "ocimds": True, "compatibility": ["ignore_missing_pks"], "users": False, "ddlOnly": True, "showProgress": False })
3590+
EXPECT_FALSE(os.path.isfile(os.path.join(test_output_absolute, encode_schema_basename(schema_name) + ".sql")))
3591+
3592+
#@<> BUG#35550282 - cleanup
3593+
session.run_sql("DROP SCHEMA !;", [schema_name])
3594+
35773595
#@<> Cleanup
35783596
drop_all_schemas()
35793597
session.run_sql("SET GLOBAL local_infile = false;")

0 commit comments

Comments
 (0)