Commit 5e85c850 authored by unknown's avatar unknown

DbUtil.hpp, DbUtil.cpp, NdbRepStress.cpp:

  More code improvments


storage/ndb/test/include/DbUtil.hpp:
  More code improvments
storage/ndb/test/src/DbUtil.cpp:
  More code improvments
storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp:
  More code improvments
parent 0f5cf864
...@@ -90,9 +90,10 @@ public: ...@@ -90,9 +90,10 @@ public:
int connect(); int connect();
int selectDb(); int selectDb();
int selectDb(const char * m_db); int selectDb(const char *);
int doQuery(char * stm); int createDb(BaseString&);
int doQuery(const char * stm); int doQuery(BaseString&);
int doQuery(const char *);
int getErrorNumber(); int getErrorNumber();
unsigned long selectCountTable(const char * table); unsigned long selectCountTable(const char * table);
......
...@@ -99,6 +99,7 @@ DbUtil::databaseLogin(const char* system, const char* usr, ...@@ -99,6 +99,7 @@ DbUtil::databaseLogin(const char* system, const char* usr,
mysql_get_server_info(mysql), mysql_get_server_info(mysql),
(unsigned long) mysql_get_server_version(mysql)); (unsigned long) mysql_get_server_version(mysql));
#endif #endif
this->selectDb();
} }
/* Database Connect */ /* Database Connect */
...@@ -132,7 +133,7 @@ DbUtil::connect() ...@@ -132,7 +133,7 @@ DbUtil::connect()
mysql_close(mysql); mysql_close(mysql);
return DBU_FAILED; return DBU_FAILED;
} }
this->selectDb();
m_connected = true; m_connected = true;
return DBU_OK; return DBU_OK;
} }
...@@ -243,15 +244,32 @@ DbUtil::selectDb(const char * m_db) ...@@ -243,15 +244,32 @@ DbUtil::selectDb(const char * m_db)
} }
} }
int
DbUtil::createDb(BaseString& m_db)
{
BaseString stm;
{
if(mysql_select_db(this->getMysql(), m_db.c_str()) == DBU_OK)
{
stm.assfmt("DROP DATABASE %s", m_db.c_str());
if(this->doQuery(m_db.c_str()) == DBU_FAILED)
return DBU_FAILED;
}
stm.assfmt("CREATE DATABASE %s", m_db.c_str());
if(this->doQuery(m_db.c_str()) == DBU_FAILED)
return DBU_FAILED;
return DBU_OK;
}
}
/* Run Simple Queries */ /* Run Simple Queries */
int int
DbUtil::doQuery(char * stm) DbUtil::doQuery(BaseString& str)
{ {
if(mysql_query(this->getMysql(), stm)) if(mysql_query(this->getMysql(), str.c_str()))
{ {
this->printError(stm); this->printError(str.c_str());
return DBU_FAILED; return DBU_FAILED;
} }
return DBU_OK; return DBU_OK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment