From 5068483cb917ba1c8ed3a0d20f7bfcb996f0aa3e Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 27 Apr 2012 15:38:50 -0400 Subject: Add db_sql:prefix allow prefixing all anope tables similarly, and changed db_sql to update the databases incrementally instead of one big flush --- modules/extra/m_chanstats.cpp | 2 +- modules/extra/m_mysql.cpp | 6 +++--- modules/extra/m_sqlite.cpp | 6 +++--- modules/extra/sql.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'modules/extra') diff --git a/modules/extra/m_chanstats.cpp b/modules/extra/m_chanstats.cpp index 8aa7e0a6a..9da3f0b10 100644 --- a/modules/extra/m_chanstats.cpp +++ b/modules/extra/m_chanstats.cpp @@ -66,7 +66,7 @@ class MChanstats : public Module if (!sql) return; - SQLResult r = this->sql->RunQuery(this->sql->GetTables()); + SQLResult r = this->sql->RunQuery(this->sql->GetTables("anope_bs_")); for (int i = 0; i < r.Rows(); ++i) { const std::map &map = r.Row(i); diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index 0696955cd..b5f0e4406 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -127,7 +127,7 @@ class MySQLService : public SQLProvider std::vector CreateTable(const Anope::string &table, const Serialize::Data &data) anope_override; - SQLQuery GetTables() anope_override; + SQLQuery GetTables(const Anope::string &prefix) anope_override; void Connect(); @@ -391,9 +391,9 @@ std::vector MySQLService::CreateTable(const Anope::string &table, cons return queries; } -SQLQuery MySQLService::GetTables() +SQLQuery MySQLService::GetTables(const Anope::string &prefix) { - return SQLQuery("SHOW TABLES"); + return SQLQuery("SHOW TABLES LIKE '" + prefix + "%';"); } void MySQLService::Connect() diff --git a/modules/extra/m_sqlite.cpp b/modules/extra/m_sqlite.cpp index 1c82f3459..5102c003b 100644 --- a/modules/extra/m_sqlite.cpp +++ b/modules/extra/m_sqlite.cpp @@ -48,7 +48,7 @@ class SQLiteService : public SQLProvider std::vector CreateTable(const Anope::string &table, const Serialize::Data &data) anope_override; - SQLQuery GetTables(); + SQLQuery GetTables(const Anope::string &prefix); Anope::string BuildQuery(const SQLQuery &q); }; @@ -236,9 +236,9 @@ std::vector SQLiteService::CreateTable(const Anope::string &table, con return queries; } -SQLQuery SQLiteService::GetTables() +SQLQuery SQLiteService::GetTables(const Anope::string &prefix) { - return SQLQuery("SELECT name FROM sqlite_master WHERE type='table'"); + return SQLQuery("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '" + prefix + "%';"); } Anope::string SQLiteService::Escape(const Anope::string &query) diff --git a/modules/extra/sql.h b/modules/extra/sql.h index a986cf794..2e2e1840c 100644 --- a/modules/extra/sql.h +++ b/modules/extra/sql.h @@ -129,6 +129,6 @@ class SQLProvider : public Service virtual std::vector CreateTable(const Anope::string &table, const Serialize::Data &data) = 0; - virtual SQLQuery GetTables() = 0; + virtual SQLQuery GetTables(const Anope::string &prefix) = 0; }; -- cgit