Merging like a zip!

This commit is contained in:
Matt Woodrow 2008-10-16 10:55:42 +13:00
commit 3c12db8637
3 changed files with 47 additions and 14 deletions

View File

@ -415,7 +415,18 @@ bool ClientPrefs::AddQueryToQueue( TQueryOp *query )
{
query->SetDatabase(Database);
query->SetPreparedQuery();
if (query->GetQuery() == NULL && query->GetType() != Query_Connect)
{
g_pSM->LogError(myself, "Invalid aqtq query %d being inserted! glorp: %p, %p",
query->GetType(),
query->GetDriver(),
query);
query->Destroy();
}
else
{
dbi->AddToThreadQueue(query, PrioQueue_Normal);
}
return true;
}
@ -435,17 +446,28 @@ void ClientPrefs::ProcessQueryCache()
while (iter != cachedQueries.end())
{
TQueryOp *op = (TQueryOp *)*iter;
TQueryOp *op = *iter;
if (Database != NULL)
{
op->SetDatabase(Database);
op->SetPreparedQuery();
dbi->AddToThreadQueue(op, PrioQueue_Normal);
if (op->GetQuery() == NULL && op->GetType() != Query_Connect)
{
g_pSM->LogError(myself, "Invalid pqc query %d being inserted! glorp: %p, %p",
op->GetType(),
op->GetDriver(),
op);
op->Destroy();
}
else
{
delete op;
dbi->AddToThreadQueue(op, PrioQueue_Normal);
}
}
else
{
op->Destroy();
}
iter++;

View File

@ -79,10 +79,7 @@ void TQueryOp::RunThreadPart()
}
else
{
if (m_database == NULL)
{
return;
}
assert(m_database != NULL);
m_database->LockForFullAtomicOperation();
@ -99,10 +96,7 @@ void TQueryOp::RunThreadPart()
IDBDriver *TQueryOp::GetDriver()
{
if (m_database == NULL)
{
return NULL;
}
assert(m_database != NULL);
return m_database->GetDriver();
}
@ -140,9 +134,12 @@ void TQueryOp::SetDatabase( IDatabase *db )
bool TQueryOp::BindParamsAndRun()
{
assert(m_pQuery != NULL);
/* :TODO: remove this check. */
if (m_pQuery == NULL)
{
g_pSM->LogError(myself, "Attempted to run with a NULL Query");
g_pSM->LogError(myself, "Attempted to run with a NULL Query (type %d)", m_type);
return false;
}
@ -230,7 +227,6 @@ void TQueryOp::SetPreparedQuery()
{
break;
}
}
}

View File

@ -91,6 +91,21 @@ public:
/* Params to be bound */
ParamData m_params;
inline IPreparedQuery *GetQuery()
{
return m_pQuery;
}
inline querytype GetType()
{
return m_type;
}
inline IDatabase *GetDB()
{
return m_database;
}
private:
IPreparedQuery *m_pQuery;
IDatabase *m_database;