summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/extra/m_sql.cpp22
-rw-r--r--src/modules/extra/m_sql.h9
2 files changed, 31 insertions, 0 deletions
diff --git a/src/modules/extra/m_sql.cpp b/src/modules/extra/m_sql.cpp
index d2b5802de..1b7862281 100644
--- a/src/modules/extra/m_sql.cpp
+++ b/src/modules/extra/m_sql.cpp
@@ -229,6 +229,8 @@ class ModuleSQL : public Module
res->SetError(i->GetError());
return;
}
+ res->SetType(SQL_OK);
+ return;
}
}
}
@@ -246,17 +248,34 @@ class ModuleSQL : public Module
}
}
+ void DoneType(SQLRequest *r, SQLResult* res)
+ {
+ for (ConnectionList::iterator i = Connections.begin(); i != Connections.end(); i++)
+ {
+ if ((i->GetID() == r->GetConnID()) && (i->IsEnabled()))
+ {
+ res->SetType(SQL_DONE);
+ if (!i->QueryDone())
+ res->SetType(SQL_ERROR);
+ }
+ }
+ }
+
void RowType(SQLRequest *r, SQLResult* res)
{
for (ConnectionList::iterator i = Connections.begin(); i != Connections.end(); i++)
{
if ((i->GetID() == r->GetConnID()) && (i->IsEnabled()))
{
+ log(DEBUG,"*** FOUND MATCHING ROW");
std::map<std::string,std::string> row = i->GetRow();
res->SetRow(row);
res->SetType(SQL_ROW);
if (!row.size())
+ {
+ log(DEBUG,"ROW SIZE IS 0");
res->SetType(SQL_END);
+ }
return;
}
}
@@ -279,6 +298,9 @@ class ModuleSQL : public Module
case SQL_ROW:
RowType(r,Result);
break;
+ case SQL_DONE:
+ DoneType(r,Result);
+ break;
}
return (char*)Result;
}
diff --git a/src/modules/extra/m_sql.h b/src/modules/extra/m_sql.h
index 0620dedf7..5110146d9 100644
--- a/src/modules/extra/m_sql.h
+++ b/src/modules/extra/m_sql.h
@@ -9,6 +9,8 @@
#define SQL_ROW 3
#define SQL_ERROR 4
#define SQL_END 5
+#define SQL_DONE 6
+#define SQL_OK 7
// SQLRequest is inherited from a basic Request object
// so that we can neatly pass information around the
@@ -21,6 +23,13 @@ class SQLRequest
int request_type;
std::string thisquery;
public:
+ SQLRequest(int qt, long cid, std::string query)
+ {
+ this->SetQueryType(qt);
+ this->SetConnID(cid);
+ this->SetQuery(query);
+ }
+
void SetConnID(long id)
{
conn_id = id;