From fbeb5d9c84c35f09088464cc2d049cbc3a089f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 23 Jul 2019 09:20:33 +0300 Subject: [PATCH] Always ignore server-internal databases The mysql, information_schema and performance_schema databases should always be ignored if found on multiple servers. --- server/modules/routing/schemarouter/schemaroutersession.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/modules/routing/schemarouter/schemaroutersession.cc b/server/modules/routing/schemarouter/schemaroutersession.cc index 4b7bfa1d8..ff9cd4fdb 100644 --- a/server/modules/routing/schemarouter/schemaroutersession.cc +++ b/server/modules/routing/schemarouter/schemaroutersession.cc @@ -1192,11 +1192,13 @@ char* get_lenenc_str(void* data) return rval; } +static const std::set always_ignore = {"mysql", "information_schema", "performance_schema"}; + bool SchemaRouterSession::ignore_duplicate_database(const char* data) { bool rval = false; - if (m_config->ignored_dbs.find(data) != m_config->ignored_dbs.end()) + if (m_config->ignored_dbs.count(data) || always_ignore.count(data)) { rval = true; } @@ -1379,8 +1381,7 @@ void SchemaRouterSession::query_databases() "LEFT JOIN information_schema.tables AS t ON s.schema_name = t.table_schema " "WHERE t.table_name IS NULL " "UNION " - "SELECT CONCAT (table_schema, '.', table_name) FROM information_schema.tables " - "WHERE table_schema NOT IN ('information_schema', 'performance_schema', 'mysql');"); + "SELECT CONCAT (table_schema, '.', table_name) FROM information_schema.tables"); gwbuf_set_type(buffer, GWBUF_TYPE_COLLECT_RESULT); for (SSRBackendList::iterator it = m_backends.begin(); it != m_backends.end(); it++)