1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Revert "Verify database connection on interval (#9665)"

Fixes #10113

This reverts commit 5c588f89e7.
This commit is contained in:
rubenwardy 2020-07-07 17:50:52 +01:00
parent dc6318b84a
commit 6e4d8de104
9 changed files with 33 additions and 65 deletions

View file

@ -121,7 +121,7 @@ Database_SQLite3::Database_SQLite3(const std::string &savedir, const std::string
void Database_SQLite3::beginSave()
{
pingDatabase();
verifyDatabase();
SQLRES(sqlite3_step(m_stmt_begin), SQLITE_DONE,
"Failed to start SQLite3 transaction");
sqlite3_reset(m_stmt_begin);
@ -129,7 +129,7 @@ void Database_SQLite3::beginSave()
void Database_SQLite3::endSave()
{
pingDatabase();
verifyDatabase();
SQLRES(sqlite3_step(m_stmt_end), SQLITE_DONE,
"Failed to commit SQLite3 transaction");
sqlite3_reset(m_stmt_end);
@ -171,7 +171,7 @@ void Database_SQLite3::openDatabase()
"Failed to enable sqlite3 foreign key support");
}
void Database_SQLite3::pingDatabase()
void Database_SQLite3::verifyDatabase()
{
if (m_initialized) return;
@ -247,7 +247,7 @@ inline void MapDatabaseSQLite3::bindPos(sqlite3_stmt *stmt, const v3s16 &pos, in
bool MapDatabaseSQLite3::deleteBlock(const v3s16 &pos)
{
pingDatabase();
verifyDatabase();
bindPos(m_stmt_delete, pos);
@ -263,7 +263,7 @@ bool MapDatabaseSQLite3::deleteBlock(const v3s16 &pos)
bool MapDatabaseSQLite3::saveBlock(const v3s16 &pos, const std::string &data)
{
pingDatabase();
verifyDatabase();
#ifdef __ANDROID__
/**
@ -290,7 +290,7 @@ bool MapDatabaseSQLite3::saveBlock(const v3s16 &pos, const std::string &data)
void MapDatabaseSQLite3::loadBlock(const v3s16 &pos, std::string *block)
{
pingDatabase();
verifyDatabase();
bindPos(m_stmt_read, pos);
@ -311,7 +311,7 @@ void MapDatabaseSQLite3::loadBlock(const v3s16 &pos, std::string *block)
void MapDatabaseSQLite3::listAllLoadableBlocks(std::vector<v3s16> &dst)
{
pingDatabase();
verifyDatabase();
while (sqlite3_step(m_stmt_list) == SQLITE_ROW)
dst.push_back(getIntegerAsBlock(sqlite3_column_int64(m_stmt_list, 0)));
@ -439,7 +439,7 @@ void PlayerDatabaseSQLite3::initStatements()
bool PlayerDatabaseSQLite3::playerDataExists(const std::string &name)
{
pingDatabase();
verifyDatabase();
str_to_sqlite(m_stmt_player_load, 1, name);
bool res = (sqlite3_step(m_stmt_player_load) == SQLITE_ROW);
sqlite3_reset(m_stmt_player_load);
@ -536,7 +536,7 @@ void PlayerDatabaseSQLite3::savePlayer(RemotePlayer *player)
bool PlayerDatabaseSQLite3::loadPlayer(RemotePlayer *player, PlayerSAO *sao)
{
pingDatabase();
verifyDatabase();
str_to_sqlite(m_stmt_player_load, 1, player->getName());
if (sqlite3_step(m_stmt_player_load) != SQLITE_ROW) {
@ -600,7 +600,7 @@ bool PlayerDatabaseSQLite3::removePlayer(const std::string &name)
void PlayerDatabaseSQLite3::listPlayers(std::vector<std::string> &res)
{
pingDatabase();
verifyDatabase();
while (sqlite3_step(m_stmt_player_list) == SQLITE_ROW)
res.push_back(sqlite_to_string(m_stmt_player_list, 0));
@ -673,7 +673,7 @@ void AuthDatabaseSQLite3::initStatements()
bool AuthDatabaseSQLite3::getAuth(const std::string &name, AuthEntry &res)
{
pingDatabase();
verifyDatabase();
str_to_sqlite(m_stmt_read, 1, name);
if (sqlite3_step(m_stmt_read) != SQLITE_ROW) {
sqlite3_reset(m_stmt_read);
@ -735,7 +735,7 @@ bool AuthDatabaseSQLite3::createAuth(AuthEntry &authEntry)
bool AuthDatabaseSQLite3::deleteAuth(const std::string &name)
{
pingDatabase();
verifyDatabase();
str_to_sqlite(m_stmt_delete, 1, name);
sqlite3_vrfy(sqlite3_step(m_stmt_delete), SQLITE_DONE);
@ -749,7 +749,7 @@ bool AuthDatabaseSQLite3::deleteAuth(const std::string &name)
void AuthDatabaseSQLite3::listNames(std::vector<std::string> &res)
{
pingDatabase();
verifyDatabase();
while (sqlite3_step(m_stmt_list_names) == SQLITE_ROW) {
res.push_back(sqlite_to_string(m_stmt_list_names, 0));