summaryrefslogtreecommitdiff
path: root/modules/database/db_sql.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-03-16 20:08:39 -0500
committerAdam <Adam@anope.org>2013-03-16 20:08:39 -0500
commit810685cb739dc32690bd571492629293b4a0e1fd (patch)
tree64829c1d9ca668ed97b59cf18acd9bbca856783d /modules/database/db_sql.cpp
parent1a0e6b0be3f901462d4376c882f1dc7304bedaf9 (diff)
Have db_flatfile store object ids if they are set, even though it doesn't use them, so that if other database modules that use them are loaded they can keep track of objects properly
Diffstat (limited to 'modules/database/db_sql.cpp')
-rw-r--r--modules/database/db_sql.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp
index 3bb0efde2..ab6a1b259 100644
--- a/modules/database/db_sql.cpp
+++ b/modules/database/db_sql.cpp
@@ -63,6 +63,7 @@ class DBSQL : public Module, public Pipe
bool shutting_down;
bool loading_databases;
bool loaded;
+ bool imported;
void RunBackground(const Query &q, Interface *iface = NULL)
{
@@ -86,7 +87,7 @@ class DBSQL : public Module, public Pipe
}
public:
- DBSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE), sql("", ""), sqlinterface(this), shutting_down(false), loading_databases(false), loaded(false)
+ DBSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE), sql("", ""), sqlinterface(this), shutting_down(false), loading_databases(false), loaded(false), imported(false)
{
this->SetAuthor("Anope");
@@ -121,17 +122,22 @@ class DBSQL : public Module, public Pipe
this->RunBackground(create[i]);
Query insert = this->sql->BuildInsert(this->prefix + s_type->GetName(), obj->id, data);
- if (this->loaded)
+ if (this->imported)
this->RunBackground(insert, new ResultSQLSQLInterface(this, obj));
else
- /* If we aren't loading these objects then we are importing them, so don't do asynchronous
- * queries in case for some reason the core has to shut down, it will cut short the import
+ {
+ /* On the first loop we may be importing objects from another database module, so don't do asynchronous
+ * queries in case the core has to shut down, it will cut short the import
*/
- this->sql->RunQuery(insert);
+ Result r = this->sql->RunQuery(insert);
+ if (r.GetID() > 0)
+ obj->id = r.GetID();
+ }
}
}
this->updated_items.clear();
+ this->imported = true;
}
void OnReload() anope_override