From 7893c120a98f52b07dc36342d2e1337b119e3670 Mon Sep 17 00:00:00 2001 From: Marko Date: Wed, 15 May 2019 21:37:16 +0300 Subject: [PATCH] MXS-2477 Change schemarouter ignore_databases parameters to ignore_tables With the table level sharding parameter is used to ignore tables not databases. --- .../routing/schemarouter/schemarouter.cc | 31 ++++++++++++++++--- .../routing/schemarouter/schemarouter.hh | 5 +++ .../schemarouter/schemarouterinstance.cc | 12 ++++--- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/server/modules/routing/schemarouter/schemarouter.cc b/server/modules/routing/schemarouter/schemarouter.cc index b996a3311..86adf53e2 100644 --- a/server/modules/routing/schemarouter/schemarouter.cc +++ b/server/modules/routing/schemarouter/schemarouter.cc @@ -22,16 +22,39 @@ Config::Config(MXS_CONFIG_PARAMETER* conf) : refresh_min_interval(conf->get_duration("refresh_interval").count()) , refresh_databases(conf->get_bool("refresh_databases")) , debug(conf->get_bool("debug")) - , ignore_regex(conf->get_compiled_regex("ignore_databases_regex", 0, NULL).release()) - , ignore_match_data(ignore_regex ? pcre2_match_data_create_from_pattern(ignore_regex, NULL) : NULL) + , ignore_regex(NULL) + , ignore_match_data(NULL) , preferred_server(conf->get_server("preferred_server")) { + // TODO: Don't process this in the router + if (conf->contains(CN_IGNORE_TABLES_REGEX)) + { + ignore_regex = conf->get_compiled_regex(CN_IGNORE_TABLES_REGEX, 0, NULL).release(); + ignore_match_data = pcre2_match_data_create_from_pattern(ignore_regex, NULL); + } + else if (conf->contains(CN_IGNORE_DATABASES_REGEX)) + { + MXS_WARNING("Parameter '%s' has been deprecated, use '%s' instead.", + CN_IGNORE_DATABASES_REGEX, CN_IGNORE_TABLES_REGEX); + ignore_regex = conf->get_compiled_regex(CN_IGNORE_DATABASES_REGEX, 0, NULL).release(); + ignore_match_data = pcre2_match_data_create_from_pattern(ignore_regex, NULL); + } + ignored_dbs.insert("mysql"); ignored_dbs.insert("information_schema"); ignored_dbs.insert("performance_schema"); - // TODO: Don't process this in the router - std::string ignored_dbs_str = conf->get_string("ignore_databases"); + std::string ignored_dbs_str = conf->get_string(CN_IGNORE_TABLES); + if (ignored_dbs_str.empty()) + { + ignored_dbs_str = conf->get_string(CN_IGNORE_DATABASES); + if (!ignored_dbs_str.empty()) + { + MXS_WARNING("Parameter '%s' has been deprecated, use '%s' instead.", + CN_IGNORE_DATABASES, CN_IGNORE_TABLES); + } + } + if (!ignored_dbs_str.empty()) { for (const auto& a : mxs::strtok(ignored_dbs_str, ", \t")) diff --git a/server/modules/routing/schemarouter/schemarouter.hh b/server/modules/routing/schemarouter/schemarouter.hh index 0006816c9..e93dc2d85 100644 --- a/server/modules/routing/schemarouter/schemarouter.hh +++ b/server/modules/routing/schemarouter/schemarouter.hh @@ -32,6 +32,11 @@ #include #include +const char* const CN_IGNORE_DATABASES = "ignore_databases"; +const char* const CN_IGNORE_DATABASES_REGEX = "ignore_databases_regex"; +const char* const CN_IGNORE_TABLES = "ignore_tables"; +const char* const CN_IGNORE_TABLES_REGEX = "ignore_tables_regex"; + namespace schemarouter { /** diff --git a/server/modules/routing/schemarouter/schemarouterinstance.cc b/server/modules/routing/schemarouter/schemarouterinstance.cc index b1faa918d..cb7c24cf7 100644 --- a/server/modules/routing/schemarouter/schemarouterinstance.cc +++ b/server/modules/routing/schemarouter/schemarouterinstance.cc @@ -296,11 +296,13 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() NULL, NULL, { - {"ignore_databases", MXS_MODULE_PARAM_STRING }, - {"ignore_databases_regex", MXS_MODULE_PARAM_STRING }, - {"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "0"}, - {"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false"}, - {"refresh_databases", MXS_MODULE_PARAM_BOOL, "true"}, + {CN_IGNORE_TABLES, MXS_MODULE_PARAM_STRING }, + {CN_IGNORE_TABLES_REGEX, MXS_MODULE_PARAM_STRING }, + {CN_IGNORE_DATABASES, MXS_MODULE_PARAM_STRING }, + {CN_IGNORE_DATABASES_REGEX, MXS_MODULE_PARAM_STRING }, + {"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "0"}, + {"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false"}, + {"refresh_databases", MXS_MODULE_PARAM_BOOL, "true"}, { "refresh_interval", MXS_MODULE_PARAM_DURATION,