mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.1-ndb-new
into eel.(none):/home/jonas/src/51-ndb
This commit is contained in:
commit
f8b6c2dd20
8 changed files with 62 additions and 28 deletions
|
@ -44,6 +44,8 @@ public:
|
|||
static const NdbDictionary::Table* getTable(int _num);
|
||||
static int getNumTables();
|
||||
|
||||
static int create_default_tablespace(Ndb* pNdb);
|
||||
|
||||
private:
|
||||
static const NdbDictionary::Table* tableWithPkSize(const char* _nam, Uint32 pkSize);
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <NdbSleep.h>
|
||||
#include <UtilTransactions.hpp>
|
||||
|
||||
Bank::Bank(Ndb_cluster_connection& con, bool _init, char * dbase):
|
||||
Bank::Bank(Ndb_cluster_connection& con, bool _init, const char * dbase):
|
||||
m_ndb(&con, dbase),
|
||||
m_maxAccount(-1),
|
||||
m_initialized(false)
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
class Bank {
|
||||
public:
|
||||
|
||||
Bank(Ndb_cluster_connection&, bool init = true, char *dbase="BANK");
|
||||
Bank(Ndb_cluster_connection&, bool init = true, const char *dbase="BANK");
|
||||
|
||||
int createAndLoadBank(bool overWrite, int num_accounts=10);
|
||||
int createAndLoadBank(bool overWrite, bool disk= false, int num_accounts=10);
|
||||
int dropBank();
|
||||
|
||||
int performTransactions(int maxSleepBetweenTrans = 20, int yield=0);
|
||||
|
@ -121,8 +121,8 @@ private:
|
|||
int prepareReadSystemValueOp(NdbConnection*, SystemValueId sysValId, Uint64 &time);
|
||||
int prepareGetCurrTimeOp(NdbConnection*, Uint64 &time);
|
||||
|
||||
int createTables();
|
||||
int createTable(const char* tabName);
|
||||
int createTables(bool disk);
|
||||
int createTable(const char* tabName, bool disk);
|
||||
|
||||
int dropTables();
|
||||
int dropTable(const char* tabName);
|
||||
|
|
|
@ -53,7 +53,7 @@ int Bank::getNumAccountTypes(){
|
|||
return accountTypesSize;
|
||||
}
|
||||
|
||||
int Bank::createAndLoadBank(bool ovrWrt, int num_accounts){
|
||||
int Bank::createAndLoadBank(bool ovrWrt, bool disk, int num_accounts){
|
||||
|
||||
m_ndb.init();
|
||||
if (m_ndb.waitUntilReady() != 0)
|
||||
|
@ -69,7 +69,7 @@ int Bank::createAndLoadBank(bool ovrWrt, int num_accounts){
|
|||
}
|
||||
}
|
||||
|
||||
if (createTables() != NDBT_OK)
|
||||
if (createTables(disk) != NDBT_OK)
|
||||
return NDBT_FAILED;
|
||||
|
||||
if (clearTables() != NDBT_OK)
|
||||
|
@ -104,9 +104,9 @@ int Bank::dropBank(){
|
|||
|
||||
}
|
||||
|
||||
int Bank::createTables(){
|
||||
int Bank::createTables(bool disk){
|
||||
for (int i = 0; i < tableNamesSize; i++){
|
||||
if (createTable(tableNames[i]) != NDBT_OK)
|
||||
if (createTable(tableNames[i], disk) != NDBT_OK)
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
return NDBT_OK;
|
||||
|
@ -136,7 +136,7 @@ int Bank::clearTable(const char* tabName){
|
|||
return NDBT_OK;
|
||||
}
|
||||
|
||||
int Bank::createTable(const char* tabName){
|
||||
int Bank::createTable(const char* tabName, bool disk){
|
||||
ndbout << "createTable " << tabName << endl;
|
||||
|
||||
const NdbDictionary::Table* pTab = NDBT_Tables::getTable(tabName);
|
||||
|
@ -146,7 +146,8 @@ int Bank::createTable(const char* tabName){
|
|||
const NdbDictionary::Table* org =
|
||||
m_ndb.getDictionary()->getTable(tabName);
|
||||
|
||||
if (org != 0 && pTab->equal(* org)){
|
||||
if (org != 0 && (disk || pTab->equal(* org)))
|
||||
{
|
||||
return NDBT_OK;
|
||||
}
|
||||
|
||||
|
@ -154,11 +155,31 @@ int Bank::createTable(const char* tabName){
|
|||
ndbout << "Different table with same name exists" << endl;
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
|
||||
if(m_ndb.getDictionary()->createTable(* pTab) == -1){
|
||||
ndbout << "Failed to create table: " <<
|
||||
m_ndb.getNdbError() << endl;
|
||||
return NDBT_FAILED;
|
||||
|
||||
if (disk)
|
||||
{
|
||||
if (NDBT_Tables::create_default_tablespace(&m_ndb))
|
||||
{
|
||||
ndbout << "Failed to create tablespaces" << endl;
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
NdbDictionary::Table copy(* pTab);
|
||||
copy.setTablespace("DEFAULT-TS");
|
||||
for (Uint32 i = 0; i<copy.getNoOfColumns(); i++)
|
||||
copy.getColumn(i)->setStorageType(NdbDictionary::Column::StorageTypeDisk);
|
||||
if(m_ndb.getDictionary()->createTable(copy) == -1){
|
||||
ndbout << "Failed to create table: " <<
|
||||
m_ndb.getNdbError() << endl;
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_ndb.getDictionary()->createTable(* pTab) == -1){
|
||||
ndbout << "Failed to create table: " <<
|
||||
m_ndb.getNdbError() << endl;
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
return NDBT_OK;
|
||||
|
|
|
@ -30,9 +30,11 @@ int main(int argc, const char** argv){
|
|||
ndb_init();
|
||||
int _help = 0;
|
||||
char * _database = "BANK";
|
||||
|
||||
int disk = 0;
|
||||
|
||||
struct getargs args[] = {
|
||||
{ "database", 'd', arg_string, &_database, "Database name", ""},
|
||||
{ "disk", 0, arg_flag, &disk, "Use disk tables", "" },
|
||||
{ "usage", '?', arg_flag, &_help, "Print help", "" }
|
||||
};
|
||||
int num_args = sizeof(args) / sizeof(args[0]);
|
||||
|
@ -53,7 +55,7 @@ int main(int argc, const char** argv){
|
|||
|
||||
Bank bank(con,_database);
|
||||
int overWriteExisting = true;
|
||||
if (bank.createAndLoadBank(overWriteExisting) != NDBT_OK)
|
||||
if (bank.createAndLoadBank(overWriteExisting, disk) != NDBT_OK)
|
||||
return NDBT_ProgramExit(NDBT_FAILED);
|
||||
return NDBT_ProgramExit(NDBT_OK);
|
||||
|
||||
|
|
|
@ -31,8 +31,9 @@
|
|||
|
||||
#include "Bank.hpp"
|
||||
|
||||
const char* _database = "BANK";
|
||||
|
||||
int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){
|
||||
char * _database = "BANK";
|
||||
Bank bank(ctx->m_cluster_connection, _database);
|
||||
int overWriteExisting = true;
|
||||
if (bank.createAndLoadBank(overWriteExisting) != NDBT_OK)
|
||||
|
@ -41,7 +42,6 @@ int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){
|
|||
}
|
||||
|
||||
int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){
|
||||
char * _database = "BANK";
|
||||
Bank bank(ctx->m_cluster_connection, _database);
|
||||
int wait = 30; // Max seconds between each "day"
|
||||
int yield = 1; // Loops before bank returns
|
||||
|
@ -53,7 +53,6 @@ int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){
|
|||
}
|
||||
|
||||
int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){
|
||||
char * _database = "BANK";
|
||||
Bank bank(ctx->m_cluster_connection, _database);
|
||||
int wait = 10; // Max ms between each transaction
|
||||
int yield = 100; // Loops before bank returns
|
||||
|
@ -65,7 +64,6 @@ int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){
|
|||
}
|
||||
|
||||
int runBankGL(NDBT_Context* ctx, NDBT_Step* step){
|
||||
char * _database = "BANK";
|
||||
Bank bank(ctx->m_cluster_connection, _database);
|
||||
int yield = 20; // Loops before bank returns
|
||||
int result = NDBT_OK;
|
||||
|
@ -80,7 +78,6 @@ int runBankGL(NDBT_Context* ctx, NDBT_Step* step){
|
|||
}
|
||||
|
||||
int runBankSum(NDBT_Context* ctx, NDBT_Step* step){
|
||||
char * _database = "BANK";
|
||||
Bank bank(ctx->m_cluster_connection, _database);
|
||||
int wait = 2000; // Max ms between each sum of accounts
|
||||
int yield = 1; // Loops before bank returns
|
||||
|
@ -96,7 +93,6 @@ int runBankSum(NDBT_Context* ctx, NDBT_Step* step){
|
|||
}
|
||||
|
||||
int runDropBank(NDBT_Context* ctx, NDBT_Step* step){
|
||||
char * _database = "BANK";
|
||||
Bank bank(ctx->m_cluster_connection, _database);
|
||||
if (bank.dropBank() != NDBT_OK)
|
||||
return NDBT_FAILED;
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
|
||||
#include "bank/Bank.hpp"
|
||||
|
||||
bool disk = false;
|
||||
|
||||
int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){
|
||||
Bank bank(ctx->m_cluster_connection);
|
||||
int overWriteExisting = true;
|
||||
if (bank.createAndLoadBank(overWriteExisting, 10) != NDBT_OK)
|
||||
if (bank.createAndLoadBank(overWriteExisting, disk, 10) != NDBT_OK)
|
||||
return NDBT_FAILED;
|
||||
return NDBT_OK;
|
||||
}
|
||||
|
@ -406,8 +408,20 @@ TESTCASE("Mix",
|
|||
}
|
||||
NDBT_TESTSUITE_END(testSRBank);
|
||||
|
||||
int main(int argc, const char** argv){
|
||||
int
|
||||
main(int argc, const char** argv){
|
||||
ndb_init();
|
||||
for (int i = 0; i<argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "--disk") == 0)
|
||||
{
|
||||
argc--;
|
||||
disk = true;
|
||||
for (; i<argc; i++)
|
||||
argv[i] = argv[i+1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return testSRBank.execute(argc, argv);
|
||||
}
|
||||
|
||||
|
|
|
@ -848,9 +848,8 @@ NDBT_Tables::createAllTables(Ndb* pNdb){
|
|||
return createAllTables(pNdb, false);
|
||||
}
|
||||
|
||||
static
|
||||
int
|
||||
create_default_tablespace(Ndb* pNdb)
|
||||
NDBT_Tables::create_default_tablespace(Ndb* pNdb)
|
||||
{
|
||||
NdbDictionary::Dictionary* pDict = pNdb->getDictionary();
|
||||
|
||||
|
|
Loading…
Reference in a new issue