summaryrefslogtreecommitdiff
path: root/src/modules/extra
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-14 23:14:23 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-14 23:14:23 +0000
commitf927c17c606bb6f13376a683f2f6776fc4c3e4c9 (patch)
treeb0c8b1f7f7045d018122de1bc4361b1e2088b19a /src/modules/extra
parent085671219c2d477006db815efc03038178b989a4 (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/modules/extra')
-rw-r--r--src/modules/extra/m_sqlite3.cpp20
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, &params);
if (sqlite3_exec(conn, req.query.q.data(), QueryResult, &params, &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);