Commit 3add897e authored by unknown's avatar unknown

changed to using NdbTransaction scoped enums

and removed usage of Ndb::waitUntilReady()

parent ae736acf
......@@ -381,7 +381,7 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
}
/*Prepare transaction (the transaction is NOT yet sent to NDB)*/
transaction[current].conn->executeAsynchPrepare(Commit,
transaction[current].conn->executeAsynchPrepare(NdbTransaction::Commit,
&callback,
cb);
/**
......
......@@ -99,7 +99,8 @@ int main()
myNdbOperation->setValue("ATTR2", 20 + i);
// Prepare transaction (the transaction is NOT yet sent to NDB)
myNdbTransaction[i]->executeAsynchPrepare(Commit, &callback, NULL);
myNdbTransaction[i]->executeAsynchPrepare(NdbTransaction::Commit,
&callback, NULL);
}
// Send all transactions to NDB
......
......@@ -104,7 +104,7 @@ int insert(int transactionId, NdbTransaction* myTransaction) {
exit(-1);
}
return myTransaction->execute(NoCommit);
return myTransaction->execute(NdbTransaction::NoCommit);
}
......@@ -131,7 +131,7 @@ int executeInsertTransaction(int transactionId, Ndb* myNdb) {
result = -1; // Failure
} else if (insert(transactionId, myTransaction) ||
insert(10000+transactionId, myTransaction) ||
myTransaction->execute(Commit)) {
myTransaction->execute(NdbTransaction::Commit)) {
TRANSERROR(myTransaction);
ndberror = myTransaction->getNdbError();
result = -1; // Failure
......
......@@ -187,7 +187,7 @@ int populate(Ndb * myNdb)
myNdbOperation->setValue("COLOR", cars[i].color);
}
int check = myTrans->execute(Commit);
int check = myTrans->execute(NdbTransaction::Commit);
myTrans->close();
......@@ -280,7 +280,7 @@ int scan_delete(Ndb* myNdb,
/**
* Start scan (NoCommit since we are only reading at this stage);
*/
if(myTrans->execute(NoCommit) != 0){
if(myTrans->execute(NdbTransaction::NoCommit) != 0){
err = myTrans->getNdbError();
if(err.status == NdbError::TemporaryError){
std::cout << myTrans->getNdbError().message << std::endl;
......@@ -322,7 +322,7 @@ int scan_delete(Ndb* myNdb,
*/
if(check != -1)
{
check = myTrans->execute(Commit);
check = myTrans->execute(NdbTransaction::Commit);
}
if(check == -1)
......@@ -453,7 +453,7 @@ int scan_update(Ndb* myNdb,
/**
* Start scan (NoCommit since we are only reading at this stage);
*/
if(myTrans->execute(NoCommit) != 0)
if(myTrans->execute(NdbTransaction::NoCommit) != 0)
{
err = myTrans->getNdbError();
if(err.status == NdbError::TemporaryError){
......@@ -501,7 +501,7 @@ int scan_update(Ndb* myNdb,
*/
if(check != -1)
{
check = myTrans->execute(NoCommit);
check = myTrans->execute(NdbTransaction::NoCommit);
}
/**
......@@ -525,7 +525,7 @@ int scan_update(Ndb* myNdb,
/**
* Commit all prepared operations
*/
if(myTrans->execute(Commit) == -1)
if(myTrans->execute(NdbTransaction::Commit) == -1)
{
if(err.status == NdbError::TemporaryError){
std::cout << myTrans->getNdbError().message << std::endl;
......@@ -640,7 +640,7 @@ int scan_print(Ndb * myNdb)
/**
* Start scan (NoCommit since we are only reading at this stage);
*/
if(myTrans->execute(NoCommit) != 0){
if(myTrans->execute(NdbTransaction::NoCommit) != 0){
err = myTrans->getNdbError();
if(err.status == NdbError::TemporaryError){
std::cout << myTrans->getNdbError().message << std::endl;
......
......@@ -170,7 +170,7 @@ static void do_insert(Ndb &myNdb)
myOperation->equal("ATTR1", i+5);
myOperation->setValue("ATTR2", i+5);
if (myTransaction->execute( Commit ) == -1)
if (myTransaction->execute( NdbTransaction::Commit ) == -1)
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
......@@ -193,7 +193,7 @@ static void do_update(Ndb &myNdb)
myOperation->equal( "ATTR1", i );
myOperation->setValue( "ATTR2", i+10);
if( myTransaction->execute( Commit ) == -1 )
if( myTransaction->execute( NdbTransaction::Commit ) == -1 )
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
......@@ -214,7 +214,7 @@ static void do_delete(Ndb &myNdb)
myOperation->deleteTuple();
myOperation->equal( "ATTR1", 3 );
if (myTransaction->execute(Commit) == -1)
if (myTransaction->execute(NdbTransaction::Commit) == -1)
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
......@@ -240,7 +240,7 @@ static void do_read(Ndb &myNdb)
NdbRecAttr *myRecAttr= myOperation->getValue("ATTR2", NULL);
if (myRecAttr == NULL) APIERROR(myTransaction->getNdbError());
if(myTransaction->execute( Commit ) == -1)
if(myTransaction->execute( NdbTransaction::Commit ) == -1)
if (i == 3) {
std::cout << "Detected that deleted tuple doesn't exist!" << std::endl;
} else {
......
......@@ -127,7 +127,7 @@ int main()
myOperation->equal("ATTR1", i+5);
myOperation->setValue("ATTR2", i+5);
if (myTransaction->execute( Commit ) == -1)
if (myTransaction->execute( NdbTransaction::Commit ) == -1)
APIERROR(myTransaction->getNdbError());
myNdb->closeTransaction(myTransaction);
......@@ -152,7 +152,7 @@ int main()
NdbRecAttr *myRecAttr= myIndexOperation->getValue("ATTR1", NULL);
if (myRecAttr == NULL) APIERROR(myTransaction->getNdbError());
if(myTransaction->execute( Commit ) != -1)
if(myTransaction->execute( NdbTransaction::Commit ) != -1)
printf(" %2d %2d\n", myRecAttr->u_32_value(), i);
myNdb->closeTransaction(myTransaction);
......@@ -173,7 +173,7 @@ int main()
myIndexOperation->equal( "ATTR2", i );
myIndexOperation->setValue( "ATTR2", i+10);
if( myTransaction->execute( Commit ) == -1 )
if( myTransaction->execute( NdbTransaction::Commit ) == -1 )
APIERROR(myTransaction->getNdbError());
myNdb->closeTransaction(myTransaction);
......@@ -193,7 +193,7 @@ int main()
myIndexOperation->deleteTuple();
myIndexOperation->equal( "ATTR2", 3 );
if (myTransaction->execute(Commit) == -1)
if (myTransaction->execute(NdbTransaction::Commit) == -1)
APIERROR(myTransaction->getNdbError());
myNdb->closeTransaction(myTransaction);
......@@ -218,7 +218,7 @@ int main()
NdbRecAttr *myRecAttr= myOperation->getValue("ATTR2", NULL);
if (myRecAttr == NULL) APIERROR(myTransaction->getNdbError());
if(myTransaction->execute( Commit ) == -1)
if(myTransaction->execute( NdbTransaction::Commit ) == -1)
if (i == 3) {
std::cout << "Detected that deleted tuple doesn't exist!\n";
} else {
......
......@@ -698,7 +698,7 @@ public:
/** @} *******************************************************************/
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
void setStoredTable(bool x) { setLogging(x); }
bool getStoredTable() const { return getLogging(); }
......@@ -1010,6 +1010,8 @@ public:
* Fetch list of all objects, optionally restricted to given type.
*/
int listObjects(List & list, Object::Type type = Object::TypeUndefined);
int listObjects(const List & list,
Object::Type type = Object::TypeUndefined) const;
/**
* Get the latest error
......@@ -1048,6 +1050,7 @@ public:
* @return 0 if successful, otherwise -1
*/
int listIndexes(List & list, const char * tableName);
int listIndexes(const List & list, const char * tableName) const;
/** @} *******************************************************************/
/**
......
......@@ -42,7 +42,7 @@ class NdbBlob;
typedef void (* NdbAsynchCallback)(int, NdbTransaction*, void*);
#endif
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
enum AbortOption {
CommitIfFailFree= 0,
TryCommit= 0,
......
......@@ -823,6 +823,13 @@ NdbDictionary::Dictionary::listObjects(List& list, Object::Type type)
return m_impl.listObjects(list, type);
}
int
NdbDictionary::Dictionary::listObjects(const List& list,
Object::Type type) const
{
return m_impl.listObjects(*(List*)&list, type);
}
int
NdbDictionary::Dictionary::listIndexes(List& list, const char * tableName)
{
......@@ -834,6 +841,13 @@ NdbDictionary::Dictionary::listIndexes(List& list, const char * tableName)
return m_impl.listIndexes(list, tab->getTableId());
}
int
NdbDictionary::Dictionary::listIndexes(const List& list,
const char * tableName) const
{
return listIndexes(*(List *)&list, tableName);
}
const struct NdbError &
NdbDictionary::Dictionary::getNdbError() const {
return m_impl.getNdbError();
......
......@@ -80,19 +80,21 @@ int main(int argc, char** argv){
Ndb_cluster_connection con(opt_connect_str);
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
if (con.wait_until_ready(30,0) < 0)
{
ndbout << "Cluster nodes not ready in 30 seconds." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
// Connect to Ndb and wait for it to become ready
while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl;
// Check if table exists in db
int res = NDBT_OK;
for(int i = 0; i<argc; i++){
......@@ -148,11 +150,11 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
goto failed;
}
if( pOp->readTuplesExclusive(par) ) {
if( pOp->readTuples(NdbOperation::LM_Exclusive,par) ) {
goto failed;
}
if(pTrans->execute(NoCommit) != 0){
if(pTrans->execute(NdbTransaction::NoCommit) != 0){
err = pTrans->getNdbError();
if(err.status == NdbError::TemporaryError){
ERR(err);
......@@ -172,7 +174,7 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
} while((check = pOp->nextResult(false)) == 0);
if(check != -1){
check = pTrans->execute(Commit);
check = pTrans->execute(NdbTransaction::Commit);
pTrans->restart();
}
......
......@@ -80,25 +80,28 @@ int main(int argc, char** argv){
Ndb_cluster_connection con(opt_connect_str);
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb* pMyNdb = new Ndb(&con, _dbname);
pMyNdb->init();
ndbout << "Waiting...";
while (pMyNdb->waitUntilReady() != 0) {
ndbout << "...";
if (con.wait_until_ready(30,0) < 0)
{
ndbout << "Cluster nodes not ready in 30 seconds." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
ndbout << endl;
NdbDictionary::Dictionary * dict = pMyNdb->getDictionary();
Ndb MyNdb(&con, _dbname);
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
const NdbDictionary::Dictionary * dict= MyNdb.getDictionary();
for (int i = 0; i < argc; i++) {
NDBT_Table* pTab = (NDBT_Table*)dict->getTable(argv[i]);
if (pTab != 0){
ndbout << (* pTab) << endl;
NdbDictionary::Dictionary::List list;
const NdbDictionary::Dictionary::List list;
if (dict->listIndexes(list, argv[i]) != 0){
ndbout << argv[i] << ": " << dict->getNdbError() << endl;
return NDBT_ProgramExit(NDBT_FAILED);
......@@ -132,6 +135,5 @@ int main(int argc, char** argv){
ndbout << argv[i] << ": " << dict->getNdbError() << endl;
}
delete pMyNdb;
return NDBT_ProgramExit(NDBT_OK);
}
......@@ -83,16 +83,18 @@ int main(int argc, char** argv){
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
if (con.wait_until_ready(30,0) < 0)
{
ndbout << "Cluster nodes not ready in 30 seconds." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl;
int res = 0;
for(int i = 0; i<argc; i++){
ndbout << "Dropping index " << argv[i] << "...";
......
......@@ -81,18 +81,21 @@ int main(int argc, char** argv){
Ndb_cluster_connection con(opt_connect_str);
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
if (con.wait_until_ready(30,0) < 0)
{
ndbout << "Cluster nodes not ready in 30 seconds." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl;
int res = 0;
for(int i = 0; i<argc; i++){
ndbout << "Dropping table " << argv[i] << "...";
......
......@@ -29,7 +29,7 @@
static Ndb_cluster_connection *ndb_cluster_connection= 0;
static Ndb* ndb = 0;
static NdbDictionary::Dictionary* dic = 0;
static NdbDictionary::Dictionary * dic = 0;
static int _unqualified = 0;
static void
......@@ -233,16 +233,19 @@ int main(int argc, char** argv){
ndb_cluster_connection = new Ndb_cluster_connection(opt_connect_str);
if (ndb_cluster_connection->connect(12,5,1))
fatal("unable to connect");
fatal("Unable to connect to management server.");
if (ndb_cluster_connection->wait_until_ready(30,0) < 0)
fatal("Cluster nodes not ready in 30 seconds.");
ndb = new Ndb(ndb_cluster_connection, _dbname);
if (ndb->init() != 0)
fatal("init");
if (ndb->waitUntilReady(30) < 0)
fatal("waitUntilReady");
dic = ndb->getDictionary();
for (int i = 0; _loops == 0 || i < _loops; i++) {
list(_tabname, (NdbDictionary::Object::Type)_type);
}
delete ndb;
delete ndb_cluster_connection;
return NDBT_ProgramExit(NDBT_OK);
}
......
......@@ -375,7 +375,8 @@ void BackupRestore::tuple_a(restore_callback_t *cb)
}
// Prepare transaction (the transaction is NOT yet sent to NDB)
cb->connection->executeAsynchPrepare(Commit, &callback, cb);
cb->connection->executeAsynchPrepare(NdbTransaction::Commit,
&callback, cb);
m_transactions++;
return;
}
......@@ -543,7 +544,7 @@ BackupRestore::logEntry(const LogEntry & tup)
op->setValue(attr->Desc->attrId, dataPtr, length);
}
const int ret = trans->execute(Commit);
const int ret = trans->execute(NdbTransaction::Commit);
if (ret != 0)
{
// Both insert update and delete can fail during log running
......@@ -654,7 +655,7 @@ BackupRestore::tuple(const TupleS & tup)
else
op->setValue(i, dataPtr, length);
}
int ret = trans->execute(Commit);
int ret = trans->execute(NdbTransaction::Commit);
if (ret != 0)
{
ndbout << "execute failed: ";
......
......@@ -24,7 +24,6 @@
#include <NdbMain.h>
#include <NDBT.hpp>
#include <NdbSleep.h>
#include <NdbScanFilter.hpp>
int scanReadRecords(Ndb*,
const NdbDictionary::Table*,
......@@ -127,19 +126,21 @@ int main(int argc, char** argv){
Ndb_cluster_connection con(opt_connect_str);
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
if (con.wait_until_ready(30,0) < 0)
{
ndbout << "Cluster nodes not ready in 30 seconds." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
// Connect to Ndb and wait for it to become ready
while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl;
// Check if table exists in db
const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
const NdbDictionary::Index * pIdx = 0;
......@@ -320,7 +321,7 @@ int scanReadRecords(Ndb* pNdb,
}
}
check = pTrans->execute(NoCommit);
check = pTrans->execute(NdbTransaction::NoCommit);
if( check == -1 ) {
const NdbError err = pTrans->getNdbError();
......
......@@ -100,19 +100,21 @@ int main(int argc, char** argv){
Ndb_cluster_connection con(opt_connect_str);
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
if (con.wait_until_ready(30,0) < 0)
{
ndbout << "Cluster nodes not ready in 30 seconds." << endl;
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED);
}
// Connect to Ndb and wait for it to become ready
while(MyNdb.waitUntilReady() != 0)
ndbout << "Waiting for ndb to become ready..." << endl;
for(int i = 0; i<argc; i++){
// Check if table exists in db
const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]);
......@@ -189,7 +191,7 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab,
Uint32 row_size;
pOp->getValue(NdbDictionary::Column::ROW_COUNT, (char*)&tmp);
pOp->getValue(NdbDictionary::Column::ROW_SIZE, (char*)&row_size);
check = pTrans->execute(NoCommit);
check = pTrans->execute(NdbTransaction::NoCommit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
......
......@@ -161,7 +161,9 @@ int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans)
if (m_batch_execute)
return 0;
#endif
return trans->execute(NoCommit,AbortOnError,h->m_force_send);
return trans->execute(NdbTransaction::NoCommit,
NdbTransaction::AbortOnError,
h->m_force_send);
}
inline
......@@ -172,7 +174,9 @@ int execute_commit(ha_ndbcluster *h, NdbTransaction *trans)
if (m_batch_execute)
return 0;
#endif
return trans->execute(Commit,AbortOnError,h->m_force_send);
return trans->execute(NdbTransaction::Commit,
NdbTransaction::AbortOnError,
h->m_force_send);
}
inline
......@@ -183,7 +187,9 @@ int execute_commit(THD *thd, NdbTransaction *trans)
if (m_batch_execute)
return 0;
#endif
return trans->execute(Commit,AbortOnError,thd->variables.ndb_force_send);
return trans->execute(NdbTransaction::Commit,
NdbTransaction::AbortOnError,
thd->variables.ndb_force_send);
}
inline
......@@ -194,7 +200,9 @@ int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans)
if (m_batch_execute)
return 0;
#endif
return trans->execute(NoCommit,AO_IgnoreError,h->m_force_send);
return trans->execute(NdbTransaction::NoCommit,
NdbTransaction::AO_IgnoreError,
h->m_force_send);
}
/*
......@@ -3345,7 +3353,7 @@ int ndbcluster_rollback(THD *thd, void *ndb_transaction)
"stmt" : "all"));
DBUG_ASSERT(ndb && trans);
if (trans->execute(Rollback) != 0)
if (trans->execute(NdbTransaction::Rollback) != 0)
{
const NdbError err= trans->getNdbError();
const NdbOperation *error_op= trans->getNdbErrorOperation();
......@@ -4863,7 +4871,9 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
pOp->getValue(NdbDictionary::Column::ROW_COUNT, (char*)&rows);
pOp->getValue(NdbDictionary::Column::COMMIT_COUNT, (char*)&commits);
check= pTrans->execute(NoCommit, AbortOnError, TRUE);
check= pTrans->execute(NdbTransaction::NoCommit,
NdbTransaction::AbortOnError,
TRUE);
if (check == -1)
break;
......
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