*Fix build.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-25 11:31:57 -05:00
parent 8644c48db8
commit f89cd6318d
6 changed files with 0 additions and 356 deletions

View File

@@ -4,14 +4,11 @@ SET(trinitydatabase_STAT_SRCS
DBCStore.h
Database.cpp
Database.h
DatabaseEnv.h
DatabaseImpl.h
DatabaseMysql.cpp
DatabasePostgre.cpp
DatabaseMysql.h
DatabasePostgre.h
DatabaseSqlite.cpp
DatabaseSqlite.h
Field.cpp
Field.h
MySQLDelayThread.h
@@ -21,8 +18,6 @@ SET(trinitydatabase_STAT_SRCS
QueryResultMysql.h
QueryResultPostgre.cpp
QueryResultPostgre.h
QueryResultSqlite.cpp
QueryResultSqlite.h
SQLStorage.cpp
SQLStorage.h
SqlDelayThread.cpp

View File

@@ -1,56 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if !defined(DATABASEENV_H)
#define DATABASEENV_H
#include "Common.h"
#include "Log.h"
#include "Errors.h"
#include "Database/Field.h"
#include "Database/QueryResult.h"
#ifdef DO_POSTGRESQL
#include "Database/QueryResultPostgre.h"
#include "Database/Database.h"
#include "Database/DatabasePostgre.h"
typedef DatabasePostgre DatabaseType;
#define _LIKE_ "ILIKE"
#define _TABLE_SIM_ "\""
#define _CONCAT3_(A,B,C) "( " A " || " B " || " C " )"
#define _OFFSET_ "LIMIT 1 OFFSET %d"
#else
#include "Database/QueryResultMysql.h"
#include "Database/Database.h"
#include "Database/DatabaseMysql.h"
typedef DatabaseMysql DatabaseType;
#define _LIKE_ "LIKE"
#define _TABLE_SIM_ "`"
#define _CONCAT3_(A,B,C) "CONCAT( " A " , " B " , " C " )"
#define _OFFSET_ "LIMIT %d,1"
#endif
extern DatabaseType WorldDatabase;
extern DatabaseType CharacterDatabase;
extern DatabaseType LoginDatabase;
#endif

View File

@@ -1,104 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DO_POSTGRESQL
#include "DatabaseEnv.h"
DatabaseSqlite::DatabaseSqlite() : Database(), mSqlite(0)
{
}
DatabaseSqlite::~DatabaseSqlite()
{
if (mSqlite)
sqlite_close(mSqlite);
}
bool DatabaseSqlite::Initialize(const char *infoString)
{
if(!Database::Initialize(infoString))
return false;
char *errmsg;
mSqlite = sqlite_open(infoString, 0, &errmsg);
if (!mSqlite)
{
if (errmsg)
sqlite_freemem(errmsg);
return false;
}
return true;
}
QueryResult* DatabaseSqlite::Query(const char *sql)
{
char *errmsg;
if (!mSqlite)
return 0;
char **tableData;
int rowCount;
int fieldCount;
sqlite_get_table(mSqlite, sql, &tableData, &rowCount, &fieldCount, &errmsg);
if (!rowCount)
return 0;
if (!tableData)
{
if (errmsg)
sqlite_freemem(errmsg);
return 0;
}
QueryResultSqlite *queryResult = new QueryResultSqlite(tableData, rowCount, fieldCount);
if(!queryResult)
{
return 0;
}
queryResult->NextRow();
return queryResult;
}
bool DatabaseSqlite::Execute(const char *sql)
{
char *errmsg;
if (!mSqlite)
return false;
if(sqlite_exec(mSqlite, sql, NULL, NULL, &errmsg) != SQLITE_OK)
return false;
return true;
}
#endif

View File

@@ -1,46 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DO_POSTGRESQL
#ifndef _DATABASESQLITE_H
#define _DATABASESQLITE_H
#include <sqlite/sqlite.h>
class DatabaseSqlite : public Database
{
public:
DatabaseSqlite();
~DatabaseSqlite();
bool Initialize(const char *infoString);
QueryResult* Query(const char *sql);
bool Execute(const char *sql);
operator bool () const { return mSqlite != NULL; }
private:
sqlite *mSqlite;
};
#endif
#endif

View File

@@ -1,99 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DO_POSTGRESQL
#include "DatabaseEnv.h"
QueryResultSqlite::QueryResultSqlite(char **tableData, uint32 rowCount, uint32 fieldCount) :
QueryResult(rowCount, fieldCount), mTableData(tableData), mTableIndex(0)
{
mCurrentRow = new Field[mFieldCount];
for (uint32 i = 0; i < mFieldCount; i++)
{
mFieldNames[i] = mTableData[i];
mCurrentRow[i].SetType(Field::DB_TYPE_UNKNOWN);
}
}
QueryResultSqlite::~QueryResultSqlite()
{
EndQuery();
}
bool QueryResultSqlite::NextRow()
{
int startIndex;
uint32 i;
if (!mTableData)
return false;
if (mTableIndex >= mRowCount)
{
EndQuery();
return false;
}
startIndex = (mTableIndex + 1) * mFieldCount;
for (i = 0; i < mFieldCount; i++)
{
mCurrentRow[i].SetValue(mTableData[startIndex + i]);
}
++mTableIndex;
return true;
}
void QueryResultSqlite::EndQuery()
{
if (mCurrentRow)
{
delete [] mCurrentRow;
mCurrentRow = NULL;
}
if (mTableData)
{
sqlite_free_table(mTableData);
mTableData = NULL;
}
}
enum Field::DataTypes QueryResultSqlite::ConvertNativeType(const char* sqliteType) const
{
if (sqliteType)
{
switch (*sqliteType)
{
case 'S':
return Field::DB_TYPE_STRING;
case 'I':
return Field::DB_TYPE_INTEGER;
case 'F':
return Field::DB_TYPE_FLOAT;
default:
return Field::DB_TYPE_UNKNOWN;
};
}
return Field::DB_TYPE_UNKNOWN;
}
#endif

View File

@@ -1,46 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DO_POSTGRESQL
#if !defined(QUERYRESULTSQLITE_H)
#define QUERYRESULTSQLITE_H
#include <sqlite/sqlite.h>
class QueryResultSqlite : public QueryResult
{
public:
QueryResultSqlite(char **tableData, uint32 rowCount, uint32 fieldCount);
~QueryResultSqlite();
bool NextRow();
private:
enum Field::DataTypes ConvertNativeType(const char* sqliteType) const;
void EndQuery();
char **mTableData;
uint32 mTableIndex;
};
#endif
#endif