diff options
author | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-14 23:14:23 +0000 |
---|---|---|
committer | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-14 23:14:23 +0000 |
commit | f927c17c606bb6f13376a683f2f6776fc4c3e4c9 (patch) | |
tree | b0c8b1f7f7045d018122de1bc4361b1e2088b19a /src | |
parent | 085671219c2d477006db815efc03038178b989a4 (diff) |
Hook qlite3_update_hook to queries to also catch affected rows on UPDATE/INSERT/DELETE.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6344 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/extra/m_sqlite3.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index 469d5e153..5fba3880e 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -126,6 +126,11 @@ class SQLite3Result : public SQLresult rows++; } + void UpdateAffectedCount() + { + rows++; + } + virtual int Rows() { return rows; @@ -339,8 +344,7 @@ class SQLConn : public classbase *queryend = 0; req.query.q = query; -// Instance->Log(DEBUG, "<******> Doing query: " + ConvToStr(req.query.q.data())); - + //Instance->Log(DEBUG, "<******> Doing query: " + ConvToStr(req.query.q.data())); SQLite3Result* res = new SQLite3Result(mod, req.GetSource(), req.id); res->dbid = host.id; res->query = req.query.q; @@ -349,6 +353,7 @@ class SQLConn : public classbase params.push_back(res); char *errmsg = 0; + sqlite3_update_hook(conn, QueryUpdateHook, ¶ms); if (sqlite3_exec(conn, req.query.q.data(), QueryResult, ¶ms, &errmsg) != SQLITE_OK) { Instance->Log(DEBUG, "Query failed: " + ConvToStr(errmsg)); @@ -372,11 +377,22 @@ class SQLConn : public classbase return 0; } + static void QueryUpdateHook(void *params, int eventid, char const * azSQLite, char const * azColName, sqlite_int64 rowid) + { + paramlist* p = (paramlist*)params; + ((SQLConn*)(*p)[0])->AffectedReady(((SQLite3Result*)(*p)[1])); + }
+ void ResultReady(SQLite3Result *res, int cols, char **data, char **colnames) { res->AddRow(cols, data, colnames); } + void AffectedReady(SQLite3Result *res) + { + res->UpdateAffectedCount(); + } + int OpenDB() { return sqlite3_open(host.host.c_str(), &conn); |