Commit fb572d9c authored by joreland@mysql.com's avatar joreland@mysql.com

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

into mysql.com:/home/jonas/src/mysql-5.0-ndb
parents b6b8c50a 9d267f4d
......@@ -1770,6 +1770,7 @@ examine config.log for possible errors. If you want to report this, use
'scripts/mysqlbug' and include at least the last 20 rows from config.log!])
fi
AC_CHECK_SIZEOF(char*, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
if test "$ac_cv_sizeof_int" -eq 0
then
......@@ -2723,11 +2724,26 @@ then
fi
AC_SUBST([ndb_bin_am_ldflags])
AC_SUBST([ndb_opt_subdirs])
NDB_SIZEOF_CHARP="$ac_cv_sizeof_charp"
NDB_SIZEOF_CHAR="$ac_cv_sizeof_char"
NDB_SIZEOF_SHORT="$ac_cv_sizeof_short"
NDB_SIZEOF_INT="$ac_cv_sizeof_int"
NDB_SIZEOF_LONG="$ac_cv_sizeof_long"
NDB_SIZEOF_LONG_LONG="$ac_cv_sizeof_long_long"
AC_SUBST([NDB_SIZEOF_CHARP])
AC_SUBST([NDB_SIZEOF_CHAR])
AC_SUBST([NDB_SIZEOF_SHORT])
AC_SUBST([NDB_SIZEOF_INT])
AC_SUBST([NDB_SIZEOF_LONG])
AC_SUBST([NDB_SIZEOF_LONG_LONG])
AC_CONFIG_FILES(ndb/Makefile ndb/include/Makefile dnl
ndb/src/Makefile ndb/src/common/Makefile dnl
ndb/docs/Makefile dnl
ndb/tools/Makefile dnl
ndb/src/common/debugger/Makefile ndb/src/common/debugger/signaldata/Makefile dnl
ndb/src/common/debugger/Makefile dnl
ndb/src/common/debugger/signaldata/Makefile dnl
ndb/src/common/portlib/Makefile dnl
ndb/src/common/util/Makefile dnl
ndb/src/common/logger/Makefile dnl
......@@ -2766,6 +2782,7 @@ AC_CONFIG_FILES(ndb/Makefile ndb/include/Makefile dnl
ndb/test/tools/Makefile dnl
ndb/test/run-test/Makefile mysql-test/ndb/Makefile dnl
ndb/include/ndb_version.h ndb/include/ndb_global.h dnl
ndb/include/ndb_types.h dnl
)
fi
......
-include .defs.mk
#NDB_OS = OS_YOU_ARE_RUNNING_ON
#NDB_OS = LINUX
#You need to set the NDB_OS variable here (LINUX, SOLARIS, MACOSX)
TARGET = ndbapi_async
SRCS = ndbapi_async.cpp
OBJS = ndbapi_async.o
CC = g++
CFLAGS = -c -Wall -fno-rtti -D$(NDB_OS)
SRCS = $(TARGET).cpp
OBJS = $(TARGET).o
CXX = g++
CFLAGS = -g -c -Wall -fno-rtti -fno-exceptions
CXXFLAGS = -g
DEBUG =
LFLAGS = -Wall
INCLUDE_DIR = ../../include
LIB_DIR = ../../lib
ifeq ($(NDB_OS), SOLARIS)
# Here is the definition of system libraries necessary for Solaris 7
SYS_LIB = -lpthread -lsocket -lnsl -lrt
endif
ifeq ($(NDB_OS), LINUX)
# Here is the definition of system libraries necessary for Linux 2.4
SYS_LIB = -lpthread
endif
ifeq ($(NDB_OS), MACOSX)
# Here is the definition of system libraries necessary for Mac OS X
TOP_SRCDIR = ../../..
INCLUDE_DIR = $(TOP_SRCDIR)
LIB_DIR = -L$(TOP_SRCDIR)/ndb/src/.libs \
-L$(TOP_SRCDIR)/libmysql_r/.libs \
-L$(TOP_SRCDIR)/mysys
SYS_LIB =
endif
$(TARGET): $(OBJS)
$(CC) $(LFLAGS) -L$(LIB_DIR) -lNDB_API $(OBJS) $(SYS_LIB) -o $(TARGET)
$(CXX) $(CXXFLAGS) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lz $(SYS_LIB) -o $(TARGET)
$(TARGET).o: $(SRCS)
$(CC) $(CFLAGS) -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/ndbapi $(SRCS)
$(CXX) $(CFLAGS) -I$(INCLUDE_DIR)/include -I$(INCLUDE_DIR)/extra -I$(INCLUDE_DIR)/ndb/include -I$(INCLUDE_DIR)/ndb/include/ndbapi $(SRCS)
clean:
rm -f *.o $(TARGET)
......@@ -24,10 +24,12 @@
*
* Classes and methods in NDBAPI used in this example:
*
* Ndb_cluster_connection
* connect()
* wait_until_ready()
*
* Ndb
* init()
* waitUntilRead()
* getDictionary()
* startTransaction()
* closeTransaction()
* sendPollNdb()
......@@ -38,23 +40,6 @@
* executeAsynchPrepare()
* getNdbError()
*
* NdbDictionary::Dictionary
* getTable()
* dropTable()
* createTable()
* getNdbError()
*
* NdbDictionary::Column
* setName()
* setType()
* setLength()
* setPrimaryKey()
* setNullable()
*
* NdbDictionary::Table
* setName()
* addColumn()
*
* NdbOperation
* insertTuple()
* equal()
......@@ -63,10 +48,10 @@
*/
#include <ndb_global.h>
#include <mysql.h>
#include <mysqld_error.h>
#include <NdbApi.hpp>
#include <NdbScanFilter.hpp>
#include <iostream> // Used for cout
/**
......@@ -85,11 +70,16 @@ milliSleep(int milliseconds){
/**
* error printout macro
*/
#define APIERROR(error) \
{ std::cout << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
<< error.code << ", msg: " << error.message << "." << std::endl; \
exit(-1); }
#define PRINT_ERROR(code,msg) \
std::cout << "Error in " << __FILE__ << ", line: " << __LINE__ \
<< ", code: " << code \
<< ", msg: " << msg << "." << std::endl
#define MYSQLERROR(mysql) { \
PRINT_ERROR(mysql_errno(&mysql),mysql_error(&mysql)); \
exit(-1); }
#define APIERROR(error) { \
PRINT_ERROR(error.code,error.message); \
exit(-1); }
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/**
......@@ -106,10 +96,10 @@ typedef struct {
} async_callback_t;
/**
* Structure used in "free list" to a NdbConnection
* Structure used in "free list" to a NdbTransaction
*/
typedef struct {
NdbConnection* conn;
NdbTransaction* conn;
int used;
} transaction_t;
......@@ -132,7 +122,7 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData);
/**
* Error handler.
*/
bool asynchErrorHandler(NdbConnection * trans, Ndb* ndb);
bool asynchErrorHandler(NdbTransaction * trans, Ndb* ndb);
/**
* Exit function
......@@ -171,7 +161,7 @@ closeTransaction(Ndb * ndb , async_callback_t * cb)
* Callback executed when transaction has return from NDB
*/
static void
callback(int result, NdbConnection* trans, void* aObject)
callback(int result, NdbTransaction* trans, void* aObject)
{
async_callback_t * cbData = (async_callback_t *)aObject;
if (result<0)
......@@ -207,61 +197,26 @@ callback(int result, NdbConnection* trans, void* aObject)
/**
* Create table "GARAGE"
*/
int create_table(Ndb * myNdb)
int create_table(MYSQL &mysql)
{
NdbDictionary::Table myTable;
NdbDictionary::Column myColumn;
NdbDictionary::Dictionary* myDict = myNdb->getDictionary();
/*********************************************************
* Create a table named GARAGE if it does not exist *
*********************************************************/
if (myDict->getTable("GARAGE") != NULL)
while (mysql_query(&mysql,
"CREATE TABLE"
" GARAGE"
" (REG_NO INT UNSIGNED NOT NULL,"
" BRAND CHAR(20) NOT NULL,"
" COLOR CHAR(20) NOT NULL,"
" PRIMARY KEY USING HASH (REG_NO))"
" ENGINE=NDB"))
{
std::cout << "NDB already has example table: GARAGE. "
if (mysql_errno(&mysql) != ER_TABLE_EXISTS_ERROR)
MYSQLERROR(mysql);
std::cout << "MySQL Cluster already has example table: GARAGE. "
<< "Dropping it..." << std::endl;
if(myDict->dropTable("GARAGE") == -1)
{
std::cout << "Failed to drop: GARAGE." << std::endl;
exit(1);
}
}
myTable.setName("GARAGE");
/**
* Column REG_NO
*/
myColumn.setName("REG_NO");
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
/**
* Column BRAND
*/
myColumn.setName("BRAND");
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
/**
* Column COLOR
*/
myColumn.setName("COLOR");
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(20);
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
if (myDict->createTable(myTable) == -1) {
APIERROR(myDict->getNdbError());
/**************
* Drop table *
**************/
if (mysql_query(&mysql, "DROP TABLE GARAGE"))
MYSQLERROR(mysql);
}
return 1;
}
......@@ -276,7 +231,7 @@ void asynchExitHandler(Ndb * m_ndb)
/* returns true if is recoverable (temporary),
* false if it is an error that is permanent.
*/
bool asynchErrorHandler(NdbConnection * trans, Ndb* ndb)
bool asynchErrorHandler(NdbTransaction * trans, Ndb* ndb)
{
NdbError error = trans->getNdbError();
switch(error.status)
......@@ -455,22 +410,48 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
int main()
{
ndb_init();
Ndb* myNdb = new Ndb( "TEST_DB" ); // Object representing the database
/*******************************************
* Initialize NDB and wait until its ready *
*******************************************/
if (myNdb->init(1024) == -1) { // Set max 1024 parallel transactions
APIERROR(myNdb->getNdbError());
MYSQL mysql;
/**************************************************************
* Connect to mysql server and create table *
**************************************************************/
{
if ( !mysql_init(&mysql) ) {
std::cout << "mysql_init failed\n";
exit(-1);
}
if ( !mysql_real_connect(&mysql, "localhost", "root", "", "",
3306, "/tmp/mysql.sock", 0) )
MYSQLERROR(mysql);
mysql_query(&mysql, "CREATE DATABASE TEST_DB");
if (mysql_query(&mysql, "USE TEST_DB") != 0) MYSQLERROR(mysql);
create_table(mysql);
}
if (myNdb->waitUntilReady(30) != 0) {
std::cout << "NDB was not ready within 30 secs." << std::endl;
/**************************************************************
* Connect to ndb cluster *
**************************************************************/
Ndb_cluster_connection cluster_connection;
if (cluster_connection.connect(4, 5, 1))
{
std::cout << "Unable to connect to cluster within 30 secs." << std::endl;
exit(-1);
}
// Optionally connect and wait for the storage nodes (ndbd's)
if (cluster_connection.wait_until_ready(30,0) < 0)
{
std::cout << "Cluster was not ready within 30 secs.\n";
exit(-1);
}
create_table(myNdb);
Ndb* myNdb = new Ndb( &cluster_connection,
"TEST_DB" ); // Object representing the database
if (myNdb->init(1024) == -1) { // Set max 1024 parallel transactions
APIERROR(myNdb->getNdbError());
}
/**
* Initialise transaction array
*/
......
......@@ -141,8 +141,8 @@ static void create_table(MYSQL &mysql)
if (mysql_query(&mysql,
"CREATE TABLE"
" MYTABLENAME"
" (ATTR1 INT UNSIGNED PRIMARY KEY,"
" ATTR2 INT UNSIGNED)"
" (ATTR1 INT UNSIGNED NOT NULL PRIMARY KEY,"
" ATTR2 INT UNSIGNED NOT NULL)"
" ENGINE=NDB"))
MYSQLERROR(mysql);
}
......@@ -234,7 +234,7 @@ static void do_read(Ndb &myNdb)
NdbOperation *myOperation= myTransaction->getNdbOperation("MYTABLENAME");
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->readTuple();
myOperation->readTuple(NdbOperation::LM_Read);
myOperation->equal("ATTR1", i);
NdbRecAttr *myRecAttr= myOperation->getValue("ATTR2", NULL);
......
TARGET = ndbapi_example4
SRCS = ndbapi_example4.cpp
OBJS = ndbapi_example4.o
SRCS = $(TARGET).cpp
OBJS = $(TARGET).o
CXX = g++
CFLAGS = -c -Wall -fno-rtti -fno-exceptions
CXXFLAGS =
DEBUG =
LFLAGS = -Wall
INCLUDE_DIR = ../../include
LIB_DIR = -L../../src/.libs \
-L../../../libmysql_r/.libs \
-L../../../mysys
TOP_SRCDIR = ../../..
INCLUDE_DIR = $(TOP_SRCDIR)
LIB_DIR = -L$(TOP_SRCDIR)/ndb/src/.libs \
-L$(TOP_SRCDIR)/libmysql_r/.libs \
-L$(TOP_SRCDIR)/mysys
SYS_LIB =
$(TARGET): $(OBJS)
$(CXX) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lz $(SYS_LIB) -o $(TARGET)
$(CXX) $(CXXFLAGS) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lz $(SYS_LIB) -o $(TARGET)
$(TARGET).o: $(SRCS)
$(CXX) $(CFLAGS) -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/ndbapi $(SRCS)
$(CXX) $(CFLAGS) -I$(INCLUDE_DIR)/include -I$(INCLUDE_DIR)/ndb/include -I$(INCLUDE_DIR)/ndb/include/ndbapi $(SRCS)
clean:
rm -f *.o $(TARGET)
TARGET = ndbapi_scan
SRCS = ndbapi_scan.cpp
OBJS = ndbapi_scan.o
SRCS = $(TARGET).cpp
OBJS = $(TARGET).o
CXX = g++
CFLAGS = -c -Wall -fno-rtti -fno-exceptions
CXXFLAGS =
CFLAGS = -g -c -Wall -fno-rtti -fno-exceptions
CXXFLAGS = -g
DEBUG =
LFLAGS = -Wall
TOP_SRCDIR = ../../..
INCLUDE_DIR = $(TOP_SRCDIR)/ndb/include
INCLUDE_DIR = $(TOP_SRCDIR)
LIB_DIR = -L$(TOP_SRCDIR)/ndb/src/.libs \
-L$(TOP_SRCDIR)/libmysql_r/.libs \
-L$(TOP_SRCDIR)/mysys
......@@ -17,7 +17,7 @@ $(TARGET): $(OBJS)
$(CXX) $(CXXFLAGS) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lz $(SYS_LIB) -o $(TARGET)
$(TARGET).o: $(SRCS)
$(CXX) $(CFLAGS) -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/ndbapi $(SRCS)
$(CXX) $(CFLAGS) -I$(INCLUDE_DIR)/include -I$(INCLUDE_DIR)/extra -I$(INCLUDE_DIR)/ndb/include -I$(INCLUDE_DIR)/ndb/include/ndbapi $(SRCS)
clean:
rm -f *.o $(TARGET)
......@@ -38,8 +38,6 @@
* getNdbScanOperation()
* execute()
*
* NdbResultSet
*
* NdbScanOperation
* getValue()
* readTuples()
......@@ -47,21 +45,14 @@
* deleteCurrentTuple()
* updateCurrentTuple()
*
* NdbDictionary::Dictionary
* const NdbDictionary::Dictionary
* getTable()
* dropTable()
* createTable()
*
* NdbDictionary::Column
* setName()
* setType()
* setLength()
* setPrimaryKey()
* setNullable()
* const NdbDictionary::Table
* getColumn()
*
* NdbDictionary::Table
* setName()
* addColumn()
* const NdbDictionary::Column
* getLength()
*
* NdbOperation
* insertTuple()
......@@ -76,6 +67,8 @@
*/
#include <mysql.h>
#include <mysqld_error.h>
#include <NdbApi.hpp>
// Used for cout
#include <iostream>
......@@ -97,10 +90,16 @@ milliSleep(int milliseconds){
/**
* Helper sleep function
*/
#define APIERROR(error) \
{ std::cout << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
<< error.code << ", msg: " << error.message << "." << std::endl; \
exit(-1); }
#define PRINT_ERROR(code,msg) \
std::cout << "Error in " << __FILE__ << ", line: " << __LINE__ \
<< ", code: " << code \
<< ", msg: " << msg << "." << std::endl
#define MYSQLERROR(mysql) { \
PRINT_ERROR(mysql_errno(&mysql),mysql_error(&mysql)); \
exit(-1); }
#define APIERROR(error) { \
PRINT_ERROR(error.code,error.message); \
exit(-1); }
struct Car
{
......@@ -112,55 +111,26 @@ struct Car
/**
* Function to create table
*/
int create_table(Ndb * myNdb)
int create_table(MYSQL &mysql)
{
NdbDictionary::Table myTable;
NdbDictionary::Column myColumn;
NdbDictionary::Dictionary* myDict = myNdb->getDictionary();
/*********************************************************
* Create a table named GARAGE if it does not exist *
*********************************************************/
if (myDict->getTable("GARAGE") != NULL) {
std::cout << "NDB already has example table: GARAGE. "
while (mysql_query(&mysql,
"CREATE TABLE"
" GARAGE"
" (REG_NO INT UNSIGNED NOT NULL,"
" BRAND CHAR(20) NOT NULL,"
" COLOR CHAR(20) NOT NULL,"
" PRIMARY KEY USING HASH (REG_NO))"
" ENGINE=NDB"))
{
if (mysql_errno(&mysql) != ER_TABLE_EXISTS_ERROR)
MYSQLERROR(mysql);
std::cout << "MySQL Cluster already has example table: GARAGE. "
<< "Dropping it..." << std::endl;
if(myDict->dropTable("GARAGE") == -1)
{
std::cout << "Failed to drop: GARAGE." << std::endl;
exit(1);
}
}
Car car;
myTable.setName("GARAGE");
myColumn.setName("REG_NO");
myColumn.setType(NdbDictionary::Column::Unsigned);
myColumn.setLength(1);
myColumn.setPrimaryKey(true);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("BRAND");
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(sizeof(car.brand));
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
myColumn.setName("COLOR");
myColumn.setType(NdbDictionary::Column::Char);
myColumn.setLength(sizeof(car.color));
myColumn.setPrimaryKey(false);
myColumn.setNullable(false);
myTable.addColumn(myColumn);
if (myDict->createTable(myTable) == -1) {
APIERROR(myDict->getNdbError());
return -1;
/**************
* Drop table *
**************/
if (mysql_query(&mysql, "DROP TABLE GARAGE"))
MYSQLERROR(mysql);
}
return 1;
}
......@@ -460,7 +430,7 @@ int scan_update(Ndb* myNdb,
/**
* Define a result set for the scan.
*/
if( myScanOp->readTuplesExclusive(NdbOperation::LM_Exclusive) )
if( myScanOp->readTuples(NdbOperation::LM_Exclusive) )
{
std::cout << myTrans->getNdbError().message << std::endl;
myNdb->closeTransaction(myTrans);
......@@ -726,36 +696,67 @@ int scan_print(Ndb * myNdb)
int main()
{
ndb_init();
MYSQL mysql;
Ndb_cluster_connection cluster_connection;
/**************************************************************
* Connect to mysql server and create table *
**************************************************************/
{
if ( !mysql_init(&mysql) ) {
std::cout << "mysql_init failed\n";
exit(-1);
}
if ( !mysql_real_connect(&mysql, "localhost", "root", "", "",
3306, "/tmp/mysql.sock", 0) )
MYSQLERROR(mysql);
mysql_query(&mysql, "CREATE DATABASE TEST_DB");
if (mysql_query(&mysql, "USE TEST_DB") != 0) MYSQLERROR(mysql);
if (cluster_connection.connect(12, 5, 1))
create_table(mysql);
}
/**************************************************************
* Connect to ndb cluster *
**************************************************************/
Ndb_cluster_connection cluster_connection;
if (cluster_connection.connect(4, 5, 1))
{
std::cout << "Unable to connect to cluster within 30 secs." << std::endl;
exit(-1);
}
if (cluster_connection.wait_until_ready(30,30))
// Optionally connect and wait for the storage nodes (ndbd's)
if (cluster_connection.wait_until_ready(30,0) < 0)
{
std::cout << "Cluster was not ready within 30 secs." << std::endl;
std::cout << "Cluster was not ready within 30 secs.\n";
exit(-1);
}
Ndb myNdb(&cluster_connection,"TEST_DB" );
/*******************************************
* Initialize NDB and wait until its ready *
*******************************************/
if (myNdb.init(1024) == -1) { // Set max 1024 parallel transactions
Ndb myNdb(&cluster_connection,"TEST_DB");
if (myNdb.init(1024) == -1) { // Set max 1024 parallel transactions
APIERROR(myNdb.getNdbError());
exit(-1);
}
create_table(&myNdb);
NdbDictionary::Dictionary* myDict = myNdb.getDictionary();
int column_color = myDict->getTable("GARAGE")->getColumn("COLOR")->getColumnNo();
/*******************************************
* Check table definition *
*******************************************/
int column_color;
{
const NdbDictionary::Dictionary* myDict= myNdb.getDictionary();
const NdbDictionary::Table *t= myDict->getTable("GARAGE");
Car car;
if (t->getColumn("COLOR")->getLength() != sizeof(car.color) ||
t->getColumn("BRAND")->getLength() != sizeof(car.brand))
{
std::cout << "Wrong table definition" << std::endl;
exit(-1);
}
column_color= t->getColumn("COLOR")->getColumnNo();
}
if(populate(&myNdb) > 0)
std::cout << "populate: Success!" << std::endl;
......@@ -789,4 +790,6 @@ int main()
}
if(scan_print(&myNdb) > 0)
std::cout << "scan_print: Success!" << std::endl << std::endl;
return 0;
}
-include .defs.mk
#NDB_OS = OS_YOU_ARE_RUNNING_ON
#You need to set the NDB_OS variable here
TARGET = select_all
SRCS = select_all.cpp
OBJS = select_all.o
CXX = g++
CFLAGS = -c -Wall -fno-rtti -fno-exceptions
DEBUG =
LFLAGS = -Wall
INCLUDE_DIR = ../../include
LIB_DIR = ../../lib
ifeq ($(NDB_OS), SOLARIS)
# Here is the definition of system libraries necessary for Solaris 7
SYS_LIB =
endif
ifeq ($(NDB_OS), LINUX)
# Here is the definition of system libraries necessary for Linux 2.4
SYS_LIB =
endif
ifeq ($(NDB_OS), MACOSX)
# Here is the definition of system libraries necessary for Mac OS X
SYS_LIB =
endif
$(TARGET): $(OBJS)
$(CXX) $(LFLAGS) -L$(LIB_DIR) $(OBJS) -lNDB_API $(SYS_LIB) -o $(TARGET)
$(TARGET).o: $(SRCS)
$(CXX) $(CFLAGS) -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/ndbapi $(SRCS)
clean:
rm -f *.o $(TARGET)
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
//
// select_all.cpp: Prints all rows of a table
//
// Usage: select_all <table_name>+
#include <NdbApi.hpp>
// Used for cout
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#define APIERROR(error) \
{ cout << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
<< error.code << ", msg: " << error.message << "." << endl; \
exit(-1); }
void usage(const char* prg) {
cout << "Usage: " << prg << " <table name>" << endl;
cout << "Prints all rows of table named <table name>" << endl;
exit(0);
}
/*****************************************************************************
*************************** Result Set Container ****************************
*****************************************************************************/
/*
* Container of NdbRecAttr objects.
* (NdbRecAttr objects are database rows read by a scan operation.)
*/
class ResultSetContainer {
public:
/**
* Initialize ResultSetContainer object for table named <tableName>
* - Allocates memory
* - Fetches attribute names from NDB Cluster
*/
void init(NdbDictionary::Dictionary* dict, const char* tableName);
/**
* Get no of attributes for stored NdbRecAttr objects
*/
int getNoOfAttributes() const;
/**
* Get NdbRecAttr object no i
*/
NdbRecAttr* & getAttrStore(int i);
/**
* Get attribute name of attribute no i
*/
const char* getAttrName(int i) const;
/**
* Print header of rows
*/
void header() const;
private:
int m_cols; // No of attributes for stored NdbRecAttr objects
char **m_names; // Names of attributes
NdbRecAttr **m_data; // The actual stored NdbRecAttr objects
};
void ResultSetContainer::init(NdbDictionary::Dictionary * dict,
const char* tableName)
{
// Get Table object from NDB (this contains metadata about all tables)
const NdbDictionary::Table * tab = dict->getTable(tableName);
// Get table id of the table we are interested in
if (tab == 0) APIERROR(dict->getNdbError()); // E.g. table didn't exist
// Get no of attributes and allocate memory
m_cols = tab->getNoOfColumns();
m_names = new char* [m_cols];
m_data = new NdbRecAttr* [m_cols];
// Store all attribute names for the table
for (int i = 0; i < m_cols; i++) {
m_names[i] = new char[255];
BaseString::snprintf(m_names[i], 255, "%s", tab->getColumn(i)->getName());
}
}
int ResultSetContainer::getNoOfAttributes() const {return m_cols;}
NdbRecAttr*& ResultSetContainer::getAttrStore(int i) {return m_data[i];}
const char* ResultSetContainer::getAttrName(int i) const {return m_names[i];}
/*****************************************************************************
********************************** MAIN ***********************************
*****************************************************************************/
int main(int argc, const char** argv)
{
ndb_init();
Ndb* myNdb = new Ndb("ndbapi_example4"); // Object representing the database
NdbConnection* myNdbConnection; // For transactions
NdbOperation* myNdbOperation; // For operations
int check;
if (argc != 2) {
usage(argv[0]);
exit(0);
}
const char* tableName = argv[1];
/*******************************************
* Initialize NDB and wait until its ready *
*******************************************/
if (myNdb->init() == -1) {
APIERROR(myNdb->getNdbError());
exit(-1);
}
if (myNdb->waitUntilReady(30) != 0) {
cout << "NDB was not ready within 30 secs." << endl;
exit(-1);
}
/***************************
* Define and execute scan *
***************************/
cout << "Select * from " << tableName << endl;
ResultSetContainer * container = new ResultSetContainer;
container->init(myNdb->getDictionary(), tableName);
myNdbConnection = myNdb->startTransaction();
if (myNdbConnection == NULL) APIERROR(myNdb->getNdbError());
myNdbOperation = myNdbConnection->getNdbOperation(tableName);
if (myNdbOperation == NULL) APIERROR(myNdbConnection->getNdbError());
// Define the operation to be an 'openScanRead' operation.
check = myNdbOperation->openScanRead(1);
if (check == -1) APIERROR(myNdbConnection->getNdbError());
// Set interpreted program to just be the single instruction
// 'interpret_exit_ok'. (This approves all rows of the table.)
if (myNdbOperation->interpret_exit_ok() == -1)
APIERROR(myNdbConnection->getNdbError());
// Get all attribute values of the row
for(int i = 0; i < container->getNoOfAttributes(); i++){
if((container->getAttrStore(i) =
myNdbOperation->getValue(container->getAttrName(i))) == 0)
APIERROR(myNdbConnection->getNdbError());
}
// Execute scan operation
check = myNdbConnection->executeScan();
if (check == -1) APIERROR(myNdbConnection->getNdbError());
/****************
* Print header *
****************/
for (int i = 0; i < container->getNoOfAttributes(); i++)
cout << container->getAttrName(i) << "\t";
cout << endl;
for (int i = 0; i < container->getNoOfAttributes(); i++) {
for (int j = strlen(container->getAttrName(i)); j > 0; j--)
cout << "-";
cout << "\t";
}
cout << "\n";
/**************
* Scan table *
**************/
int eof;
int rows = 0;
// Print all rows of table
while ((eof = myNdbConnection->nextScanResult()) == 0) {
rows++;
for (int i = 0; i < container->getNoOfAttributes(); i++) {
if (container->getAttrStore(i)->isNULL()) {
cout << "NULL";
} else {
// Element size of value (No of bits per element in attribute value)
const int size = container->getAttrStore(i)->attrSize();
// No of elements in an array attribute (Is 1 if non-array attribute)
const int aSize = container->getAttrStore(i)->arraySize();
switch(container->getAttrStore(i)->attrType()){
case UnSigned:
switch(size) {
case 8: cout << container->getAttrStore(i)->u_64_value(); break;
case 4: cout << container->getAttrStore(i)->u_32_value(); break;
case 2: cout << container->getAttrStore(i)->u_short_value(); break;
case 1: cout << (unsigned) container->getAttrStore(i)->u_char_value();
break;
default: cout << "Unknown size" << endl;
}
break;
case Signed:
switch(size) {
case 8: cout << container->getAttrStore(i)->int64_value(); break;
case 4: cout << container->getAttrStore(i)->int32_value(); break;
case 2: cout << container->getAttrStore(i)->short_value(); break;
case 1: cout << (int) container->getAttrStore(i)->char_value(); break;
default: cout << "Unknown size" << endl;
}
break;
case String:
{
char* buf = new char[aSize+1];
memcpy(buf, container->getAttrStore(i)->aRef(), aSize);
buf[aSize] = 0;
cout << buf;
delete [] buf;
}
break;
case Float:
cout << container->getAttrStore(i)->float_value();
break;
default:
cout << "Unknown";
break;
}
}
cout << "\t";
}
cout << endl;
}
if (eof == -1) APIERROR(myNdbConnection->getNdbError());
myNdb->closeTransaction(myNdbConnection);
cout << "Selected " << rows << " rows." << endl;
}
......@@ -14,8 +14,8 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef NDBGLOBAL_H
#define NDBGLOBAL_H
#ifndef NDB_GLOBAL_H
#define NDB_GLOBAL_H
#include <ndb_types.h>
......@@ -31,45 +31,22 @@
#define HAVE_STRCASECMP
#define strcasecmp _strcmpi
#pragma warning(disable: 4503 4786)
typedef unsigned __int64 Uint64;
typedef signed __int64 Int64;
#else
#undef NDB_WIN32
#define DIR_SEPARATOR "/"
typedef unsigned long long Uint64;
typedef signed long long Int64;
#endif
#include <my_global.h>
typedef signed char Int8;
typedef unsigned char Uint8;
typedef signed short Int16;
typedef unsigned short Uint16;
typedef signed int Int32;
typedef unsigned int Uint32;
typedef unsigned int UintR;
#ifdef __SIZE_TYPE__
typedef __SIZE_TYPE__ UintPtr;
#elif SIZEOF_CHARP == 4
typedef Uint32 UintPtr;
#elif SIZEOF_CHARP == 8
typedef Uint64 UintPtr;
#else
#error "Unknown size of (char *)"
#endif
#if ! (SIZEOF_CHAR == 1)
#if ! (NDB_SIZEOF_CHAR == SIZEOF_CHAR)
#error "Invalid define for Uint8"
#endif
#if ! (SIZEOF_INT == 4)
#if ! (NDB_SIZEOF_INT == SIZEOF_INT)
#error "Invalid define for Uint32"
#endif
#if ! (SIZEOF_LONG_LONG == 8)
#if ! (NDB_SIZEOF_LONG_LONG == SIZEOF_LONG_LONG)
#error "Invalid define for Uint64"
#endif
......
......@@ -21,7 +21,61 @@
#ifndef NDB_TYPES_H
#define NDB_TYPES_H
#include "ndb_global.h"
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(_WIN64)
#define NDB_SIZEOF_CHARP SIZEOF_CHARP
#define NDB_SIZEOF_CHAR SIZEOF_CHAR
#define NDB_SIZEOF_SHORT 2
#define NDB_SIZEOF_INT SIZEOF_INT
#define NDB_SIZEOF_LONG SIZEOF_LONG
#define NDB_SIZEOF_LONG_LONG SIZEOF_LONG_LONG
typedef unsigned __int64 Uint64;
typedef signed __int64 Int64;
#else
#define NDB_SIZEOF_CHARP @NDB_SIZEOF_CHARP@
#define NDB_SIZEOF_CHAR @NDB_SIZEOF_CHAR@
#define NDB_SIZEOF_INT @NDB_SIZEOF_INT@
#define NDB_SIZEOF_SHORT @NDB_SIZEOF_SHORT@
#define NDB_SIZEOF_LONG @NDB_SIZEOF_LONG@
#define NDB_SIZEOF_LONG_LONG @NDB_SIZEOF_LONG_LONG@
typedef unsigned long long Uint64;
typedef signed long long Int64;
#endif
typedef signed char Int8;
typedef unsigned char Uint8;
typedef signed short Int16;
typedef unsigned short Uint16;
typedef signed int Int32;
typedef unsigned int Uint32;
typedef unsigned int UintR;
#ifdef __SIZE_TYPE__
typedef __SIZE_TYPE__ UintPtr;
#elif NDB_SIZEOF_CHARP == 4
typedef Uint32 UintPtr;
#elif NDB_SIZEOF_CHARP == 8
typedef Uint64 UintPtr;
#else
#error "Unknown size of (char *)"
#endif
#if ! (NDB_SIZEOF_CHAR == 1)
#error "Invalid define for Uint8"
#endif
#if ! (NDB_SIZEOF_SHORT == 2)
#error "Invalid define for Uint16"
#endif
#if ! (NDB_SIZEOF_INT == 4)
#error "Invalid define for Uint32"
#endif
#if ! (NDB_SIZEOF_LONG_LONG == 8)
#error "Invalid define for Uint64"
#endif
#include "ndb_constants.h"
#endif
......@@ -1023,7 +1023,7 @@ public:
* @param name Name of table to get
* @return table if successful otherwise NULL.
*/
const Table * getTable(const char * name);
const Table * getTable(const char * name) const;
/**
* Get index with given name, NULL if undefined
......@@ -1032,7 +1032,7 @@ public:
* @return index if successful, otherwise 0.
*/
const Index * getIndex(const char * indexName,
const char * tableName);
const char * tableName) const;
/**
* Fetch list of indexes of given table.
......@@ -1173,10 +1173,10 @@ public:
class NdbDictionaryImpl & m_impl;
Dictionary(NdbDictionaryImpl&);
const Table * getIndexTable(const char * indexName,
const char * tableName);
const char * tableName) const;
public:
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
const Table * getTable(const char * name, void **data);
const Table * getTable(const char * name, void **data) const;
void set_local_table_data_size(unsigned sz);
#endif
};
......
......@@ -706,7 +706,8 @@ NdbDictionary::Dictionary::alterTable(const Table & t){
}
const NdbDictionary::Table *
NdbDictionary::Dictionary::getTable(const char * name, void **data){
NdbDictionary::Dictionary::getTable(const char * name, void **data) const
{
NdbTableImpl * t = m_impl.getTable(name, data);
if(t)
return t->m_facade;
......@@ -719,7 +720,8 @@ void NdbDictionary::Dictionary::set_local_table_data_size(unsigned sz)
}
const NdbDictionary::Table *
NdbDictionary::Dictionary::getTable(const char * name){
NdbDictionary::Dictionary::getTable(const char * name) const
{
return getTable(name, 0);
}
......@@ -752,7 +754,7 @@ NdbDictionary::Dictionary::dropIndex(const char * indexName,
const NdbDictionary::Index *
NdbDictionary::Dictionary::getIndex(const char * indexName,
const char * tableName)
const char * tableName) const
{
NdbIndexImpl * i = m_impl.getIndex(indexName, tableName);
if(i)
......@@ -782,7 +784,7 @@ NdbDictionary::Dictionary::removeCachedIndex(const char * indexName,
const NdbDictionary::Table *
NdbDictionary::Dictionary::getIndexTable(const char * indexName,
const char * tableName)
const char * tableName) const
{
NdbIndexImpl * i = m_impl.getIndex(indexName, tableName);
NdbTableImpl * t = m_impl.getTable(tableName);
......
......@@ -119,7 +119,7 @@ int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
const int retryMax = 10;
int deletedRows = 0;
int check;
NdbConnection *pTrans;
NdbTransaction *pTrans;
NdbScanOperation *pOp;
NdbError err;
......
......@@ -21,7 +21,7 @@ extern FilteredNdbOut err;
extern FilteredNdbOut info;
extern FilteredNdbOut debug;
static void callback(int, NdbConnection*, void*);
static void callback(int, NdbTransaction*, void*);
extern const char * g_connect_string;
bool
......@@ -492,7 +492,7 @@ BackupRestore::logEntry(const LogEntry & tup)
if (!m_restore)
return;
NdbConnection * trans = m_ndb->startTransaction();
NdbTransaction * trans = m_ndb->startTransaction();
if (trans == NULL)
{
// Deep shit, TODO: handle the error
......@@ -584,12 +584,12 @@ BackupRestore::endOfLogEntrys()
*
* (This function must have three arguments:
* - The result of the transaction,
* - The NdbConnection object, and
* - The NdbTransaction object, and
* - A pointer to an arbitrary object.)
*/
static void
callback(int result, NdbConnection* trans, void* aObject)
callback(int result, NdbTransaction* trans, void* aObject)
{
restore_callback_t *cb = (restore_callback_t *)aObject;
(cb->restore)->cback(result, cb);
......@@ -603,7 +603,7 @@ BackupRestore::tuple(const TupleS & tup)
return;
while (1)
{
NdbConnection * trans = m_ndb->startTransaction();
NdbTransaction * trans = m_ndb->startTransaction();
if (trans == NULL)
{
// Deep shit, TODO: handle the error
......
......@@ -21,8 +21,8 @@ extern FilteredNdbOut err;
extern FilteredNdbOut info;
extern FilteredNdbOut debug;
static bool asynchErrorHandler(NdbConnection * trans, Ndb * ndb);
static void callback(int result, NdbConnection* trans, void* aObject);
static bool asynchErrorHandler(NdbTransaction * trans, Ndb * ndb);
static void callback(int result, NdbTransaction* trans, void* aObject);
bool
BackupRestore::init()
......@@ -371,7 +371,7 @@ BackupRestore::tuple(const TupleS & tup)
return;
while (1)
{
NdbConnection * trans = m_ndb->startTransaction();
NdbTransaction * trans = m_ndb->startTransaction();
if (trans == NULL)
{
// Deep shit, TODO: handle the error
......@@ -460,7 +460,7 @@ BackupRestore::logEntry(const LogEntry & tup)
if (!m_restore)
return;
NdbConnection * trans = m_ndb->startTransaction();
NdbTransaction * trans = m_ndb->startTransaction();
if (trans == NULL)
{
// Deep shit, TODO: handle the error
......@@ -551,7 +551,7 @@ BackupRestore::endOfLogEntrys()
*
******************************************/
static void restoreCallback(int result, // Result for transaction
NdbConnection *object, // Transaction object
NdbTransaction *object, // Transaction object
void *anything) // Not used
{
static Uint32 counter = 0;
......@@ -593,12 +593,12 @@ static void restoreCallback(int result, // Result for transaction
*
* (This function must have three arguments:
* - The result of the transaction,
* - The NdbConnection object, and
* - The NdbTransaction object, and
* - A pointer to an arbitrary object.)
*/
static void
callback(int result, NdbConnection* trans, void* aObject)
callback(int result, NdbTransaction* trans, void* aObject)
{
restore_callback_t *cb = (restore_callback_t *)aObject;
(cb->restore)->cback(result, cb);
......@@ -610,7 +610,7 @@ callback(int result, NdbConnection* trans, void* aObject)
* false if it is an error that generates an abort.
*/
static
bool asynchErrorHandler(NdbConnection * trans, Ndb* ndb)
bool asynchErrorHandler(NdbTransaction * trans, Ndb* ndb)
{
NdbError error = trans->getNdbError();
ndb->closeTransaction(trans);
......
......@@ -194,7 +194,7 @@ int scanReadRecords(Ndb* pNdb,
int retryAttempt = 0;
const int retryMax = 100;
int check;
NdbConnection *pTrans;
NdbTransaction *pTrans;
NdbScanOperation *pOp;
NdbIndexScanOperation * pIOp= 0;
......
......@@ -141,7 +141,7 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab,
int retryAttempt = 0;
const int retryMax = 100;
int check;
NdbConnection *pTrans;
NdbTransaction *pTrans;
NdbScanOperation *pOp;
while (true){
......
......@@ -154,7 +154,7 @@ static int ndb_to_mysql_error(const NdbError *err)
inline
int execute_no_commit(ha_ndbcluster *h, NdbConnection *trans)
int execute_no_commit(ha_ndbcluster *h, NdbTransaction *trans)
{
int m_batch_execute= 0;
#ifdef NOT_USED
......@@ -165,7 +165,7 @@ int execute_no_commit(ha_ndbcluster *h, NdbConnection *trans)
}
inline
int execute_commit(ha_ndbcluster *h, NdbConnection *trans)
int execute_commit(ha_ndbcluster *h, NdbTransaction *trans)
{
int m_batch_execute= 0;
#ifdef NOT_USED
......@@ -176,7 +176,7 @@ int execute_commit(ha_ndbcluster *h, NdbConnection *trans)
}
inline
int execute_commit(THD *thd, NdbConnection *trans)
int execute_commit(THD *thd, NdbTransaction *trans)
{
int m_batch_execute= 0;
#ifdef NOT_USED
......@@ -187,7 +187,7 @@ int execute_commit(THD *thd, NdbConnection *trans)
}
inline
int execute_no_commit_ie(ha_ndbcluster *h, NdbConnection *trans)
int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans)
{
int m_batch_execute= 0;
#ifdef NOT_USED
......@@ -330,7 +330,7 @@ void ha_ndbcluster::no_uncommitted_rows_reset(THD *thd)
*/
int ha_ndbcluster::ndb_err(NdbConnection *trans)
int ha_ndbcluster::ndb_err(NdbTransaction *trans)
{
int res;
const NdbError err= trans->getNdbError();
......@@ -1091,7 +1091,7 @@ int ha_ndbcluster::pk_read(const byte *key, uint key_len, byte *buf)
DBUG_PRINT("enter", ("key_len: %u", key_len));
DBUG_DUMP("key", (char*)key, key_len);
uint no_fields= table->fields, i;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
NdbOperation *op;
THD *thd= current_thd;
......@@ -1141,7 +1141,7 @@ int ha_ndbcluster::pk_read(const byte *key, uint key_len, byte *buf)
int ha_ndbcluster::complemented_pk_read(const byte *old_data, byte *new_data)
{
uint no_fields= table->fields, i;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
NdbOperation *op;
THD *thd= current_thd;
DBUG_ENTER("complemented_pk_read");
......@@ -1204,7 +1204,7 @@ int ha_ndbcluster::complemented_pk_read(const byte *old_data, byte *new_data)
int ha_ndbcluster::peek_row()
{
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
NdbOperation *op;
THD *thd= current_thd;
DBUG_ENTER("peek_row");
......@@ -1235,7 +1235,7 @@ int ha_ndbcluster::unique_index_read(const byte *key,
uint key_len, byte *buf)
{
int res;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
NdbIndexOperation *op;
DBUG_ENTER("ha_ndbcluster::unique_index_read");
DBUG_PRINT("enter", ("key_len: %u, index: %u", key_len, active_index));
......@@ -1271,7 +1271,7 @@ inline int ha_ndbcluster::fetch_next(NdbScanOperation* cursor)
{
DBUG_ENTER("fetch_next");
int check;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
bool contact_ndb= m_lock.type < TL_WRITE_ALLOW_WRITE;
do {
......@@ -1551,7 +1551,7 @@ int ha_ndbcluster::define_read_attrs(byte* buf, NdbOperation* op)
{
uint i;
THD *thd= current_thd;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
DBUG_ENTER("define_read_attrs");
......@@ -1598,7 +1598,7 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key,
{
int res;
bool restart;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
NdbIndexScanOperation *op;
DBUG_ENTER("ha_ndbcluster::ordered_index_scan");
......@@ -1668,7 +1668,7 @@ int ha_ndbcluster::filtered_scan(const byte *key, uint key_len,
enum ha_rkey_function find_flag)
{
int res;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
NdbScanOperation *op;
DBUG_ENTER("filtered_scan");
......@@ -1748,7 +1748,7 @@ int ha_ndbcluster::full_table_scan(byte *buf)
uint i;
int res;
NdbScanOperation *op;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
DBUG_ENTER("full_table_scan");
DBUG_PRINT("enter", ("Starting new scan on %s", m_tabname));
......@@ -1776,7 +1776,7 @@ int ha_ndbcluster::write_row(byte *record)
{
bool has_auto_increment;
uint i;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
NdbOperation *op;
int res;
THD *thd= current_thd;
......@@ -1945,7 +1945,7 @@ int ha_ndbcluster::key_cmp(uint keynr, const byte * old_row,
int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
{
THD *thd= current_thd;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
NdbScanOperation* cursor= m_active_cursor;
NdbOperation *op;
uint i;
......@@ -2063,7 +2063,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
int ha_ndbcluster::delete_row(const byte *record)
{
THD *thd= current_thd;
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
NdbScanOperation* cursor= m_active_cursor;
NdbOperation *op;
DBUG_ENTER("delete_row");
......@@ -2635,7 +2635,7 @@ int ha_ndbcluster::rnd_init(bool scan)
int ha_ndbcluster::close_scan()
{
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
DBUG_ENTER("close_scan");
m_multi_cursor= 0;
......@@ -2983,7 +2983,7 @@ int ha_ndbcluster::end_bulk_insert()
// Check if last inserts need to be flushed
if (m_bulk_insert_not_flushed)
{
NdbConnection *trans= m_active_trans;
NdbTransaction *trans= m_active_trans;
// Send rows to NDB
DBUG_PRINT("info", ("Sending inserts to NDB, "\
"rows_inserted:%d, bulk_insert_rows: %d",
......@@ -3102,7 +3102,7 @@ THR_LOCK_DATA **ha_ndbcluster::store_lock(THD *thd,
int ha_ndbcluster::external_lock(THD *thd, int lock_type)
{
int error=0;
NdbConnection* trans= NULL;
NdbTransaction* trans= NULL;
DBUG_ENTER("external_lock");
/*
......@@ -3189,8 +3189,8 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
// m_use_local_query_cache= thd->variables.ndb_use_local_query_cache;
m_active_trans= thd->transaction.all.ndb_tid ?
(NdbConnection*)thd->transaction.all.ndb_tid:
(NdbConnection*)thd->transaction.stmt.ndb_tid;
(NdbTransaction*)thd->transaction.all.ndb_tid:
(NdbTransaction*)thd->transaction.stmt.ndb_tid;
DBUG_ASSERT(m_active_trans);
// Start of transaction
m_retrieve_all_fields= FALSE;
......@@ -3272,13 +3272,13 @@ int ha_ndbcluster::start_stmt(THD *thd)
DBUG_ENTER("start_stmt");
PRINT_OPTION_FLAGS(thd);
NdbConnection *trans= (NdbConnection*)thd->transaction.stmt.ndb_tid;
NdbTransaction *trans= (NdbTransaction*)thd->transaction.stmt.ndb_tid;
if (!trans){
Ndb *ndb= ((Thd_ndb*)thd->transaction.thd_ndb)->ndb;
DBUG_PRINT("trans",("Starting transaction stmt"));
NdbConnection *tablock_trans=
(NdbConnection*)thd->transaction.all.ndb_tid;
NdbTransaction *tablock_trans=
(NdbTransaction*)thd->transaction.all.ndb_tid;
DBUG_PRINT("info", ("tablock_trans: %x", (uint)tablock_trans));
DBUG_ASSERT(tablock_trans);
// trans= ndb->hupp(tablock_trans);
......@@ -3307,7 +3307,7 @@ int ndbcluster_commit(THD *thd, void *ndb_transaction)
{
int res= 0;
Ndb *ndb= ((Thd_ndb*)thd->transaction.thd_ndb)->ndb;
NdbConnection *trans= (NdbConnection*)ndb_transaction;
NdbTransaction *trans= (NdbTransaction*)ndb_transaction;
DBUG_ENTER("ndbcluster_commit");
DBUG_PRINT("transaction",("%s",
......@@ -3337,7 +3337,7 @@ int ndbcluster_rollback(THD *thd, void *ndb_transaction)
{
int res= 0;
Ndb *ndb= ((Thd_ndb*)thd->transaction.thd_ndb)->ndb;
NdbConnection *trans= (NdbConnection*)ndb_transaction;
NdbTransaction *trans= (NdbTransaction*)ndb_transaction;
DBUG_ENTER("ndbcluster_rollback");
DBUG_PRINT("transaction",("%s",
......@@ -4842,7 +4842,7 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
{
DBUG_ENTER("ndb_get_table_statistics");
DBUG_PRINT("enter", ("table: %s", table));
NdbConnection* pTrans= ndb->startTransaction();
NdbTransaction* pTrans= ndb->startTransaction();
do
{
if (pTrans == NULL)
......
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