Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
c33a0fc5
Commit
c33a0fc5
authored
Jan 04, 2005
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated all examples to use mysql c-api create table
parent
d10e6cf0
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
286 additions
and
340 deletions
+286
-340
ndb/examples/ndbapi_async_example/Makefile
ndb/examples/ndbapi_async_example/Makefile
+12
-23
ndb/examples/ndbapi_async_example/ndbapi_async.cpp
ndb/examples/ndbapi_async_example/ndbapi_async.cpp
+71
-89
ndb/examples/ndbapi_example1/ndbapi_example1.cpp
ndb/examples/ndbapi_example1/ndbapi_example1.cpp
+3
-3
ndb/examples/ndbapi_example4/Makefile
ndb/examples/ndbapi_example4/Makefile
+10
-8
ndb/examples/ndbapi_example4/ndbapi_example4.cpp
ndb/examples/ndbapi_example4/ndbapi_example4.cpp
+98
-128
ndb/examples/ndbapi_scan_example/Makefile
ndb/examples/ndbapi_scan_example/Makefile
+6
-6
ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp
ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp
+86
-83
No files found.
ndb/examples/ndbapi_async_example/Makefile
View file @
c33a0fc5
-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)
$(C
C)
$(LFLAGS)
-L
$(LIB_DIR)
-lNDB_API
$(OBJS)
$(SYS_LIB)
-o
$(TARGET)
$(C
XX)
$(CXXFLAGS)
$(LFLAGS)
$(LIB_DIR)
$(OBJS)
-lndbclient
-lmysqlclient_r
-lmysys
-lz
$(SYS_LIB)
-o
$(TARGET)
$(TARGET).o
:
$(SRCS)
$(C
C)
$(CFLAGS)
-I
$(INCLUDE_DIR)
-I
$(INCLUDE_DIR)
/ndbapi
$(SRCS)
$(C
XX)
$(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)
ndb/examples/ndbapi_async_example/ndbapi_async.cpp
View file @
c33a0fc5
...
...
@@ -24,9 +24,12 @@
*
* Classes and methods in NDBAPI used in this example:
*
* Ndb_cluster_connection
* connect()
* wait_until_ready()
*
* Ndb
* init()
* waitUntilRead()
* getDictionary()
* startTransaction()
* closeTransaction()
...
...
@@ -38,23 +41,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 +49,10 @@
*/
#include <
ndb_globa
l.h>
#include <
mysq
l.h>
#include <mysqld_error.h>
#include <NdbApi.hpp>
#include <NdbScanFilter.hpp>
#include <iostream> // Used for cout
/**
...
...
@@ -85,11 +71,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
/**
...
...
@@ -207,61 +198,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
;
}
...
...
@@ -455,22 +411,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
*/
...
...
ndb/examples/ndbapi_example1/ndbapi_example1.cpp
View file @
c33a0fc5
...
...
@@ -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
);
...
...
ndb/examples/ndbapi_example4/Makefile
View file @
c33a0fc5
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)
ndb/examples/ndbapi_example4/ndbapi_example4.cpp
View file @
c33a0fc5
This diff is collapsed.
Click to expand it.
ndb/examples/ndbapi_scan_example/Makefile
View file @
c33a0fc5
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)
ndb/examples/ndbapi_scan_example/ndbapi_scan.cpp
View file @
c33a0fc5
...
...
@@ -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
->
readTuples
Exclusive
(
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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment