Commit 6a582297 authored by jonas@perch.ndb.mysql.com's avatar jonas@perch.ndb.mysql.com

Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.1-ndb-new

into  perch.ndb.mysql.com:/home/jonas/src/51-ndb
parents ae1bb1bd 405b3ff6
...@@ -44,6 +44,8 @@ public: ...@@ -44,6 +44,8 @@ public:
static const NdbDictionary::Table* getTable(int _num); static const NdbDictionary::Table* getTable(int _num);
static int getNumTables(); static int getNumTables();
static int create_default_tablespace(Ndb* pNdb);
private: private:
static const NdbDictionary::Table* tableWithPkSize(const char* _nam, Uint32 pkSize); static const NdbDictionary::Table* tableWithPkSize(const char* _nam, Uint32 pkSize);
}; };
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <NdbSleep.h> #include <NdbSleep.h>
#include <UtilTransactions.hpp> #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_ndb(&con, dbase),
m_maxAccount(-1), m_maxAccount(-1),
m_initialized(false) m_initialized(false)
......
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
class Bank { class Bank {
public: 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 dropBank();
int performTransactions(int maxSleepBetweenTrans = 20, int yield=0); int performTransactions(int maxSleepBetweenTrans = 20, int yield=0);
...@@ -121,8 +121,8 @@ private: ...@@ -121,8 +121,8 @@ private:
int prepareReadSystemValueOp(NdbConnection*, SystemValueId sysValId, Uint64 &time); int prepareReadSystemValueOp(NdbConnection*, SystemValueId sysValId, Uint64 &time);
int prepareGetCurrTimeOp(NdbConnection*, Uint64 &time); int prepareGetCurrTimeOp(NdbConnection*, Uint64 &time);
int createTables(); int createTables(bool disk);
int createTable(const char* tabName); int createTable(const char* tabName, bool disk);
int dropTables(); int dropTables();
int dropTable(const char* tabName); int dropTable(const char* tabName);
......
...@@ -53,7 +53,7 @@ int Bank::getNumAccountTypes(){ ...@@ -53,7 +53,7 @@ int Bank::getNumAccountTypes(){
return accountTypesSize; return accountTypesSize;
} }
int Bank::createAndLoadBank(bool ovrWrt, int num_accounts){ int Bank::createAndLoadBank(bool ovrWrt, bool disk, int num_accounts){
m_ndb.init(); m_ndb.init();
if (m_ndb.waitUntilReady() != 0) if (m_ndb.waitUntilReady() != 0)
...@@ -69,7 +69,7 @@ int Bank::createAndLoadBank(bool ovrWrt, int num_accounts){ ...@@ -69,7 +69,7 @@ int Bank::createAndLoadBank(bool ovrWrt, int num_accounts){
} }
} }
if (createTables() != NDBT_OK) if (createTables(disk) != NDBT_OK)
return NDBT_FAILED; return NDBT_FAILED;
if (clearTables() != NDBT_OK) if (clearTables() != NDBT_OK)
...@@ -104,9 +104,9 @@ int Bank::dropBank(){ ...@@ -104,9 +104,9 @@ int Bank::dropBank(){
} }
int Bank::createTables(){ int Bank::createTables(bool disk){
for (int i = 0; i < tableNamesSize; i++){ 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_FAILED;
} }
return NDBT_OK; return NDBT_OK;
...@@ -136,7 +136,7 @@ int Bank::clearTable(const char* tabName){ ...@@ -136,7 +136,7 @@ int Bank::clearTable(const char* tabName){
return NDBT_OK; return NDBT_OK;
} }
int Bank::createTable(const char* tabName){ int Bank::createTable(const char* tabName, bool disk){
ndbout << "createTable " << tabName << endl; ndbout << "createTable " << tabName << endl;
const NdbDictionary::Table* pTab = NDBT_Tables::getTable(tabName); const NdbDictionary::Table* pTab = NDBT_Tables::getTable(tabName);
...@@ -146,7 +146,8 @@ int Bank::createTable(const char* tabName){ ...@@ -146,7 +146,8 @@ int Bank::createTable(const char* tabName){
const NdbDictionary::Table* org = const NdbDictionary::Table* org =
m_ndb.getDictionary()->getTable(tabName); m_ndb.getDictionary()->getTable(tabName);
if (org != 0 && pTab->equal(* org)){ if (org != 0 && (disk || pTab->equal(* org)))
{
return NDBT_OK; return NDBT_OK;
} }
...@@ -155,11 +156,31 @@ int Bank::createTable(const char* tabName){ ...@@ -155,11 +156,31 @@ int Bank::createTable(const char* tabName){
return NDBT_FAILED; 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){ if(m_ndb.getDictionary()->createTable(* pTab) == -1){
ndbout << "Failed to create table: " << ndbout << "Failed to create table: " <<
m_ndb.getNdbError() << endl; m_ndb.getNdbError() << endl;
return NDBT_FAILED; return NDBT_FAILED;
} }
}
return NDBT_OK; return NDBT_OK;
} }
......
...@@ -30,9 +30,11 @@ int main(int argc, const char** argv){ ...@@ -30,9 +30,11 @@ int main(int argc, const char** argv){
ndb_init(); ndb_init();
int _help = 0; int _help = 0;
char * _database = "BANK"; char * _database = "BANK";
int disk = 0;
struct getargs args[] = { struct getargs args[] = {
{ "database", 'd', arg_string, &_database, "Database name", ""}, { "database", 'd', arg_string, &_database, "Database name", ""},
{ "disk", 0, arg_flag, &disk, "Use disk tables", "" },
{ "usage", '?', arg_flag, &_help, "Print help", "" } { "usage", '?', arg_flag, &_help, "Print help", "" }
}; };
int num_args = sizeof(args) / sizeof(args[0]); int num_args = sizeof(args) / sizeof(args[0]);
...@@ -53,7 +55,7 @@ int main(int argc, const char** argv){ ...@@ -53,7 +55,7 @@ int main(int argc, const char** argv){
Bank bank(con,_database); Bank bank(con,_database);
int overWriteExisting = true; 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_FAILED);
return NDBT_ProgramExit(NDBT_OK); return NDBT_ProgramExit(NDBT_OK);
......
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
#include "Bank.hpp" #include "Bank.hpp"
const char* _database = "BANK";
int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){ int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){
char * _database = "BANK";
Bank bank(ctx->m_cluster_connection, _database); Bank bank(ctx->m_cluster_connection, _database);
int overWriteExisting = true; int overWriteExisting = true;
if (bank.createAndLoadBank(overWriteExisting) != NDBT_OK) if (bank.createAndLoadBank(overWriteExisting) != NDBT_OK)
...@@ -41,7 +42,6 @@ int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -41,7 +42,6 @@ int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){
} }
int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){ int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){
char * _database = "BANK";
Bank bank(ctx->m_cluster_connection, _database); Bank bank(ctx->m_cluster_connection, _database);
int wait = 30; // Max seconds between each "day" int wait = 30; // Max seconds between each "day"
int yield = 1; // Loops before bank returns int yield = 1; // Loops before bank returns
...@@ -53,7 +53,6 @@ int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -53,7 +53,6 @@ int runBankTimer(NDBT_Context* ctx, NDBT_Step* step){
} }
int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){ int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){
char * _database = "BANK";
Bank bank(ctx->m_cluster_connection, _database); Bank bank(ctx->m_cluster_connection, _database);
int wait = 10; // Max ms between each transaction int wait = 10; // Max ms between each transaction
int yield = 100; // Loops before bank returns int yield = 100; // Loops before bank returns
...@@ -65,7 +64,6 @@ int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -65,7 +64,6 @@ int runBankTransactions(NDBT_Context* ctx, NDBT_Step* step){
} }
int runBankGL(NDBT_Context* ctx, NDBT_Step* step){ int runBankGL(NDBT_Context* ctx, NDBT_Step* step){
char * _database = "BANK";
Bank bank(ctx->m_cluster_connection, _database); Bank bank(ctx->m_cluster_connection, _database);
int yield = 20; // Loops before bank returns int yield = 20; // Loops before bank returns
int result = NDBT_OK; int result = NDBT_OK;
...@@ -80,7 +78,6 @@ int runBankGL(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -80,7 +78,6 @@ int runBankGL(NDBT_Context* ctx, NDBT_Step* step){
} }
int runBankSum(NDBT_Context* ctx, NDBT_Step* step){ int runBankSum(NDBT_Context* ctx, NDBT_Step* step){
char * _database = "BANK";
Bank bank(ctx->m_cluster_connection, _database); Bank bank(ctx->m_cluster_connection, _database);
int wait = 2000; // Max ms between each sum of accounts int wait = 2000; // Max ms between each sum of accounts
int yield = 1; // Loops before bank returns int yield = 1; // Loops before bank returns
...@@ -96,7 +93,6 @@ int runBankSum(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -96,7 +93,6 @@ int runBankSum(NDBT_Context* ctx, NDBT_Step* step){
} }
int runDropBank(NDBT_Context* ctx, NDBT_Step* step){ int runDropBank(NDBT_Context* ctx, NDBT_Step* step){
char * _database = "BANK";
Bank bank(ctx->m_cluster_connection, _database); Bank bank(ctx->m_cluster_connection, _database);
if (bank.dropBank() != NDBT_OK) if (bank.dropBank() != NDBT_OK)
return NDBT_FAILED; return NDBT_FAILED;
......
...@@ -22,10 +22,12 @@ ...@@ -22,10 +22,12 @@
#include "bank/Bank.hpp" #include "bank/Bank.hpp"
bool disk = false;
int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){ int runCreateBank(NDBT_Context* ctx, NDBT_Step* step){
Bank bank(ctx->m_cluster_connection); Bank bank(ctx->m_cluster_connection);
int overWriteExisting = true; int overWriteExisting = true;
if (bank.createAndLoadBank(overWriteExisting, 10) != NDBT_OK) if (bank.createAndLoadBank(overWriteExisting, disk, 10) != NDBT_OK)
return NDBT_FAILED; return NDBT_FAILED;
return NDBT_OK; return NDBT_OK;
} }
...@@ -406,8 +408,20 @@ TESTCASE("Mix", ...@@ -406,8 +408,20 @@ TESTCASE("Mix",
} }
NDBT_TESTSUITE_END(testSRBank); NDBT_TESTSUITE_END(testSRBank);
int main(int argc, const char** argv){ int
main(int argc, const char** argv){
ndb_init(); 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); return testSRBank.execute(argc, argv);
} }
......
...@@ -848,9 +848,8 @@ NDBT_Tables::createAllTables(Ndb* pNdb){ ...@@ -848,9 +848,8 @@ NDBT_Tables::createAllTables(Ndb* pNdb){
return createAllTables(pNdb, false); return createAllTables(pNdb, false);
} }
static
int int
create_default_tablespace(Ndb* pNdb) NDBT_Tables::create_default_tablespace(Ndb* pNdb)
{ {
NdbDictionary::Dictionary* pDict = pNdb->getDictionary(); NdbDictionary::Dictionary* pDict = pNdb->getDictionary();
......
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