Skip to content

Commit

Permalink
(dbserver): cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
vpashka committed Jan 6, 2024
1 parent ccd3a65 commit 3f4304a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 42 deletions.
3 changes: 1 addition & 2 deletions extensions/DBServer-MySQL/DBServer_MySQL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,7 @@ std::shared_ptr<DBServer_MySQL> DBServer_MySQL::init_dbserver( int argc, const c

if( !name.empty() )
{
ObjectId ID = conf->getServiceID(name);

ID = conf->getServiceID(name);
if( ID == uniset3::DefaultObjectId )
{
cerr << "(DBServer_MySQL): Unknown ServiceID for '" << name << endl;
Expand Down
3 changes: 1 addition & 2 deletions extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ std::shared_ptr<DBServer_PostgreSQL> DBServer_PostgreSQL::init_dbserver( int arg

if( !name.empty() )
{
ObjectId ID = conf->getServiceID(name);

ID = conf->getServiceID(name);
if( ID == uniset3::DefaultObjectId )
{
cerr << "(DBServer_PostgreSQL): Unknown ServiceID for '" << name << endl;
Expand Down
36 changes: 1 addition & 35 deletions extensions/DBServer-SQLite/DBServer_SQLite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,11 @@
* \author Pavel Vainerman
*/
// --------------------------------------------------------------------------
#include <sys/time.h>
#include <sstream>
#include <iomanip>
#include <cmath>

#include "unisetstd.h"
#include "DBServer_SQLite.h"
#include "Configuration.h"
#include "Debug.h"
#include "UniXML.h"
#include "DBLogSugar.h"
// --------------------------------------------------------------------------
using namespace uniset3;
Expand Down Expand Up @@ -306,40 +301,11 @@ void DBServer_SQLite::initDBServer()
connect_ok = true;
askTimer(DBServer_SQLite::ReconnectTimer, 0);
askTimer(DBServer_SQLite::PingTimer, PingTime);
// createTables(db);
initDB(db);
flushBuffer();
}
}
//--------------------------------------------------------------------------------------------
void DBServer_SQLite::createTables( SQLiteInterface* db )
{
auto conf = uniset_conf();
UniXML::iterator it( conf->getNode("Tables") );

if(!it)
{
dbcrit << myname << ": section <Tables> not found.." << endl;
throw Exception();
}

if( !it.goChildren() )
return;

for( ; it; it.goNext() )
{
if( it.getName() != "comment" )
{
dbinfo << myname << "(createTables): create " << it.getName() << endl;
ostringstream query;
query << "CREATE TABLE " << conf->getProp(it, "name") << "(" << conf->getProp(it, "create") << ")";

if( !db->query(query.str()) )
dbcrit << myname << "(createTables): error: \t\t" << db->error() << endl;
}
}
}
//--------------------------------------------------------------------------------------------
void DBServer_SQLite::timerInfo( const uniset3::umessage::TimerMessage* tm )
{
DBServer::timerInfo(tm);
Expand Down Expand Up @@ -402,7 +368,7 @@ std::shared_ptr<DBServer_SQLite> DBServer_SQLite::init_dbserver( int argc, const

if( !name.empty() )
{
ObjectId ID = conf->getServiceID(name);
ID = conf->getServiceID(name);

if( ID == uniset3::DefaultObjectId )
{
Expand Down
3 changes: 0 additions & 3 deletions extensions/DBServer-SQLite/DBServer_SQLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ namespace uniset3
}

protected:
typedef std::unordered_map<int, std::string> DBTableMap;

virtual void initDBServer() override;
virtual void initDB( const std::unique_ptr<SQLiteInterface>& db ) {};

Expand All @@ -186,7 +184,6 @@ namespace uniset3
virtual std::string getMonitInfo( const std::string& params ) override;

bool writeToBase( const std::string& query );
void createTables( SQLiteInterface* db );

enum Timers
{
Expand Down

0 comments on commit 3f4304a

Please sign in to comment.