Increased Clientprefs error reporting and a rare leak on database connection failed.
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402434
This commit is contained in:
parent
ea748cfdbd
commit
a01848c774
@ -227,8 +227,7 @@ void ClientPrefs::DatabaseConnect()
|
|||||||
TQueryOp *op = new TQueryOp(Query_CreateTable, 0);
|
TQueryOp *op = new TQueryOp(Query_CreateTable, 0);
|
||||||
|
|
||||||
op->SetDatabase(Database);
|
op->SetDatabase(Database);
|
||||||
op->SetCustomPreparedQuery
|
IPreparedQuery *pQuery = Database->PrepareQuery(
|
||||||
(Database->PrepareQuery(
|
|
||||||
"CREATE TABLE IF NOT EXISTS sm_cookies \
|
"CREATE TABLE IF NOT EXISTS sm_cookies \
|
||||||
( \
|
( \
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT, \
|
id INTEGER PRIMARY KEY AUTOINCREMENT, \
|
||||||
@ -236,14 +235,22 @@ void ClientPrefs::DatabaseConnect()
|
|||||||
description varchar(255), \
|
description varchar(255), \
|
||||||
access INTEGER \
|
access INTEGER \
|
||||||
)",
|
)",
|
||||||
error, sizeof(error), &errCode));
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (pQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query CreateTable sm_cookies: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
op->SetCustomPreparedQuery(pQuery);
|
||||||
|
|
||||||
dbi->AddToThreadQueue(op, PrioQueue_High);
|
dbi->AddToThreadQueue(op, PrioQueue_High);
|
||||||
|
|
||||||
op = new TQueryOp(Query_CreateTable, 0);
|
op = new TQueryOp(Query_CreateTable, 0);
|
||||||
op->SetDatabase(Database);
|
op->SetDatabase(Database);
|
||||||
op->SetCustomPreparedQuery
|
|
||||||
(Database->PrepareQuery(
|
pQuery = Database->PrepareQuery(
|
||||||
"CREATE TABLE IF NOT EXISTS sm_cookie_cache \
|
"CREATE TABLE IF NOT EXISTS sm_cookie_cache \
|
||||||
( \
|
( \
|
||||||
player varchar(65) NOT NULL, \
|
player varchar(65) NOT NULL, \
|
||||||
@ -252,7 +259,15 @@ void ClientPrefs::DatabaseConnect()
|
|||||||
timestamp int, \
|
timestamp int, \
|
||||||
PRIMARY KEY (player, cookie_id) \
|
PRIMARY KEY (player, cookie_id) \
|
||||||
)",
|
)",
|
||||||
error, sizeof(error), &errCode));
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (pQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query CreateTable sm_cookie_cache: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
op->SetCustomPreparedQuery(pQuery);
|
||||||
|
|
||||||
dbi->AddToThreadQueue(op, PrioQueue_High);
|
dbi->AddToThreadQueue(op, PrioQueue_High);
|
||||||
}
|
}
|
||||||
@ -262,8 +277,8 @@ void ClientPrefs::DatabaseConnect()
|
|||||||
|
|
||||||
TQueryOp *op = new TQueryOp(Query_CreateTable, 0);
|
TQueryOp *op = new TQueryOp(Query_CreateTable, 0);
|
||||||
op->SetDatabase(Database);
|
op->SetDatabase(Database);
|
||||||
op->SetCustomPreparedQuery
|
|
||||||
(Database->PrepareQuery(
|
IPreparedQuery *pQuery = Database->PrepareQuery(
|
||||||
"CREATE TABLE IF NOT EXISTS sm_cookies \
|
"CREATE TABLE IF NOT EXISTS sm_cookies \
|
||||||
( \
|
( \
|
||||||
id INTEGER unsigned NOT NULL auto_increment, \
|
id INTEGER unsigned NOT NULL auto_increment, \
|
||||||
@ -272,14 +287,22 @@ void ClientPrefs::DatabaseConnect()
|
|||||||
access INTEGER, \
|
access INTEGER, \
|
||||||
PRIMARY KEY (id) \
|
PRIMARY KEY (id) \
|
||||||
)",
|
)",
|
||||||
error, sizeof(error), &errCode));
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (pQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query CreateTable sm_cookies: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
op->SetCustomPreparedQuery(pQuery);
|
||||||
|
|
||||||
dbi->AddToThreadQueue(op, PrioQueue_High);
|
dbi->AddToThreadQueue(op, PrioQueue_High);
|
||||||
|
|
||||||
op = new TQueryOp(Query_CreateTable, 0);
|
op = new TQueryOp(Query_CreateTable, 0);
|
||||||
op->SetDatabase(Database);
|
op->SetDatabase(Database);
|
||||||
op->SetCustomPreparedQuery
|
|
||||||
(Database->PrepareQuery(
|
pQuery = Database->PrepareQuery(
|
||||||
"CREATE TABLE IF NOT EXISTS sm_cookie_cache \
|
"CREATE TABLE IF NOT EXISTS sm_cookie_cache \
|
||||||
( \
|
( \
|
||||||
player varchar(65) NOT NULL, \
|
player varchar(65) NOT NULL, \
|
||||||
@ -288,7 +311,15 @@ void ClientPrefs::DatabaseConnect()
|
|||||||
timestamp int NOT NULL, \
|
timestamp int NOT NULL, \
|
||||||
PRIMARY KEY (player, cookie_id) \
|
PRIMARY KEY (player, cookie_id) \
|
||||||
)",
|
)",
|
||||||
error, sizeof(error), &errCode));
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (pQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query CreateTable sm_cookie_cache: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
op->SetCustomPreparedQuery(pQuery);
|
||||||
|
|
||||||
dbi->AddToThreadQueue(op, PrioQueue_High);
|
dbi->AddToThreadQueue(op, PrioQueue_High);
|
||||||
}
|
}
|
||||||
@ -308,11 +339,24 @@ void ClientPrefs::DatabaseConnect()
|
|||||||
"INSERT IGNORE INTO sm_cookies(name, description, access) \
|
"INSERT IGNORE INTO sm_cookies(name, description, access) \
|
||||||
VALUES(?, ?, ?)",
|
VALUES(?, ?, ?)",
|
||||||
error, sizeof(error), &errCode);
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (InsertCookieQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query InsertCookie: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
InsertDataQuery = Database->PrepareQuery(
|
InsertDataQuery = Database->PrepareQuery(
|
||||||
"INSERT INTO sm_cookie_cache(player, cookie_id, value, timestamp) \
|
"INSERT INTO sm_cookie_cache(player, cookie_id, value, timestamp) \
|
||||||
VALUES(?, ?, ?, ?) \
|
VALUES(?, ?, ?, ?) \
|
||||||
ON DUPLICATE KEY UPDATE value = ?, timestamp = ?",
|
ON DUPLICATE KEY UPDATE value = ?, timestamp = ?",
|
||||||
error, sizeof(error), &errCode);
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (InsertDataQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query InsertData: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -320,10 +364,23 @@ void ClientPrefs::DatabaseConnect()
|
|||||||
"INSERT OR IGNORE INTO sm_cookies(name, description, access) \
|
"INSERT OR IGNORE INTO sm_cookies(name, description, access) \
|
||||||
VALUES(?, ?, ?)",
|
VALUES(?, ?, ?)",
|
||||||
error, sizeof(error), &errCode);
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (InsertCookieQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query InsertCookie: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
InsertDataQuery = Database->PrepareQuery(
|
InsertDataQuery = Database->PrepareQuery(
|
||||||
"INSERT OR REPLACE INTO sm_cookie_cache(player, cookie_id, value, timestamp) \
|
"INSERT OR REPLACE INTO sm_cookie_cache(player, cookie_id, value, timestamp) \
|
||||||
VALUES(?, ?, ?, ?)",
|
VALUES(?, ?, ?, ?)",
|
||||||
error, sizeof(error), &errCode);
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (InsertDataQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query InsertData: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectDataQuery = Database->PrepareQuery(
|
SelectDataQuery = Database->PrepareQuery(
|
||||||
@ -334,12 +391,24 @@ void ClientPrefs::DatabaseConnect()
|
|||||||
WHERE player = ?",
|
WHERE player = ?",
|
||||||
error, sizeof(error), &errCode);
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (SelectDataQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query SelectData: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SelectIdQuery = Database->PrepareQuery(
|
SelectIdQuery = Database->PrepareQuery(
|
||||||
"SELECT id \
|
"SELECT id \
|
||||||
FROM sm_cookies \
|
FROM sm_cookies \
|
||||||
WHERE name=?",
|
WHERE name=?",
|
||||||
error, sizeof(error), &errCode);
|
error, sizeof(error), &errCode);
|
||||||
|
|
||||||
|
if (SelectIdQuery == NULL)
|
||||||
|
{
|
||||||
|
g_pSM->LogMessage(myself, "Failed to prepare query SelectId: %s (%i)", error, errCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
databaseLoading = false;
|
databaseLoading = false;
|
||||||
cell_t result = 0;
|
cell_t result = 0;
|
||||||
|
|
||||||
@ -369,6 +438,8 @@ bool ClientPrefs::AddQueryToQueue( TQueryOp *query )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query->Destroy();
|
||||||
|
|
||||||
/* If Database is NULL and we're not in the loading phase it must have failed - Can't do much */
|
/* If Database is NULL and we're not in the loading phase it must have failed - Can't do much */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,7 @@ IdentityToken_t *TQueryOp::GetOwner()
|
|||||||
{
|
{
|
||||||
return myself->GetIdentity();
|
return myself->GetIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TQueryOp::Destroy()
|
void TQueryOp::Destroy()
|
||||||
{
|
{
|
||||||
delete this;
|
delete this;
|
||||||
@ -148,6 +149,7 @@ bool TQueryOp::BindParamsAndRun()
|
|||||||
{
|
{
|
||||||
if (m_pQuery == NULL)
|
if (m_pQuery == NULL)
|
||||||
{
|
{
|
||||||
|
g_pSM->LogError(myself, "Attempted to run with a NULL Query");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user