- Joined
- Apr 1, 2012
- Messages
- 1,249
- Solutions
- 71
- Reaction score
- 621
- Location
- Hell
- GitHub
- idontreallywolf
I have compiled 0.4 sources (possibly modified) for a friend and it compiled successfully.
when I started the TFS an error occured saying that database in config was empty:
I have triple checked the database information in config.lua and that was OK.
then I looked into the sources and traced it to
after adding debug code I noticed db->escapeString was returning an empty string instead of the expected value.
In the
Im not sure why escapeBlob is returning '' instead of the expected value ...
OS: Linux, Debian 8
when I started the TFS an error occured saying that database in config was empty:
The database you have specified in config.lua is empty, please import schemas/<engine>.sql to the database.
I have triple checked the database information in config.lua and that was OK.
then I looked into the sources and traced it to
databasemanager.cpp
C++:
bool DatabaseManager::isDatabaseSetup()
{
Database* db = Database::getInstance();
switch(db->getDatabaseEngine())
{
case DATABASE_ENGINE_MYSQL:
{
DBQuery query;
query << "SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `TABLE_SCHEMA` = " << db->escapeString(g_config.getString(ConfigManager::SQL_DB)) << ";";
// DEBUG LINES
// THE FOLLOWING LINE GIVES:
// SELECT TABLE_NAME FROM information_schema.`tables` WHERE TABLE_SCHEMA = '';
std::cout << query.str() << std::endl;
// This line gives the correct value of sqlDatabase variable which is "evolera" (in config)
std::cout << "sqlDatabase -- " << g_config.getString(ConfigManager::SQL_DB) << std::endl;
// This line gives '' (empty string)
std::cout << "sqlDatabase -- " << db->escapeString(g_config.getString(ConfigManager::SQL_DB)) << std::endl;
DBResult* result;
if(!(result = db->storeQuery(query.str())))
return false;
result->free();
return true;
}
case DATABASE_ENGINE_SQLITE:
//a pre-setup sqlite database is already included
return true;
case DATABASE_ENGINE_POSTGRESQL:
//TODO: PostgreSQL support
return true;
default: break;
}
return false;
}
after adding debug code I noticed db->escapeString was returning an empty string instead of the expected value.
In the
databasemysql.h
header file I found that it was using this escapeBlob method :databasemysql.cpp
C++:
std::string DatabaseMySQL::escapeBlob(const char* s, uint32_t length)
{
if(!m_connected || *s == '\0')
return "''";
char* output = new char[(length << 1) + 1];
mysql_real_escape_string(m_handle, output, s, length);
std::string res = "'";
res += output;
res += "'";
delete[] output;
return res;
}
Im not sure why escapeBlob is returning '' instead of the expected value ...
OS: Linux, Debian 8
Last edited: