mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Add ripple_db module
This commit is contained in:
@@ -12,8 +12,6 @@
|
||||
#include "../ripple/JobQueue.h"
|
||||
#include "../ripple/Log.h"
|
||||
|
||||
SETUP_NLOG("DataBase");
|
||||
|
||||
using namespace std;
|
||||
|
||||
SqliteDatabase::SqliteDatabase(const char* host) : Database(host,"",""), mWalQ(NULL), walRunning(false)
|
||||
@@ -28,7 +26,7 @@ void SqliteDatabase::connect()
|
||||
int rc = sqlite3_open(mHost.c_str(), &mConnection);
|
||||
if (rc)
|
||||
{
|
||||
cLog(lsFATAL) << "Can't open " << mHost << " " << rc;
|
||||
WriteLog (lsFATAL, SqliteDatabase) << "Can't open " << mHost << " " << rc;
|
||||
sqlite3_close(mConnection);
|
||||
assert((rc != SQLITE_BUSY) && (rc != SQLITE_LOCKED));
|
||||
}
|
||||
@@ -42,7 +40,7 @@ sqlite3* SqliteDatabase::getAuxConnection()
|
||||
int rc = sqlite3_open(mHost.c_str(), &mAuxConnection);
|
||||
if (rc)
|
||||
{
|
||||
cLog(lsFATAL) << "Can't aux open " << mHost << " " << rc;
|
||||
WriteLog (lsFATAL, SqliteDatabase) << "Can't aux open " << mHost << " " << rc;
|
||||
assert((rc != SQLITE_BUSY) && (rc != SQLITE_LOCKED));
|
||||
if (mAuxConnection != NULL)
|
||||
{
|
||||
@@ -78,9 +76,9 @@ bool SqliteDatabase::executeSQL(const char* sql, bool fail_ok)
|
||||
if (!fail_ok)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
cLog(lsWARNING) << "Perror:" << mHost << ": " << rc;
|
||||
cLog(lsWARNING) << "Statement: " << sql;
|
||||
cLog(lsWARNING) << "Error: " << sqlite3_errmsg(mConnection);
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Perror:" << mHost << ": " << rc;
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql;
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg(mConnection);
|
||||
#endif
|
||||
}
|
||||
endIterRows();
|
||||
@@ -100,7 +98,7 @@ bool SqliteDatabase::executeSQL(const char* sql, bool fail_ok)
|
||||
{
|
||||
if ((rc != SQLITE_BUSY) && (rc != SQLITE_LOCKED))
|
||||
{
|
||||
cLog(lsFATAL) << mHost << " returns error " << rc << ": " << sqlite3_errmsg(mConnection);
|
||||
WriteLog (lsFATAL, SqliteDatabase) << mHost << " returns error " << rc << ": " << sqlite3_errmsg(mConnection);
|
||||
assert(false);
|
||||
}
|
||||
mMoreRows = false;
|
||||
@@ -108,9 +106,9 @@ bool SqliteDatabase::executeSQL(const char* sql, bool fail_ok)
|
||||
if (!fail_ok)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
cLog(lsWARNING) << "SQL Serror:" << mHost << ": " << rc;
|
||||
cLog(lsWARNING) << "Statement: " << sql;
|
||||
cLog(lsWARNING) << "Error: " << sqlite3_errmsg(mConnection);
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "SQL Serror:" << mHost << ": " << rc;
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql;
|
||||
WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg(mConnection);
|
||||
#endif
|
||||
}
|
||||
endIterRows();
|
||||
@@ -127,6 +125,7 @@ int SqliteDatabase::getNumRowsAffected()
|
||||
return(0);
|
||||
}
|
||||
|
||||
// VFALCO: TODO, This must be fixed!!! return value needs to be int64
|
||||
int SqliteDatabase::getLastInsertID()
|
||||
{
|
||||
return(sqlite3_last_insert_rowid(mConnection));
|
||||
@@ -164,7 +163,7 @@ bool SqliteDatabase::getNextRow(bool finalize)
|
||||
if (rc==SQLITE_ROW)
|
||||
return(true);
|
||||
assert((rc != SQLITE_BUSY) && (rc != SQLITE_LOCKED));
|
||||
tLog((rc != SQLITE_DONE), lsWARNING) << "Rerror: " << mHost << ": " << rc;
|
||||
CondLog ((rc != SQLITE_DONE), lsWARNING, SqliteDatabase) << "Rerror: " << mHost << ": " << rc;
|
||||
}
|
||||
|
||||
if (finalize)
|
||||
@@ -272,11 +271,11 @@ void SqliteDatabase::runWal()
|
||||
int ret = sqlite3_wal_checkpoint_v2(mConnection, NULL, SQLITE_CHECKPOINT_PASSIVE, &log, &ckpt);
|
||||
if (ret != SQLITE_OK)
|
||||
{
|
||||
cLog((ret == SQLITE_LOCKED) ? lsTRACE : lsWARNING) << "WAL("
|
||||
WriteLog ((ret == SQLITE_LOCKED) ? lsTRACE : lsWARNING, SqliteDatabase) << "WAL("
|
||||
<< sqlite3_db_filename(mConnection, "main") << "): error " << ret;
|
||||
}
|
||||
else
|
||||
cLog(lsTRACE) << "WAL(" << sqlite3_db_filename(mConnection, "main") <<
|
||||
WriteLog (lsTRACE, SqliteDatabase) << "WAL(" << sqlite3_db_filename(mConnection, "main") <<
|
||||
"): frames=" << log << ", written=" << ckpt;
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user