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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8fdc781d
Commit
8fdc781d
authored
Sep 01, 2006
by
mskold/marty@mysql.com/linux.site
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed ndbapi-examples, and added tests for mysql-test-run.pl
parent
6bac3b8f
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
1016 additions
and
80 deletions
+1016
-80
mysql-test/include/have_ndbapi_examples.inc
mysql-test/include/have_ndbapi_examples.inc
+4
-0
mysql-test/mysql-test-run.pl
mysql-test/mysql-test-run.pl
+24
-0
mysql-test/r/have_ndbapi_examples.require
mysql-test/r/have_ndbapi_examples.require
+2
-0
mysql-test/r/ndbapi.result
mysql-test/r/ndbapi.result
+22
-0
mysql-test/r/rpl_ndbapi_multi.result
mysql-test/r/rpl_ndbapi_multi.result
+7
-0
mysql-test/t/ndbapi.test
mysql-test/t/ndbapi.test
+44
-0
mysql-test/t/rpl_ndbapi_multi.test
mysql-test/t/rpl_ndbapi_multi.test
+10
-0
storage/ndb/ndbapi-examples/Makefile
storage/ndb/ndbapi-examples/Makefile
+3
-1
storage/ndb/ndbapi-examples/mgmapi_logevent/Makefile
storage/ndb/ndbapi-examples/mgmapi_logevent/Makefile
+1
-0
storage/ndb/ndbapi-examples/mgmapi_logevent/mgmapi_logevent.cpp
...e/ndb/ndbapi-examples/mgmapi_logevent/mgmapi_logevent.cpp
+18
-4
storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile
storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile
+24
-0
storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp
...pi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp
+225
-0
storage/ndb/ndbapi-examples/ndbapi_async/Makefile
storage/ndb/ndbapi-examples/ndbapi_async/Makefile
+1
-0
storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp
storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp
+41
-25
storage/ndb/ndbapi-examples/ndbapi_async1/Makefile
storage/ndb/ndbapi-examples/ndbapi_async1/Makefile
+3
-2
storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp
storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp
+68
-13
storage/ndb/ndbapi-examples/ndbapi_event/Makefile
storage/ndb/ndbapi-examples/ndbapi_event/Makefile
+1
-0
storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp
storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp
+13
-6
storage/ndb/ndbapi-examples/ndbapi_retries/Makefile
storage/ndb/ndbapi-examples/ndbapi_retries/Makefile
+3
-2
storage/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp
...age/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp
+61
-6
storage/ndb/ndbapi-examples/ndbapi_scan/Makefile
storage/ndb/ndbapi-examples/ndbapi_scan/Makefile
+1
-0
storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp
storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp
+31
-11
storage/ndb/ndbapi-examples/ndbapi_simple/Makefile
storage/ndb/ndbapi-examples/ndbapi_simple/Makefile
+1
-0
storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp
storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp
+24
-6
storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile
storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile
+24
-0
storage/ndb/ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp
...ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp
+348
-0
storage/ndb/ndbapi-examples/ndbapi_simple_index/Makefile
storage/ndb/ndbapi-examples/ndbapi_simple_index/Makefile
+1
-0
storage/ndb/ndbapi-examples/ndbapi_simple_index/ndbapi_simple_index.cpp
...bapi-examples/ndbapi_simple_index/ndbapi_simple_index.cpp
+11
-4
No files found.
mysql-test/include/have_ndbapi_examples.inc
0 → 100644
View file @
8fdc781d
--
require
r
/
have_ndbapi_examples
.
require
disable_query_log
;
eval
select
LENGTH
(
"
$MY_NDB_EXAMPLES_BINARY
"
)
>
0
as
"have_ndb_example"
;
enable_query_log
;
mysql-test/mysql-test-run.pl
View file @
8fdc781d
...
@@ -323,6 +323,8 @@ our $opt_skip_slave_binlog= 0;
...
@@ -323,6 +323,8 @@ our $opt_skip_slave_binlog= 0;
our
$exe_ndb_mgm
;
our
$exe_ndb_mgm
;
our
$exe_ndb_waiter
;
our
$exe_ndb_waiter
;
our
$path_ndb_tools_dir
;
our
$path_ndb_tools_dir
;
our
$path_ndb_examples_dir
;
our
$exe_ndb_example
;
our
$file_ndb_testrun_log
;
our
$file_ndb_testrun_log
;
our
@data_dir_lst
;
our
@data_dir_lst
;
...
@@ -1233,6 +1235,9 @@ sub executable_setup () {
...
@@ -1233,6 +1235,9 @@ sub executable_setup () {
mtr_script_exists
("
$glob_basedir
/scripts/mysql_fix_privilege_tables
",
mtr_script_exists
("
$glob_basedir
/scripts/mysql_fix_privilege_tables
",
"
/usr/bin/false
");
"
/usr/bin/false
");
$path_ndb_tools_dir
=
mtr_path_exists
("
$glob_basedir
/storage/ndb/tools
");
$path_ndb_tools_dir
=
mtr_path_exists
("
$glob_basedir
/storage/ndb/tools
");
$path_ndb_examples_dir
=
mtr_path_exists
("
$glob_basedir
/storage/ndb/ndbapi-examples
");
$exe_ndb_example
=
mtr_exe_exists
("
$path_ndb_examples_dir
/ndbapi_simple/ndbapi_simple
",
$exe_mysqld
);
$exe_ndb_mgm
=
"
$glob_basedir
/storage/ndb/src/mgmclient/ndb_mgm
";
$exe_ndb_mgm
=
"
$glob_basedir
/storage/ndb/src/mgmclient/ndb_mgm
";
$exe_ndb_waiter
=
"
$glob_basedir
/storage/ndb/tools/ndb_waiter
";
$exe_ndb_waiter
=
"
$glob_basedir
/storage/ndb/tools/ndb_waiter
";
$exe_ndbd
=
"
$glob_basedir
/storage/ndb/src/kernel/ndbd
";
$exe_ndbd
=
"
$glob_basedir
/storage/ndb/src/kernel/ndbd
";
...
@@ -1297,6 +1302,7 @@ sub executable_setup () {
...
@@ -1297,6 +1302,7 @@ sub executable_setup () {
}
}
$path_ndb_tools_dir
=
"
$glob_basedir
/bin
";
$path_ndb_tools_dir
=
"
$glob_basedir
/bin
";
$path_ndb_examples_dir
=
"
$glob_basedir
/ndbapi-examples
";
$exe_ndb_mgm
=
"
$glob_basedir
/bin/ndb_mgm
";
$exe_ndb_mgm
=
"
$glob_basedir
/bin/ndb_mgm
";
$exe_ndb_waiter
=
"
$glob_basedir
/bin/ndb_waiter
";
$exe_ndb_waiter
=
"
$glob_basedir
/bin/ndb_waiter
";
$exe_ndbd
=
"
$glob_basedir
/bin/ndbd
";
$exe_ndbd
=
"
$glob_basedir
/bin/ndbd
";
...
@@ -1344,6 +1350,20 @@ sub environment_setup () {
...
@@ -1344,6 +1350,20 @@ sub environment_setup () {
(
$lib_udf_example
?
dirname
(
$lib_udf_example
)
:
"")
.
(
$lib_udf_example
?
dirname
(
$lib_udf_example
)
:
"")
.
(
$ENV
{'
LD_LIBRARY_PATH
'}
?
"
:
$ENV
{'LD_LIBRARY_PATH'}
"
:
"");
(
$ENV
{'
LD_LIBRARY_PATH
'}
?
"
:
$ENV
{'LD_LIBRARY_PATH'}
"
:
"");
# --------------------------------------------------------------------------
# Add the path where libndbclient can be found
# --------------------------------------------------------------------------
$ENV
{'
LD_LIBRARY_PATH
'}
=
(
mtr_path_exists
("
$glob_basedir
/storage/ndb/src/.libs
")
?
"
$glob_basedir
/storage/ndb/src/.libs
"
:
"")
.
(
$ENV
{'
LD_LIBRARY_PATH
'}
?
"
:
$ENV
{'LD_LIBRARY_PATH'}
"
:
"");
# --------------------------------------------------------------------------
# Add the path where libmysqlclient can be found
# --------------------------------------------------------------------------
$ENV
{'
LD_LIBRARY_PATH
'}
=
(
mtr_path_exists
("
$glob_basedir
/libmysql_r/.libs
")
?
"
$glob_basedir
/libmysql_r/.libs
"
:
"")
.
(
$ENV
{'
LD_LIBRARY_PATH
'}
?
"
:
$ENV
{'LD_LIBRARY_PATH'}
"
:
"");
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------
# Also command lines in .opt files may contain env vars
# Also command lines in .opt files may contain env vars
...
@@ -1360,6 +1380,7 @@ sub environment_setup () {
...
@@ -1360,6 +1380,7 @@ sub environment_setup () {
$ENV
{'
MASTER_MYSOCK1
'}
=
$master
->
[
1
]
->
{'
path_sock
'};
$ENV
{'
MASTER_MYSOCK1
'}
=
$master
->
[
1
]
->
{'
path_sock
'};
$ENV
{'
MASTER_MYPORT
'}
=
$master
->
[
0
]
->
{'
port
'};
$ENV
{'
MASTER_MYPORT
'}
=
$master
->
[
0
]
->
{'
port
'};
$ENV
{'
MASTER_MYPORT1
'}
=
$master
->
[
1
]
->
{'
port
'};
$ENV
{'
MASTER_MYPORT1
'}
=
$master
->
[
1
]
->
{'
port
'};
$ENV
{'
SLAVE_MYSOCK
'}
=
$slave
->
[
0
]
->
{'
path_sock
'};
$ENV
{'
SLAVE_MYPORT
'}
=
$slave
->
[
0
]
->
{'
port
'};
$ENV
{'
SLAVE_MYPORT
'}
=
$slave
->
[
0
]
->
{'
port
'};
$ENV
{'
SLAVE_MYPORT1
'}
=
$slave
->
[
1
]
->
{'
port
'};
$ENV
{'
SLAVE_MYPORT1
'}
=
$slave
->
[
1
]
->
{'
port
'};
$ENV
{'
SLAVE_MYPORT2
'}
=
$slave
->
[
2
]
->
{'
port
'};
$ENV
{'
SLAVE_MYPORT2
'}
=
$slave
->
[
2
]
->
{'
port
'};
...
@@ -3802,7 +3823,10 @@ sub run_mysqltest ($) {
...
@@ -3802,7 +3823,10 @@ sub run_mysqltest ($) {
$ENV
{'
NDB_BACKUP_DIR
'}
=
$clusters
->
[
0
]
->
{'
data_dir
'};
$ENV
{'
NDB_BACKUP_DIR
'}
=
$clusters
->
[
0
]
->
{'
data_dir
'};
$ENV
{'
NDB_DATA_DIR
'}
=
$clusters
->
[
0
]
->
{'
data_dir
'};
$ENV
{'
NDB_DATA_DIR
'}
=
$clusters
->
[
0
]
->
{'
data_dir
'};
$ENV
{'
NDB_TOOLS_DIR
'}
=
$path_ndb_tools_dir
;
$ENV
{'
NDB_TOOLS_DIR
'}
=
$path_ndb_tools_dir
;
$ENV
{'
NDB_EXAMPLES_DIR
'}
=
$path_ndb_examples_dir
;
$ENV
{'
MY_NDB_EXAMPLES_BINARY
'}
=
(
$exe_ndb_example
eq
"
$path_ndb_examples_dir
/ndbapi_simple/ndbapi_simple
")?
$exe_ndb_example:
"";
$ENV
{'
NDB_TOOLS_OUTPUT
'}
=
$file_ndb_testrun_log
;
$ENV
{'
NDB_TOOLS_OUTPUT
'}
=
$file_ndb_testrun_log
;
$ENV
{'
NDB_EXAMPLES_OUTPUT
'}
=
$file_ndb_testrun_log
;
$ENV
{'
NDB_CONNECTSTRING
'}
=
$opt_ndbconnectstring
;
$ENV
{'
NDB_CONNECTSTRING
'}
=
$opt_ndbconnectstring
;
my
$exe
=
$exe_mysqltest
;
my
$exe
=
$exe_mysqltest
;
...
...
mysql-test/r/have_ndbapi_examples.require
0 → 100644
View file @
8fdc781d
have_ndb_example
1
mysql-test/r/ndbapi.result
0 → 100644
View file @
8fdc781d
DROP TABLE IF EXISTS t0;
drop database if exists mysqltest;
Running ndbapi_simple, results in /windows/Linux_space/MySQL/mysql-5.1/mysql-test/var/log/ndb_testrun.log
Running ndbapi_simple_index, results in /windows/Linux_space/MySQL/mysql-5.1/mysql-test/var/log/ndb_testrun.log
Running ndbapi_scan, results in /windows/Linux_space/MySQL/mysql-5.1/mysql-test/var/log/ndb_testrun.log
Running ndbapi_retries, results in /windows/Linux_space/MySQL/mysql-5.1/mysql-test/var/log/ndb_testrun.log
Running ndbapi_async, results in /windows/Linux_space/MySQL/mysql-5.1/mysql-test/var/log/ndb_testrun.log
Running ndbapi_async1, results in /windows/Linux_space/MySQL/mysql-5.1/mysql-test/var/log/ndb_testrun.log
use TEST_DB;
create table t0(c0 int, c1 int, c2 char(4), c3 char(4), c4 text,
primary key(c0, c2)) engine ndb charset latin1;
insert into t0 values (1, 2, 'a', 'b', null);
insert into t0 values (3, 4, 'c', 'd', null);
update t0 set c3 = 'e' where c0 = 1 and c2 = 'a';
update t0 set c3 = 'f';
update t0 set c3 = 'F';
update t0 set c2 = 'g' where c0 = 1;
update t0 set c2 = 'G' where c0 = 1;
update t0 set c0 = 5, c2 = 'H' where c0 = 3;
delete from t0;
drop table t0;
Running mgmapi_logevent, results in /windows/Linux_space/MySQL/mysql-5.1/mysql-test/var/log/ndb_testrun.log
mysql-test/r/rpl_ndbapi_multi.result
0 → 100644
View file @
8fdc781d
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
Running mgmapi_logevent, results in /windows/Linux_space/MySQL/mysql-5.1/mysql-test/var/log/ndb_testrun.log
mysql-test/t/ndbapi.test
0 → 100644
View file @
8fdc781d
--
source
include
/
have_ndb
.
inc
--
source
include
/
have_ndbapi_examples
.
inc
--
disable_warnings
DROP
TABLE
IF
EXISTS
t0
;
drop
database
if
exists
mysqltest
;
--
enable_warnings
--
exec
echo
Running
ndbapi_simple
,
results
in
$NDB_EXAMPLES_OUTPUT
--
exec
$NDB_EXAMPLES_DIR
/
ndbapi_simple
/
ndbapi_simple
$MASTER_MYSOCK
"localhost:
$NDBCLUSTER_PORT
"
>>
$NDB_EXAMPLES_OUTPUT
--
exec
echo
Running
ndbapi_simple_index
,
results
in
$NDB_EXAMPLES_OUTPUT
--
exec
$NDB_EXAMPLES_DIR
/
ndbapi_simple_index
/
ndbapi_simple_index
$MASTER_MYSOCK
"localhost:
$NDBCLUSTER_PORT
"
>>
$NDB_EXAMPLES_OUTPUT
--
exec
echo
Running
ndbapi_scan
,
results
in
$NDB_EXAMPLES_OUTPUT
--
exec
$NDB_EXAMPLES_DIR
/
ndbapi_scan
/
ndbapi_scan
$MASTER_MYSOCK
"localhost:
$NDBCLUSTER_PORT
"
>>
$NDB_EXAMPLES_OUTPUT
--
exec
echo
Running
ndbapi_retries
,
results
in
$NDB_EXAMPLES_OUTPUT
--
exec
$NDB_EXAMPLES_DIR
/
ndbapi_retries
/
ndbapi_retries
$MASTER_MYSOCK
"localhost:
$NDBCLUSTER_PORT
"
>>
$NDB_EXAMPLES_OUTPUT
--
exec
echo
Running
ndbapi_async
,
results
in
$NDB_EXAMPLES_OUTPUT
--
exec
$NDB_EXAMPLES_DIR
/
ndbapi_async
/
ndbapi_async
$MASTER_MYSOCK
"localhost:
$NDBCLUSTER_PORT
"
>>
$NDB_EXAMPLES_OUTPUT
--
exec
echo
Running
ndbapi_async1
,
results
in
$NDB_EXAMPLES_OUTPUT
--
exec
$NDB_EXAMPLES_DIR
/
ndbapi_async1
/
ndbapi_async1
$MASTER_MYSOCK
"localhost:
$NDBCLUSTER_PORT
"
>>
$NDB_EXAMPLES_OUTPUT
use
TEST_DB
;
create
table
t0
(
c0
int
,
c1
int
,
c2
char
(
4
),
c3
char
(
4
),
c4
text
,
primary
key
(
c0
,
c2
))
engine
ndb
charset
latin1
;
#--exec echo Running ndbapi_event, results in $NDB_EXAMPLES_OUTPUT
#--exec $NDB_EXAMPLES_DIR/ndbapi_event/ndbapi_event "localhost:$NDBCLUSTER_PORT" 1 >> $NDB_EXAMPLES_OUTPUT
insert
into
t0
values
(
1
,
2
,
'a'
,
'b'
,
null
);
insert
into
t0
values
(
3
,
4
,
'c'
,
'd'
,
null
);
update
t0
set
c3
=
'e'
where
c0
=
1
and
c2
=
'a'
;
--
use
pk
update t0 set c3 = 'f'
;
--
use
scan
update t0 set c3 = 'F'
;
--
use
scan
update to 'same'
update t0 set c2 = 'g' where c0 = 1
;
--
update
pk
part
update
t0
set
c2
=
'G'
where
c0
=
1
;
--
update
pk
part
to
'same'
update
t0
set
c0
=
5
,
c2
=
'H'
where
c0
=
3
;
--
update
full
PK
delete
from
t0
;
drop
table
t0
;
--
exec
echo
Running
mgmapi_logevent
,
results
in
$NDB_EXAMPLES_OUTPUT
--
exec
$NDB_EXAMPLES_DIR
/
mgmapi_logevent
/
mgmapi_logevent
"localhost:
$NDBCLUSTER_PORT
"
1
>>
$NDB_EXAMPLES_OUTPUT
mysql-test/t/rpl_ndbapi_multi.test
0 → 100644
View file @
8fdc781d
--
source
include
/
have_ndb
.
inc
--
source
include
/
have_binlog_format_row
.
inc
--
source
include
/
master
-
slave
.
inc
--
source
include
/
have_ndbapi_examples
.
inc
--
exec
$NDB_EXAMPLES_DIR
/
ndbapi_simple_dual
/
ndbapi_simple_dual
$MASTER_MYSOCK
"localhost:
$NDBCLUSTER_PORT
"
$SLAVE_MYSOCK
"localhost:
$NDBCLUSTER_PORT_SLAVE
"
>>
$NDB_EXAMPLES_OUTPUT
--
exec
echo
Running
mgmapi_logevent
,
results
in
$NDB_EXAMPLES_OUTPUT
--
exec
$NDB_EXAMPLES_DIR
/
mgmapi_logevent
/
mgmapi_logevent
"localhost:
$NDBCLUSTER_PORT
"
"localhost:
$NDBCLUSTER_PORT_SLAVE
"
1
>>
$NDB_EXAMPLES_OUTPUT
storage/ndb/ndbapi-examples/Makefile
View file @
8fdc781d
...
@@ -5,7 +5,9 @@ BIN_DIRS := ndbapi_simple \
...
@@ -5,7 +5,9 @@ BIN_DIRS := ndbapi_simple \
ndbapi_simple_index
\
ndbapi_simple_index
\
ndbapi_event
\
ndbapi_event
\
ndbapi_scan
\
ndbapi_scan
\
mgmapi_logevent
mgmapi_logevent
\
ndbapi_simple_dual
\
mgmapi_logevent_dual
bins
:
$(patsubst %
,
_bins_%
,
$(BIN_DIRS))
bins
:
$(patsubst %
,
_bins_%
,
$(BIN_DIRS))
...
...
storage/ndb/ndbapi-examples/mgmapi_logevent/Makefile
View file @
8fdc781d
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb/include
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb/include
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
SYS_LIB
=
...
...
storage/ndb/ndbapi-examples/mgmapi_logevent/mgmapi_logevent.cpp
View file @
8fdc781d
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
exit(-1); \
exit(-1); \
}
}
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
{
NdbMgmHandle
h
;
NdbMgmHandle
h
;
NdbLogEventHandle
le
;
NdbLogEventHandle
le
;
...
@@ -51,22 +51,36 @@ int main()
...
@@ -51,22 +51,36 @@ int main()
0
};
0
};
struct
ndb_logevent
event
;
struct
ndb_logevent
event
;
if
(
argc
<
2
)
{
printf
(
"Arguments are <connect_string cluster> [<iterations>].
\n
"
);
exit
(
-
1
);
}
const
char
*
connectstring
=
argv
[
1
];
int
iterations
=
-
1
;
if
(
argc
>
2
)
iterations
=
atoi
(
argv
[
2
]);
ndb_init
();
ndb_init
();
h
=
ndb_mgm_create_handle
();
h
=
ndb_mgm_create_handle
();
if
(
h
==
0
)
if
(
h
==
0
)
{
{
printf
(
"Unable to create handle
\n
"
);
printf
(
"Unable to create handle
\n
"
);
exit
(
-
1
);
exit
(
-
1
);
}
}
if
(
ndb_mgm_set_connectstring
(
h
,
connectstring
)
==
-
1
)
{
printf
(
"Unable to set connectstring
\n
"
);
exit
(
-
1
);
}
if
(
ndb_mgm_connect
(
h
,
0
,
0
,
0
))
MGMERROR
(
h
);
if
(
ndb_mgm_connect
(
h
,
0
,
0
,
0
))
MGMERROR
(
h
);
le
=
ndb_mgm_create_logevent_handle
(
h
,
filter
);
le
=
ndb_mgm_create_logevent_handle
(
h
,
filter
);
if
(
le
==
0
)
MGMERROR
(
h
);
if
(
le
==
0
)
MGMERROR
(
h
);
while
(
1
)
while
(
iterations
--
!=
0
)
{
{
int
timeout
=
5
000
;
int
timeout
=
1
000
;
int
r
=
ndb_logevent_get_next
(
le
,
&
event
,
timeout
);
int
r
=
ndb_logevent_get_next
(
le
,
&
event
,
timeout
);
if
(
r
==
0
)
if
(
r
==
0
)
printf
(
"No event within %d milliseconds
\n
"
,
timeout
);
printf
(
"No event within %d milliseconds
\n
"
,
timeout
);
...
...
storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile
0 → 100644
View file @
8fdc781d
TARGET
=
mgmapi_logevent_dual
SRCS
=
$(TARGET)
.cpp
OBJS
=
$(TARGET)
.o
CXX
=
g++
CFLAGS
=
-c
-Wall
-fno-rtti
-fno-exceptions
CXXFLAGS
=
DEBUG
=
LFLAGS
=
-Wall
TOP_SRCDIR
=
../../../..
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb/include
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
$(TARGET)
:
$(OBJS)
$(CXX)
$(CXXFLAGS)
$(LFLAGS)
$(LIB_DIR)
$(OBJS)
-lndbclient
-lmysqlclient_r
-lmysys
-lmystrings
-lz
$(SYS_LIB)
-o
$(TARGET)
$(TARGET).o
:
$(SRCS)
$(CXX)
$(CFLAGS)
-I
$(TOP_SRCDIR)
/include
-I
$(INCLUDE_DIR)
-I
$(INCLUDE_DIR)
/mgmapi
-I
$(INCLUDE_DIR)
/ndbapi
$(SRCS)
clean
:
rm
-f
*
.o
$(TARGET)
storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp
0 → 100644
View file @
8fdc781d
/* 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 */
#include <mysql.h>
#include <ndbapi/NdbApi.hpp>
#include <mgmapi.h>
#include <stdio.h>
/*
* export LD_LIBRARY_PATH=../../../libmysql_r/.libs:../../../ndb/src/.libs
*/
#define MGMERROR(h) \
{ \
fprintf(stderr, "code: %d msg: %s\n", \
ndb_mgm_get_latest_error(h), \
ndb_mgm_get_latest_error_msg(h)); \
exit(-1); \
}
#define LOGEVENTERROR(h) \
{ \
fprintf(stderr, "code: %d msg: %s\n", \
ndb_logevent_get_latest_error(h), \
ndb_logevent_get_latest_error_msg(h)); \
exit(-1); \
}
int
main
(
int
argc
,
char
**
argv
)
{
NdbMgmHandle
h1
,
h2
;
NdbLogEventHandle
le1
,
le2
;
int
filter
[]
=
{
15
,
NDB_MGM_EVENT_CATEGORY_BACKUP
,
15
,
NDB_MGM_EVENT_CATEGORY_CONNECTION
,
15
,
NDB_MGM_EVENT_CATEGORY_NODE_RESTART
,
15
,
NDB_MGM_EVENT_CATEGORY_STARTUP
,
15
,
NDB_MGM_EVENT_CATEGORY_ERROR
,
0
};
struct
ndb_logevent
event1
,
event2
;
if
(
argc
<
3
)
{
printf
(
"Arguments are <connect_string cluster 1> <connect_string cluster 2> [<iterations>].
\n
"
);
exit
(
-
1
);
}
const
char
*
connectstring1
=
argv
[
1
];
const
char
*
connectstring2
=
argv
[
2
];
int
iterations
=
-
1
;
if
(
argc
>
3
)
iterations
=
atoi
(
argv
[
3
]);
ndb_init
();
h1
=
ndb_mgm_create_handle
();
h2
=
ndb_mgm_create_handle
();
if
(
h1
==
0
||
h2
==
0
)
{
printf
(
"Unable to create handle
\n
"
);
exit
(
-
1
);
}
if
(
ndb_mgm_set_connectstring
(
h1
,
connectstring1
)
==
-
1
||
ndb_mgm_set_connectstring
(
h2
,
connectstring1
))
{
printf
(
"Unable to set connectstring
\n
"
);
exit
(
-
1
);
}
if
(
ndb_mgm_connect
(
h1
,
0
,
0
,
0
))
MGMERROR
(
h1
);
if
(
ndb_mgm_connect
(
h2
,
0
,
0
,
0
))
MGMERROR
(
h2
);
if
((
le1
=
ndb_mgm_create_logevent_handle
(
h1
,
filter
))
==
0
)
MGMERROR
(
h1
);
if
((
le2
=
ndb_mgm_create_logevent_handle
(
h1
,
filter
))
==
0
)
MGMERROR
(
h2
);
while
(
iterations
--
!=
0
)
{
int
timeout
=
1000
;
int
r1
=
ndb_logevent_get_next
(
le1
,
&
event1
,
timeout
);
if
(
r1
==
0
)
printf
(
"No event within %d milliseconds
\n
"
,
timeout
);
else
if
(
r1
<
0
)
LOGEVENTERROR
(
le1
)
else
{
switch
(
event1
.
type
)
{
case
NDB_LE_BackupStarted
:
printf
(
"Node %d: BackupStarted
\n
"
,
event1
.
source_nodeid
);
printf
(
" Starting node ID: %d
\n
"
,
event1
.
BackupStarted
.
starting_node
);
printf
(
" Backup ID: %d
\n
"
,
event1
.
BackupStarted
.
backup_id
);
break
;
case
NDB_LE_BackupCompleted
:
printf
(
"Node %d: BackupCompleted
\n
"
,
event1
.
source_nodeid
);
printf
(
" Backup ID: %d
\n
"
,
event1
.
BackupStarted
.
backup_id
);
break
;
case
NDB_LE_BackupAborted
:
printf
(
"Node %d: BackupAborted
\n
"
,
event1
.
source_nodeid
);
break
;
case
NDB_LE_BackupFailedToStart
:
printf
(
"Node %d: BackupFailedToStart
\n
"
,
event1
.
source_nodeid
);
break
;
case
NDB_LE_NodeFailCompleted
:
printf
(
"Node %d: NodeFailCompleted
\n
"
,
event1
.
source_nodeid
);
break
;
case
NDB_LE_ArbitResult
:
printf
(
"Node %d: ArbitResult
\n
"
,
event1
.
source_nodeid
);
printf
(
" code %d, arbit_node %d
\n
"
,
event1
.
ArbitResult
.
code
&
0xffff
,
event1
.
ArbitResult
.
arbit_node
);
break
;
case
NDB_LE_DeadDueToHeartbeat
:
printf
(
"Node %d: DeadDueToHeartbeat
\n
"
,
event1
.
source_nodeid
);
printf
(
" node %d
\n
"
,
event1
.
DeadDueToHeartbeat
.
node
);
break
;
case
NDB_LE_Connected
:
printf
(
"Node %d: Connected
\n
"
,
event1
.
source_nodeid
);
printf
(
" node %d
\n
"
,
event1
.
Connected
.
node
);
break
;
case
NDB_LE_Disconnected
:
printf
(
"Node %d: Disconnected
\n
"
,
event1
.
source_nodeid
);
printf
(
" node %d
\n
"
,
event1
.
Disconnected
.
node
);
break
;
case
NDB_LE_NDBStartCompleted
:
printf
(
"Node %d: StartCompleted
\n
"
,
event1
.
source_nodeid
);
printf
(
" version %d.%d.%d
\n
"
,
event1
.
NDBStartCompleted
.
version
>>
16
&
0xff
,
event1
.
NDBStartCompleted
.
version
>>
8
&
0xff
,
event1
.
NDBStartCompleted
.
version
>>
0
&
0xff
);
break
;
case
NDB_LE_ArbitState
:
printf
(
"Node %d: ArbitState
\n
"
,
event1
.
source_nodeid
);
printf
(
" code %d, arbit_node %d
\n
"
,
event1
.
ArbitState
.
code
&
0xffff
,
event1
.
ArbitResult
.
arbit_node
);
break
;
default:
break
;
}
}
int
r2
=
ndb_logevent_get_next
(
le1
,
&
event2
,
timeout
);
if
(
r2
==
0
)
printf
(
"No event within %d milliseconds
\n
"
,
timeout
);
else
if
(
r2
<
0
)
LOGEVENTERROR
(
le2
)
else
{
switch
(
event2
.
type
)
{
case
NDB_LE_BackupStarted
:
printf
(
"Node %d: BackupStarted
\n
"
,
event2
.
source_nodeid
);
printf
(
" Starting node ID: %d
\n
"
,
event2
.
BackupStarted
.
starting_node
);
printf
(
" Backup ID: %d
\n
"
,
event2
.
BackupStarted
.
backup_id
);
break
;
case
NDB_LE_BackupCompleted
:
printf
(
"Node %d: BackupCompleted
\n
"
,
event2
.
source_nodeid
);
printf
(
" Backup ID: %d
\n
"
,
event2
.
BackupStarted
.
backup_id
);
break
;
case
NDB_LE_BackupAborted
:
printf
(
"Node %d: BackupAborted
\n
"
,
event2
.
source_nodeid
);
break
;
case
NDB_LE_BackupFailedToStart
:
printf
(
"Node %d: BackupFailedToStart
\n
"
,
event2
.
source_nodeid
);
break
;
case
NDB_LE_NodeFailCompleted
:
printf
(
"Node %d: NodeFailCompleted
\n
"
,
event2
.
source_nodeid
);
break
;
case
NDB_LE_ArbitResult
:
printf
(
"Node %d: ArbitResult
\n
"
,
event2
.
source_nodeid
);
printf
(
" code %d, arbit_node %d
\n
"
,
event2
.
ArbitResult
.
code
&
0xffff
,
event2
.
ArbitResult
.
arbit_node
);
break
;
case
NDB_LE_DeadDueToHeartbeat
:
printf
(
"Node %d: DeadDueToHeartbeat
\n
"
,
event2
.
source_nodeid
);
printf
(
" node %d
\n
"
,
event2
.
DeadDueToHeartbeat
.
node
);
break
;
case
NDB_LE_Connected
:
printf
(
"Node %d: Connected
\n
"
,
event2
.
source_nodeid
);
printf
(
" node %d
\n
"
,
event2
.
Connected
.
node
);
break
;
case
NDB_LE_Disconnected
:
printf
(
"Node %d: Disconnected
\n
"
,
event2
.
source_nodeid
);
printf
(
" node %d
\n
"
,
event2
.
Disconnected
.
node
);
break
;
case
NDB_LE_NDBStartCompleted
:
printf
(
"Node %d: StartCompleted
\n
"
,
event2
.
source_nodeid
);
printf
(
" version %d.%d.%d
\n
"
,
event2
.
NDBStartCompleted
.
version
>>
16
&
0xff
,
event2
.
NDBStartCompleted
.
version
>>
8
&
0xff
,
event2
.
NDBStartCompleted
.
version
>>
0
&
0xff
);
break
;
case
NDB_LE_ArbitState
:
printf
(
"Node %d: ArbitState
\n
"
,
event2
.
source_nodeid
);
printf
(
" code %d, arbit_node %d
\n
"
,
event2
.
ArbitState
.
code
&
0xffff
,
event2
.
ArbitResult
.
arbit_node
);
break
;
default:
break
;
}
}
}
ndb_mgm_destroy_logevent_handle
(
&
le1
);
ndb_mgm_destroy_logevent_handle
(
&
le2
);
ndb_mgm_destroy_handle
(
&
h1
);
ndb_mgm_destroy_handle
(
&
h2
);
ndb_end
(
0
);
return
0
;
}
storage/ndb/ndbapi-examples/ndbapi_async/Makefile
View file @
8fdc781d
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
INCLUDE_DIR
=
$(TOP_SRCDIR)
INCLUDE_DIR
=
$(TOP_SRCDIR)
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
SYS_LIB
=
...
...
storage/ndb/ndbapi-examples/ndbapi_async/ndbapi_async.cpp
View file @
8fdc781d
...
@@ -136,7 +136,12 @@ void closeTransaction(Ndb * ndb , async_callback_t * cb);
...
@@ -136,7 +136,12 @@ void closeTransaction(Ndb * ndb , async_callback_t * cb);
/**
/**
* Function to create table
* Function to create table
*/
*/
int
create_table
(
Ndb
*
myNdb
);
void
create_table
(
MYSQL
&
mysql
);
/**
* Function to drop table
*/
void
drop_table
(
MYSQL
&
mysql
);
/**
/**
* stat. variables
* stat. variables
...
@@ -193,7 +198,7 @@ callback(int result, NdbTransaction* trans, void* aObject)
...
@@ -193,7 +198,7 @@ callback(int result, NdbTransaction* trans, void* aObject)
/**
/**
* Create table "GARAGE"
* Create table "GARAGE"
*/
*/
int
create_table
(
MYSQL
&
mysql
)
void
create_table
(
MYSQL
&
mysql
)
{
{
while
(
mysql_query
(
&
mysql
,
while
(
mysql_query
(
&
mysql
,
"CREATE TABLE"
"CREATE TABLE"
...
@@ -208,15 +213,21 @@ int create_table(MYSQL &mysql)
...
@@ -208,15 +213,21 @@ int create_table(MYSQL &mysql)
MYSQLERROR
(
mysql
);
MYSQLERROR
(
mysql
);
std
::
cout
<<
"MySQL Cluster already has example table: GARAGE. "
std
::
cout
<<
"MySQL Cluster already has example table: GARAGE. "
<<
"Dropping it..."
<<
std
::
endl
;
<<
"Dropping it..."
<<
std
::
endl
;
/**************
drop_table
(
mysql
);
* Drop table *
create_table
(
mysql
);
**************/
if
(
mysql_query
(
&
mysql
,
"DROP TABLE GARAGE"
))
MYSQLERROR
(
mysql
);
}
}
return
1
;
}
}
/**
* Drop table GARAGE
*/
void
drop_table
(
MYSQL
&
mysql
)
{
if
(
mysql_query
(
&
mysql
,
"DROP TABLE GARAGE"
))
MYSQLERROR
(
mysql
);
}
void
asynchExitHandler
(
Ndb
*
m_ndb
)
void
asynchExitHandler
(
Ndb
*
m_ndb
)
{
{
if
(
m_ndb
!=
NULL
)
if
(
m_ndb
!=
NULL
)
...
@@ -339,16 +350,12 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
...
@@ -339,16 +350,12 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
{
{
transaction
[
current
].
conn
=
myNdb
->
startTransaction
();
transaction
[
current
].
conn
=
myNdb
->
startTransaction
();
if
(
transaction
[
current
].
conn
==
NULL
)
{
if
(
transaction
[
current
].
conn
==
NULL
)
{
if
(
asynchErrorHandler
(
transaction
[
current
].
conn
,
myNdb
))
/**
{
* no transaction to close since conn == null
/**
*/
* no transaction to close since conn == null
milliSleep
(
10
);
*/
retries
++
;
milliSleep
(
10
);
continue
;
retries
++
;
continue
;
}
asynchExitHandler
(
myNdb
);
}
}
myNdbOperation
=
transaction
[
current
].
conn
->
getNdbOperation
(
myTable
);
myNdbOperation
=
transaction
[
current
].
conn
->
getNdbOperation
(
myTable
);
if
(
myNdbOperation
==
NULL
)
if
(
myNdbOperation
==
NULL
)
...
@@ -406,8 +413,15 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
...
@@ -406,8 +413,15 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
return
-
1
;
return
-
1
;
}
}
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
{
if
(
argc
!=
3
)
{
std
::
cout
<<
"Arguments are <socket mysqld> <connect_string cluster>.
\n
"
;
exit
(
-
1
);
}
char
*
mysqld_sock
=
argv
[
1
];
const
char
*
connectstring
=
argv
[
2
];
ndb_init
();
ndb_init
();
MYSQL
mysql
;
MYSQL
mysql
;
...
@@ -420,7 +434,7 @@ int main()
...
@@ -420,7 +434,7 @@ int main()
exit
(
-
1
);
exit
(
-
1
);
}
}
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
3306
,
"/tmp/mysql.sock"
,
0
)
)
0
,
mysqld_sock
,
0
)
)
MYSQLERROR
(
mysql
);
MYSQLERROR
(
mysql
);
mysql_query
(
&
mysql
,
"CREATE DATABASE TEST_DB"
);
mysql_query
(
&
mysql
,
"CREATE DATABASE TEST_DB"
);
...
@@ -432,7 +446,7 @@ int main()
...
@@ -432,7 +446,7 @@ int main()
/**************************************************************
/**************************************************************
* Connect to ndb cluster *
* Connect to ndb cluster *
**************************************************************/
**************************************************************/
Ndb_cluster_connection
cluster_connection
;
Ndb_cluster_connection
cluster_connection
(
connectstring
)
;
if
(
cluster_connection
.
connect
(
4
,
5
,
1
))
if
(
cluster_connection
.
connect
(
4
,
5
,
1
))
{
{
std
::
cout
<<
"Unable to connect to cluster within 30 secs."
<<
std
::
endl
;
std
::
cout
<<
"Unable to connect to cluster within 30 secs."
<<
std
::
endl
;
...
@@ -447,14 +461,14 @@ int main()
...
@@ -447,14 +461,14 @@ int main()
Ndb
*
myNdb
=
new
Ndb
(
&
cluster_connection
,
Ndb
*
myNdb
=
new
Ndb
(
&
cluster_connection
,
"TEST_DB"
);
// Object representing the database
"TEST_DB"
);
// Object representing the database
if
(
myNdb
->
init
(
1024
)
==
-
1
)
{
// Set max 1024
parallel transactions
if
(
myNdb
->
init
(
1024
)
==
-
1
)
{
// Set max 1024 parallel transactions
APIERROR
(
myNdb
->
getNdbError
());
APIERROR
(
myNdb
->
getNdbError
());
}
}
/**
/**
* Initialise transaction array
* Initialise transaction array
*/
*/
for
(
int
i
=
0
;
i
<
10
24
;
i
++
)
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
{
transaction
[
i
].
used
=
0
;
transaction
[
i
].
used
=
0
;
transaction
[
i
].
conn
=
0
;
transaction
[
i
].
conn
=
0
;
...
@@ -462,9 +476,9 @@ int main()
...
@@ -462,9 +476,9 @@ int main()
}
}
int
i
=
0
;
int
i
=
0
;
/**
/**
* Do
2000
0 insert transactions.
* Do
1
0 insert transactions.
*/
*/
while
(
i
<
2000
0
)
while
(
i
<
1
0
)
{
{
while
(
populate
(
myNdb
,
i
,
0
)
<
0
)
// <0, no space on free list. Sleep and try again.
while
(
populate
(
myNdb
,
i
,
0
)
<
0
)
// <0, no space on free list. Sleep and try again.
milliSleep
(
10
);
milliSleep
(
10
);
...
@@ -473,4 +487,6 @@ int main()
...
@@ -473,4 +487,6 @@ int main()
}
}
std
::
cout
<<
"Number of temporary errors: "
<<
tempErrors
<<
std
::
endl
;
std
::
cout
<<
"Number of temporary errors: "
<<
tempErrors
<<
std
::
endl
;
delete
myNdb
;
delete
myNdb
;
drop_table
(
mysql
);
}
}
storage/ndb/ndbapi-examples/ndbapi_async1/Makefile
View file @
8fdc781d
...
@@ -6,9 +6,10 @@ CFLAGS = -c -Wall -fno-rtti -fno-exceptions
...
@@ -6,9 +6,10 @@ CFLAGS = -c -Wall -fno-rtti -fno-exceptions
DEBUG
=
DEBUG
=
LFLAGS
=
-Wall
LFLAGS
=
-Wall
TOP_SRCDIR
=
../../../..
TOP_SRCDIR
=
../../../..
INCLUDE_DIR
=
$(TOP_SRCDIR)
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb/include
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
SYS_LIB
=
...
@@ -16,7 +17,7 @@ $(TARGET): $(OBJS)
...
@@ -16,7 +17,7 @@ $(TARGET): $(OBJS)
$(CXX)
$(LFLAGS)
$(LIB_DIR)
$(OBJS)
-lndbclient
-lmysqlclient_r
-lmysys
-lmystrings
-lz
$(SYS_LIB)
-o
$(TARGET)
$(CXX)
$(LFLAGS)
$(LIB_DIR)
$(OBJS)
-lndbclient
-lmysqlclient_r
-lmysys
-lmystrings
-lz
$(SYS_LIB)
-o
$(TARGET)
$(TARGET).o
:
$(SRCS)
$(TARGET).o
:
$(SRCS)
$(CXX)
$(CFLAGS)
-I
$(
INCLUDE_DIR)
/storage/ndb/include
-I
$(INCLUDE_DIR)
/storage/ndb/include
/ndbapi
$(SRCS)
$(CXX)
$(CFLAGS)
-I
$(
TOP_SRCDIR)
/include
-I
$(INCLUDE_DIR)
-I
$(INCLUDE_DIR)
/ndbapi
$(SRCS)
clean
:
clean
:
rm
-f
*
.o
$(TARGET)
rm
-f
*
.o
$(TARGET)
storage/ndb/ndbapi-examples/ndbapi_async1/ndbapi_async1.cpp
View file @
8fdc781d
...
@@ -17,38 +17,48 @@
...
@@ -17,38 +17,48 @@
//
//
// ndbapi_async1.cpp: Using asynchronous transactions in NDB API
// ndbapi_async1.cpp: Using asynchronous transactions in NDB API
//
//
// Execute ndbapi_example1 to create the table "MYTABLENAME"
// before executing this program.
//
//
// Correct output from this program is:
// Correct output from this program is:
//
//
// Successful insert.
// Successful insert.
// Successful insert.
// Successful insert.
#include <mysql.h>
#include <NdbApi.hpp>
#include <NdbApi.hpp>
// Used for cout
// Used for cout
#include <iostream>
#include <iostream>
#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) \
#define APIERROR(error) \
{ std::cout << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
{ std::cout << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
<< error.code << ", msg: " << error.message << "." << std::endl; \
<< error.code << ", msg: " << error.message << "." << std::endl; \
exit(-1); }
exit(-1); }
static
void
create_table
(
MYSQL
&
);
static
void
drop_table
(
MYSQL
&
);
static
void
callback
(
int
result
,
NdbTransaction
*
NdbObject
,
void
*
aObject
);
static
void
callback
(
int
result
,
NdbTransaction
*
NdbObject
,
void
*
aObject
);
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
{
ndb_init
();
if
(
argc
!=
3
)
Ndb_cluster_connection
*
cluster_connection
=
new
Ndb_cluster_connection
();
// Object representing the cluster
if
(
cluster_connection
->
wait_until_ready
(
30
,
30
))
{
{
std
::
cout
<<
"
Cluster was not ready within 30 secs."
<<
std
::
endl
;
std
::
cout
<<
"
Arguments are <socket mysqld> <connect_string cluster>.
\n
"
;
exit
(
-
1
);
exit
(
-
1
);
}
}
char
*
mysqld_sock
=
argv
[
1
];
const
char
*
connectstring
=
argv
[
2
];
ndb_init
();
Ndb_cluster_connection
*
cluster_connection
=
new
Ndb_cluster_connection
(
connectstring
);
// Object representing the cluster
int
r
=
cluster_connection
->
connect
(
5
/* retries */
,
int
r
=
cluster_connection
->
connect
(
5
/* retries */
,
3
/* delay between retries */
,
3
/* delay between retries */
,
...
@@ -65,15 +75,32 @@ int main()
...
@@ -65,15 +75,32 @@ int main()
<<
"Cluster connect failed.
\n
"
;
<<
"Cluster connect failed.
\n
"
;
exit
(
-
1
);
exit
(
-
1
);
}
}
if
(
cluster_connection
->
wait_until_ready
(
30
,
3
0
))
if
(
cluster_connection
->
wait_until_ready
(
30
,
0
))
{
{
std
::
cout
<<
"Cluster was not ready within 30 secs."
<<
std
::
endl
;
std
::
cout
<<
"Cluster was not ready within 30 secs."
<<
std
::
endl
;
exit
(
-
1
);
exit
(
-
1
);
}
}
// connect to mysql server
MYSQL
mysql
;
if
(
!
mysql_init
(
&
mysql
)
)
{
std
::
cout
<<
"mysql_init failed
\n
"
;
exit
(
-
1
);
}
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
0
,
mysqld_sock
,
0
)
)
MYSQLERROR
(
mysql
);
/********************************************
* Connect to database via mysql-c *
********************************************/
mysql_query
(
&
mysql
,
"CREATE DATABASE TEST_DB_1"
);
if
(
mysql_query
(
&
mysql
,
"USE TEST_DB_1"
)
!=
0
)
MYSQLERROR
(
mysql
);
create_table
(
mysql
);
Ndb
*
myNdb
=
new
Ndb
(
cluster_connection
,
Ndb
*
myNdb
=
new
Ndb
(
cluster_connection
,
"TEST_DB_
2
"
);
// Object representing the database
"TEST_DB_
1
"
);
// Object representing the database
NdbTransaction
*
myNdbTransaction
[
2
];
// For transactions
NdbTransaction
*
myNdbTransaction
[
2
];
// For transactions
NdbOperation
*
myNdbOperation
;
// For operations
NdbOperation
*
myNdbOperation
;
// For operations
...
@@ -119,10 +146,38 @@ int main()
...
@@ -119,10 +146,38 @@ int main()
delete
myNdb
;
delete
myNdb
;
delete
cluster_connection
;
delete
cluster_connection
;
drop_table
(
mysql
);
ndb_end
(
0
);
ndb_end
(
0
);
return
0
;
return
0
;
}
}
/*********************************************************
* Create a table named MYTABLENAME if it does not exist *
*********************************************************/
static
void
create_table
(
MYSQL
&
mysql
)
{
if
(
mysql_query
(
&
mysql
,
"CREATE TABLE"
" MYTABLENAME"
" (ATTR1 INT UNSIGNED NOT NULL PRIMARY KEY,"
" ATTR2 INT UNSIGNED NOT NULL)"
" ENGINE=NDB"
))
MYSQLERROR
(
mysql
);
}
/***********************************
* Drop a table named MYTABLENAME
***********************************/
static
void
drop_table
(
MYSQL
&
mysql
)
{
if
(
mysql_query
(
&
mysql
,
"DROP TABLE"
" MYTABLENAME"
))
MYSQLERROR
(
mysql
);
}
/*
/*
* callback : This is called when the transaction is polled
* callback : This is called when the transaction is polled
*
*
...
...
storage/ndb/ndbapi-examples/ndbapi_event/Makefile
View file @
8fdc781d
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb/include
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb/include
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
SYS_LIB
=
...
...
storage/ndb/ndbapi-examples/ndbapi_event/ndbapi_event.cpp
View file @
8fdc781d
...
@@ -117,16 +117,23 @@ int myCreateEvent(Ndb* myNdb,
...
@@ -117,16 +117,23 @@ int myCreateEvent(Ndb* myNdb,
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
if
(
argc
<
3
)
{
std
::
cout
<<
"Arguments are <connect_string cluster> <timeout> [m(merge events)|d(debug)].
\n
"
;
exit
(
-
1
);
}
const
char
*
connectstring
=
argv
[
1
];
int
timeout
=
atoi
(
argv
[
2
]);
ndb_init
();
ndb_init
();
bool
merge_events
=
argc
>
1
&&
strchr
(
argv
[
1
],
'm'
)
!=
0
;
bool
merge_events
=
argc
>
3
&&
strchr
(
argv
[
3
],
'm'
)
!=
0
;
#ifdef VM_TRACE
#ifdef VM_TRACE
bool
dbug
=
argc
>
1
&&
strchr
(
argv
[
1
],
'd'
)
!=
0
;
bool
dbug
=
argc
>
3
&&
strchr
(
argv
[
3
],
'd'
)
!=
0
;
if
(
dbug
)
DBUG_PUSH
(
"d:t:"
);
if
(
dbug
)
DBUG_PUSH
(
"d:t:"
);
if
(
dbug
)
putenv
(
"API_SIGNAL_LOG=-"
);
if
(
dbug
)
putenv
(
"API_SIGNAL_LOG=-"
);
#endif
#endif
Ndb_cluster_connection
*
cluster_connection
=
Ndb_cluster_connection
*
cluster_connection
=
new
Ndb_cluster_connection
();
// Object representing the cluster
new
Ndb_cluster_connection
(
connectstring
);
// Object representing the cluster
int
r
=
cluster_connection
->
connect
(
5
/* retries */
,
int
r
=
cluster_connection
->
connect
(
5
/* retries */
,
3
/* delay between retries */
,
3
/* delay between retries */
,
...
@@ -179,7 +186,7 @@ int main(int argc, char** argv)
...
@@ -179,7 +186,7 @@ int main(int argc, char** argv)
int
i
,
j
,
k
,
l
;
int
i
,
j
,
k
,
l
;
j
=
0
;
j
=
0
;
while
(
j
<
99
)
{
while
(
j
<
timeout
)
{
// Start "transaction" for handling events
// Start "transaction" for handling events
NdbEventOperation
*
op
;
NdbEventOperation
*
op
;
...
@@ -211,7 +218,7 @@ int main(int argc, char** argv)
...
@@ -211,7 +218,7 @@ int main(int argc, char** argv)
NdbEventOperation
*
the_op
=
op
;
NdbEventOperation
*
the_op
=
op
;
i
=
0
;
i
=
0
;
while
(
i
<
40
)
{
while
(
i
<
timeout
)
{
// printf("now waiting for event...\n");
// printf("now waiting for event...\n");
int
r
=
myNdb
->
pollEvents
(
1000
);
// wait for event or 1000 ms
int
r
=
myNdb
->
pollEvents
(
1000
);
// wait for event or 1000 ms
if
(
r
>
0
)
{
if
(
r
>
0
)
{
...
@@ -287,7 +294,7 @@ int main(int argc, char** argv)
...
@@ -287,7 +294,7 @@ int main(int argc, char** argv)
}
}
}
}
}
else
}
else
;
//printf("timed out\n"
);
printf
(
"timed out (%i)
\n
"
,
timeout
);
}
}
// don't want to listen to events anymore
// don't want to listen to events anymore
if
(
myNdb
->
dropEventOperation
(
the_op
))
APIERROR
(
myNdb
->
getNdbError
());
if
(
myNdb
->
dropEventOperation
(
the_op
))
APIERROR
(
myNdb
->
getNdbError
());
...
...
storage/ndb/ndbapi-examples/ndbapi_retries/Makefile
View file @
8fdc781d
...
@@ -6,9 +6,10 @@ CFLAGS = -c -Wall -fno-rtti -fno-exceptions
...
@@ -6,9 +6,10 @@ CFLAGS = -c -Wall -fno-rtti -fno-exceptions
DEBUG
=
DEBUG
=
LFLAGS
=
-Wall
LFLAGS
=
-Wall
TOP_SRCDIR
=
../../../..
TOP_SRCDIR
=
../../../..
INCLUDE_DIR
=
../..
/include
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb
/include
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
SYS_LIB
=
...
@@ -16,7 +17,7 @@ $(TARGET): $(OBJS)
...
@@ -16,7 +17,7 @@ $(TARGET): $(OBJS)
$(CXX)
$(LFLAGS)
$(LIB_DIR)
$(OBJS)
-lndbclient
-lmysqlclient_r
-lmysys
-lmystrings
-lz
$(SYS_LIB)
-o
$(TARGET)
$(CXX)
$(LFLAGS)
$(LIB_DIR)
$(OBJS)
-lndbclient
-lmysqlclient_r
-lmysys
-lmystrings
-lz
$(SYS_LIB)
-o
$(TARGET)
$(TARGET).o
:
$(SRCS)
$(TARGET).o
:
$(SRCS)
$(CXX)
$(CFLAGS)
-I
$(INCLUDE_DIR)
-I
$(INCLUDE_DIR)
/ndbapi
$(SRCS)
$(CXX)
$(CFLAGS)
-I
$(TOP_SRCDIR)
/include
-I
$(INCLUDE_DIR)
-I
$(INCLUDE_DIR)
/ndbapi
$(SRCS)
clean
:
clean
:
rm
-f
*
.o
$(TARGET)
rm
-f
*
.o
$(TARGET)
storage/ndb/ndbapi-examples/ndbapi_retries/ndbapi_retries.cpp
View file @
8fdc781d
...
@@ -17,9 +17,6 @@
...
@@ -17,9 +17,6 @@
//
//
// ndbapi_retries.cpp: Error handling and transaction retries
// ndbapi_retries.cpp: Error handling and transaction retries
//
//
// Execute ndbapi_simple to create the table "MYTABLENAME"
// before executing this program.
//
// There are many ways to program using the NDB API. In this example
// There are many ways to program using the NDB API. In this example
// we execute two inserts in the same transaction using
// we execute two inserts in the same transaction using
// NdbConnection::execute(NoCommit).
// NdbConnection::execute(NoCommit).
...
@@ -29,6 +26,7 @@
...
@@ -29,6 +26,7 @@
// Application errors (i.e. errors at points marked with APIERROR)
// Application errors (i.e. errors at points marked with APIERROR)
// should be handled by the application programmer.
// should be handled by the application programmer.
#include <mysql.h>
#include <NdbApi.hpp>
#include <NdbApi.hpp>
// Used for cout
// Used for cout
...
@@ -38,6 +36,14 @@
...
@@ -38,6 +36,14 @@
#include <unistd.h>
#include <unistd.h>
#define TIME_TO_SLEEP_BETWEEN_TRANSACTION_RETRIES 1
#define TIME_TO_SLEEP_BETWEEN_TRANSACTION_RETRIES 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); }
//
//
// APIERROR prints an NdbError object
// APIERROR prints an NdbError object
//
//
...
@@ -176,13 +182,44 @@ int executeInsertTransaction(int transactionId, Ndb* myNdb,
...
@@ -176,13 +182,44 @@ int executeInsertTransaction(int transactionId, Ndb* myNdb,
return
result
;
return
result
;
}
}
/*********************************************************
* Create a table named MYTABLENAME if it does not exist *
*********************************************************/
static
void
create_table
(
MYSQL
&
mysql
)
{
if
(
mysql_query
(
&
mysql
,
"CREATE TABLE"
" MYTABLENAME"
" (ATTR1 INT UNSIGNED NOT NULL PRIMARY KEY,"
" ATTR2 INT UNSIGNED NOT NULL)"
" ENGINE=NDB"
))
MYSQLERROR
(
mysql
);
}
/***********************************
* Drop a table named MYTABLENAME
***********************************/
static
void
drop_table
(
MYSQL
&
mysql
)
{
if
(
mysql_query
(
&
mysql
,
"DROP TABLE"
" MYTABLENAME"
))
MYSQLERROR
(
mysql
);
}
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
{
if
(
argc
!=
3
)
{
std
::
cout
<<
"Arguments are <socket mysqld> <connect_string cluster>.
\n
"
;
exit
(
-
1
);
}
char
*
mysqld_sock
=
argv
[
1
];
const
char
*
connectstring
=
argv
[
2
];
ndb_init
();
ndb_init
();
Ndb_cluster_connection
*
cluster_connection
=
Ndb_cluster_connection
*
cluster_connection
=
new
Ndb_cluster_connection
();
// Object representing the cluster
new
Ndb_cluster_connection
(
connectstring
);
// Object representing the cluster
int
r
=
cluster_connection
->
connect
(
5
/* retries */
,
int
r
=
cluster_connection
->
connect
(
5
/* retries */
,
3
/* delay between retries */
,
3
/* delay between retries */
,
...
@@ -205,6 +242,22 @@ int main()
...
@@ -205,6 +242,22 @@ int main()
std
::
cout
<<
"Cluster was not ready within 30 secs."
<<
std
::
endl
;
std
::
cout
<<
"Cluster was not ready within 30 secs."
<<
std
::
endl
;
exit
(
-
1
);
exit
(
-
1
);
}
}
// connect to mysql server
MYSQL
mysql
;
if
(
!
mysql_init
(
&
mysql
)
)
{
std
::
cout
<<
"mysql_init failed
\n
"
;
exit
(
-
1
);
}
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
0
,
mysqld_sock
,
0
)
)
MYSQLERROR
(
mysql
);
/********************************************
* Connect to database via mysql-c *
********************************************/
mysql_query
(
&
mysql
,
"CREATE DATABASE TEST_DB_1"
);
if
(
mysql_query
(
&
mysql
,
"USE TEST_DB_1"
)
!=
0
)
MYSQLERROR
(
mysql
);
create_table
(
mysql
);
Ndb
*
myNdb
=
new
Ndb
(
cluster_connection
,
Ndb
*
myNdb
=
new
Ndb
(
cluster_connection
,
"TEST_DB_1"
);
// Object representing the database
"TEST_DB_1"
);
// Object representing the database
...
@@ -230,7 +283,9 @@ int main()
...
@@ -230,7 +283,9 @@ int main()
delete
myNdb
;
delete
myNdb
;
delete
cluster_connection
;
delete
cluster_connection
;
drop_table
(
mysql
);
ndb_end
(
0
);
ndb_end
(
0
);
return
0
;
return
0
;
}
}
storage/ndb/ndbapi-examples/ndbapi_scan/Makefile
View file @
8fdc781d
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
INCLUDE_DIR
=
$(TOP_SRCDIR)
INCLUDE_DIR
=
$(TOP_SRCDIR)
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
SYS_LIB
=
...
...
storage/ndb/ndbapi-examples/ndbapi_scan/ndbapi_scan.cpp
View file @
8fdc781d
...
@@ -113,10 +113,20 @@ struct Car
...
@@ -113,10 +113,20 @@ struct Car
char
color
[
20
];
char
color
[
20
];
};
};
/**
* Function to drop table
*/
void
drop_table
(
MYSQL
&
mysql
)
{
if
(
mysql_query
(
&
mysql
,
"DROP TABLE GARAGE"
))
MYSQLERROR
(
mysql
);
}
/**
/**
* Function to create table
* Function to create table
*/
*/
int
create_table
(
MYSQL
&
mysql
)
void
create_table
(
MYSQL
&
mysql
)
{
{
while
(
mysql_query
(
&
mysql
,
while
(
mysql_query
(
&
mysql
,
"CREATE TABLE"
"CREATE TABLE"
...
@@ -131,16 +141,14 @@ int create_table(MYSQL &mysql)
...
@@ -131,16 +141,14 @@ int create_table(MYSQL &mysql)
MYSQLERROR
(
mysql
);
MYSQLERROR
(
mysql
);
std
::
cout
<<
"MySQL Cluster already has example table: GARAGE. "
std
::
cout
<<
"MySQL Cluster already has example table: GARAGE. "
<<
"Dropping it..."
<<
std
::
endl
;
<<
"Dropping it..."
<<
std
::
endl
;
/**************
/**************
****
*
Drop
table *
*
Recreate
table *
**************/
**************
****
/
if
(
mysql_query
(
&
mysql
,
"DROP TABLE GARAGE"
))
drop_table
(
mysql
);
MYSQLERROR
(
mysql
);
create_table
(
mysql
);
}
}
return
1
;
}
}
int
populate
(
Ndb
*
myNdb
)
int
populate
(
Ndb
*
myNdb
)
{
{
int
i
;
int
i
;
...
@@ -721,8 +729,15 @@ int scan_print(Ndb * myNdb)
...
@@ -721,8 +729,15 @@ int scan_print(Ndb * myNdb)
}
}
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
{
if
(
argc
!=
3
)
{
std
::
cout
<<
"Arguments are <socket mysqld> <connect_string cluster>.
\n
"
;
exit
(
-
1
);
}
char
*
mysqld_sock
=
argv
[
1
];
const
char
*
connectstring
=
argv
[
2
];
ndb_init
();
ndb_init
();
MYSQL
mysql
;
MYSQL
mysql
;
...
@@ -735,7 +750,7 @@ int main()
...
@@ -735,7 +750,7 @@ int main()
exit
(
-
1
);
exit
(
-
1
);
}
}
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
3306
,
"/tmp/mysql.sock"
,
0
)
)
0
,
mysqld_sock
,
0
)
)
MYSQLERROR
(
mysql
);
MYSQLERROR
(
mysql
);
mysql_query
(
&
mysql
,
"CREATE DATABASE TEST_DB"
);
mysql_query
(
&
mysql
,
"CREATE DATABASE TEST_DB"
);
...
@@ -748,7 +763,7 @@ int main()
...
@@ -748,7 +763,7 @@ int main()
* Connect to ndb cluster *
* Connect to ndb cluster *
**************************************************************/
**************************************************************/
Ndb_cluster_connection
cluster_connection
;
Ndb_cluster_connection
cluster_connection
(
connectstring
)
;
if
(
cluster_connection
.
connect
(
4
,
5
,
1
))
if
(
cluster_connection
.
connect
(
4
,
5
,
1
))
{
{
std
::
cout
<<
"Unable to connect to cluster within 30 secs."
<<
std
::
endl
;
std
::
cout
<<
"Unable to connect to cluster within 30 secs."
<<
std
::
endl
;
...
@@ -821,5 +836,10 @@ int main()
...
@@ -821,5 +836,10 @@ int main()
if
(
scan_print
(
&
myNdb
)
>
0
)
if
(
scan_print
(
&
myNdb
)
>
0
)
std
::
cout
<<
"scan_print: Success!"
<<
std
::
endl
<<
std
::
endl
;
std
::
cout
<<
"scan_print: Success!"
<<
std
::
endl
<<
std
::
endl
;
/**
* Drop table
*/
drop_table
(
mysql
);
return
0
;
return
0
;
}
}
storage/ndb/ndbapi-examples/ndbapi_simple/Makefile
View file @
8fdc781d
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb/include
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb/include
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
SYS_LIB
=
...
...
storage/ndb/ndbapi-examples/ndbapi_simple/ndbapi_simple.cpp
View file @
8fdc781d
...
@@ -52,15 +52,22 @@ static void run_application(MYSQL &, Ndb_cluster_connection &);
...
@@ -52,15 +52,22 @@ static void run_application(MYSQL &, Ndb_cluster_connection &);
PRINT_ERROR(error.code,error.message); \
PRINT_ERROR(error.code,error.message); \
exit(-1); }
exit(-1); }
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
{
if
(
argc
!=
3
)
{
std
::
cout
<<
"Arguments are <socket mysqld> <connect_string cluster>.
\n
"
;
exit
(
-
1
);
}
// ndb_init must be called first
// ndb_init must be called first
ndb_init
();
ndb_init
();
// connect to mysql server and cluster and run application
// connect to mysql server and cluster and run application
{
{
char
*
mysqld_sock
=
argv
[
1
];
const
char
*
connectstring
=
argv
[
2
];
// Object representing the cluster
// Object representing the cluster
Ndb_cluster_connection
cluster_connection
;
Ndb_cluster_connection
cluster_connection
(
connectstring
)
;
// Connect to cluster management server (ndb_mgmd)
// Connect to cluster management server (ndb_mgmd)
if
(
cluster_connection
.
connect
(
4
/* retries */
,
if
(
cluster_connection
.
connect
(
4
/* retries */
,
...
@@ -85,7 +92,7 @@ int main()
...
@@ -85,7 +92,7 @@ int main()
exit
(
-
1
);
exit
(
-
1
);
}
}
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
3306
,
"/tmp/mysql.sock"
,
0
)
)
0
,
mysqld_sock
,
0
)
)
MYSQLERROR
(
mysql
);
MYSQLERROR
(
mysql
);
// run the application code
// run the application code
...
@@ -94,13 +101,11 @@ int main()
...
@@ -94,13 +101,11 @@ int main()
ndb_end
(
0
);
ndb_end
(
0
);
std
::
cout
<<
"
\n
To drop created table use:
\n
"
<<
"echo
\"
drop table MYTABLENAME
\"
| mysql TEST_DB_1 -u root
\n
"
;
return
0
;
return
0
;
}
}
static
void
create_table
(
MYSQL
&
);
static
void
create_table
(
MYSQL
&
);
static
void
drop_table
(
MYSQL
&
);
static
void
do_insert
(
Ndb
&
);
static
void
do_insert
(
Ndb
&
);
static
void
do_update
(
Ndb
&
);
static
void
do_update
(
Ndb
&
);
static
void
do_delete
(
Ndb
&
);
static
void
do_delete
(
Ndb
&
);
...
@@ -130,6 +135,8 @@ static void run_application(MYSQL &mysql,
...
@@ -130,6 +135,8 @@ static void run_application(MYSQL &mysql,
do_update
(
myNdb
);
do_update
(
myNdb
);
do_delete
(
myNdb
);
do_delete
(
myNdb
);
do_read
(
myNdb
);
do_read
(
myNdb
);
drop_table
(
mysql
);
mysql_query
(
&
mysql
,
"DROP DATABASE TEST_DB_1"
);
}
}
/*********************************************************
/*********************************************************
...
@@ -146,6 +153,17 @@ static void create_table(MYSQL &mysql)
...
@@ -146,6 +153,17 @@ static void create_table(MYSQL &mysql)
MYSQLERROR
(
mysql
);
MYSQLERROR
(
mysql
);
}
}
/***********************************
* Drop a table named MYTABLENAME
***********************************/
static
void
drop_table
(
MYSQL
&
mysql
)
{
if
(
mysql_query
(
&
mysql
,
"DROP TABLE"
" MYTABLENAME"
))
MYSQLERROR
(
mysql
);
}
/**************************************************************************
/**************************************************************************
* Using 5 transactions, insert 10 tuples in table: (0,0),(1,1),...,(9,9) *
* Using 5 transactions, insert 10 tuples in table: (0,0),(1,1),...,(9,9) *
**************************************************************************/
**************************************************************************/
...
...
storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile
0 → 100644
View file @
8fdc781d
TARGET
=
ndbapi_simple_dual
SRCS
=
$(TARGET)
.cpp
OBJS
=
$(TARGET)
.o
CXX
=
g++
CFLAGS
=
-c
-Wall
-fno-rtti
-fno-exceptions
CXXFLAGS
=
DEBUG
=
LFLAGS
=
-Wall
TOP_SRCDIR
=
../../../..
INCLUDE_DIR
=
$(TOP_SRCDIR)
/storage/ndb/include
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
$(TARGET)
:
$(OBJS)
$(CXX)
$(CXXFLAGS)
$(LFLAGS)
$(LIB_DIR)
$(OBJS)
-lndbclient
-lmysqlclient_r
-lmysys
-lmystrings
-lz
$(SYS_LIB)
-o
$(TARGET)
$(TARGET).o
:
$(SRCS)
$(CXX)
$(CFLAGS)
-I
$(TOP_SRCDIR)
/include
-I
$(INCLUDE_DIR)
-I
$(INCLUDE_DIR)
/ndbapi
$(SRCS)
clean
:
rm
-f
*
.o
$(TARGET)
storage/ndb/ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp
0 → 100644
View file @
8fdc781d
/* 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 */
/*
* ndbapi_simple_dual.cpp: Using synchronous transactions in NDB API
*
* Correct output from this program is:
*
* ATTR1 ATTR2
* 0 10
* 1 1
* 2 12
* Detected that deleted tuple doesn't exist!
* 4 14
* 5 5
* 6 16
* 7 7
* 8 18
* 9 9
* ATTR1 ATTR2
* 0 10
* 1 1
* 2 12
* Detected that deleted tuple doesn't exist!
* 4 14
* 5 5
* 6 16
* 7 7
* 8 18
* 9 9
*
*/
#include <mysql.h>
#include <NdbApi.hpp>
// Used for cout
#include <stdio.h>
#include <iostream>
static
void
run_application
(
MYSQL
&
,
Ndb_cluster_connection
&
,
const
char
*
table
,
const
char
*
db
);
#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); }
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
5
)
{
std
::
cout
<<
"Arguments are <socket mysqld1> <connect_string cluster 1> <socket mysqld2> <connect_string cluster 2>.
\n
"
;
exit
(
-
1
);
}
// ndb_init must be called first
ndb_init
();
{
char
*
mysqld1_sock
=
argv
[
1
];
const
char
*
connectstring1
=
argv
[
2
];
char
*
mysqld2_sock
=
argv
[
3
];
const
char
*
connectstring2
=
argv
[
4
];
// Object representing the cluster 1
Ndb_cluster_connection
cluster1_connection
(
connectstring1
);
MYSQL
mysql1
;
// Object representing the cluster 2
Ndb_cluster_connection
cluster2_connection
(
connectstring2
);
MYSQL
mysql2
;
// connect to mysql server and cluster 1 and run application
// Connect to cluster 1 management server (ndb_mgmd)
if
(
cluster1_connection
.
connect
(
4
/* retries */
,
5
/* delay between retries */
,
1
/* verbose */
))
{
std
::
cout
<<
"Cluster 1 management server was not ready within 30 secs.
\n
"
;
exit
(
-
1
);
}
// Optionally connect and wait for the storage nodes (ndbd's)
if
(
cluster1_connection
.
wait_until_ready
(
30
,
0
)
<
0
)
{
std
::
cout
<<
"Cluster 1 was not ready within 30 secs.
\n
"
;
exit
(
-
1
);
}
// connect to mysql server in cluster 1
if
(
!
mysql_init
(
&
mysql1
)
)
{
std
::
cout
<<
"mysql_init failed
\n
"
;
exit
(
-
1
);
}
if
(
!
mysql_real_connect
(
&
mysql1
,
"localhost"
,
"root"
,
""
,
""
,
0
,
mysqld1_sock
,
0
)
)
MYSQLERROR
(
mysql1
);
// connect to mysql server and cluster 2 and run application
// Connect to cluster management server (ndb_mgmd)
if
(
cluster2_connection
.
connect
(
4
/* retries */
,
5
/* delay between retries */
,
1
/* verbose */
))
{
std
::
cout
<<
"Cluster 2 management server was not ready within 30 secs.
\n
"
;
exit
(
-
1
);
}
// Optionally connect and wait for the storage nodes (ndbd's)
if
(
cluster2_connection
.
wait_until_ready
(
30
,
0
)
<
0
)
{
std
::
cout
<<
"Cluster 2 was not ready within 30 secs.
\n
"
;
exit
(
-
1
);
}
// connect to mysql server in cluster 2
if
(
!
mysql_init
(
&
mysql2
)
)
{
std
::
cout
<<
"mysql_init failed
\n
"
;
exit
(
-
1
);
}
if
(
!
mysql_real_connect
(
&
mysql2
,
"localhost"
,
"root"
,
""
,
""
,
0
,
mysqld2_sock
,
0
)
)
MYSQLERROR
(
mysql2
);
// run the application code
run_application
(
mysql1
,
cluster1_connection
,
"MYTABLENAME1"
,
"TEST_DB_1"
);
run_application
(
mysql2
,
cluster2_connection
,
"MYTABLENAME2"
,
"TEST_DB_2"
);
}
// Note: all connections must have been destroyed before calling ndb_end()
ndb_end
(
0
);
return
0
;
}
static
void
create_table
(
MYSQL
&
,
const
char
*
table
);
static
void
drop_table
(
MYSQL
&
,
const
char
*
table
);
static
void
do_insert
(
Ndb
&
,
const
char
*
table
);
static
void
do_update
(
Ndb
&
,
const
char
*
table
);
static
void
do_delete
(
Ndb
&
,
const
char
*
table
);
static
void
do_read
(
Ndb
&
,
const
char
*
table
);
static
void
run_application
(
MYSQL
&
mysql
,
Ndb_cluster_connection
&
cluster_connection
,
const
char
*
table
,
const
char
*
db
)
{
/********************************************
* Connect to database via mysql-c *
********************************************/
char
db_stmt
[
256
];
sprintf
(
db_stmt
,
"CREATE DATABASE %s
\n
"
,
db
);
mysql_query
(
&
mysql
,
db_stmt
);
sprintf
(
db_stmt
,
"USE %s"
,
db
);
if
(
mysql_query
(
&
mysql
,
db_stmt
)
!=
0
)
MYSQLERROR
(
mysql
);
create_table
(
mysql
,
table
);
/********************************************
* Connect to database via NdbApi *
********************************************/
// Object representing the database
Ndb
myNdb
(
&
cluster_connection
,
db
);
if
(
myNdb
.
init
())
APIERROR
(
myNdb
.
getNdbError
());
/*
* Do different operations on database
*/
do_insert
(
myNdb
,
table
);
do_update
(
myNdb
,
table
);
do_delete
(
myNdb
,
table
);
do_read
(
myNdb
,
table
);
/*
* Drop the table
*/
drop_table
(
mysql
,
table
);
sprintf
(
db_stmt
,
"DROP DATABASE %s
\n
"
,
db
);
mysql_query
(
&
mysql
,
db_stmt
);
}
/*********************************************************
* Create a table named by table if it does not exist *
*********************************************************/
static
void
create_table
(
MYSQL
&
mysql
,
const
char
*
table
)
{
char
create_stmt
[
256
];
sprintf
(
create_stmt
,
"CREATE TABLE %s \
(ATTR1 INT UNSIGNED NOT NULL PRIMARY KEY,\
ATTR2 INT UNSIGNED NOT NULL)\
ENGINE=NDB"
,
table
);
if
(
mysql_query
(
&
mysql
,
create_stmt
))
MYSQLERROR
(
mysql
);
}
/*******************************
* Drop a table named by table
*******************************/
static
void
drop_table
(
MYSQL
&
mysql
,
const
char
*
table
)
{
char
drop_stmt
[
256
];
sprintf
(
drop_stmt
,
"DROP TABLE IF EXISTS %s"
,
table
);
if
(
mysql_query
(
&
mysql
,
drop_stmt
))
MYSQLERROR
(
mysql
);
}
/**************************************************************************
* Using 5 transactions, insert 10 tuples in table: (0,0),(1,1),...,(9,9) *
**************************************************************************/
static
void
do_insert
(
Ndb
&
myNdb
,
const
char
*
table
)
{
const
NdbDictionary
::
Dictionary
*
myDict
=
myNdb
.
getDictionary
();
const
NdbDictionary
::
Table
*
myTable
=
myDict
->
getTable
(
table
);
if
(
myTable
==
NULL
)
APIERROR
(
myDict
->
getNdbError
());
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
NdbTransaction
*
myTransaction
=
myNdb
.
startTransaction
();
if
(
myTransaction
==
NULL
)
APIERROR
(
myNdb
.
getNdbError
());
NdbOperation
*
myOperation
=
myTransaction
->
getNdbOperation
(
myTable
);
if
(
myOperation
==
NULL
)
APIERROR
(
myTransaction
->
getNdbError
());
myOperation
->
insertTuple
();
myOperation
->
equal
(
"ATTR1"
,
i
);
myOperation
->
setValue
(
"ATTR2"
,
i
);
myOperation
=
myTransaction
->
getNdbOperation
(
myTable
);
if
(
myOperation
==
NULL
)
APIERROR
(
myTransaction
->
getNdbError
());
myOperation
->
insertTuple
();
myOperation
->
equal
(
"ATTR1"
,
i
+
5
);
myOperation
->
setValue
(
"ATTR2"
,
i
+
5
);
if
(
myTransaction
->
execute
(
NdbTransaction
::
Commit
)
==
-
1
)
APIERROR
(
myTransaction
->
getNdbError
());
myNdb
.
closeTransaction
(
myTransaction
);
}
}
/*****************************************************************
* Update the second attribute in half of the tuples (adding 10) *
*****************************************************************/
static
void
do_update
(
Ndb
&
myNdb
,
const
char
*
table
)
{
const
NdbDictionary
::
Dictionary
*
myDict
=
myNdb
.
getDictionary
();
const
NdbDictionary
::
Table
*
myTable
=
myDict
->
getTable
(
table
);
if
(
myTable
==
NULL
)
APIERROR
(
myDict
->
getNdbError
());
for
(
int
i
=
0
;
i
<
10
;
i
+=
2
)
{
NdbTransaction
*
myTransaction
=
myNdb
.
startTransaction
();
if
(
myTransaction
==
NULL
)
APIERROR
(
myNdb
.
getNdbError
());
NdbOperation
*
myOperation
=
myTransaction
->
getNdbOperation
(
myTable
);
if
(
myOperation
==
NULL
)
APIERROR
(
myTransaction
->
getNdbError
());
myOperation
->
updateTuple
();
myOperation
->
equal
(
"ATTR1"
,
i
);
myOperation
->
setValue
(
"ATTR2"
,
i
+
10
);
if
(
myTransaction
->
execute
(
NdbTransaction
::
Commit
)
==
-
1
)
APIERROR
(
myTransaction
->
getNdbError
());
myNdb
.
closeTransaction
(
myTransaction
);
}
}
/*************************************************
* Delete one tuple (the one with primary key 3) *
*************************************************/
static
void
do_delete
(
Ndb
&
myNdb
,
const
char
*
table
)
{
const
NdbDictionary
::
Dictionary
*
myDict
=
myNdb
.
getDictionary
();
const
NdbDictionary
::
Table
*
myTable
=
myDict
->
getTable
(
table
);
if
(
myTable
==
NULL
)
APIERROR
(
myDict
->
getNdbError
());
NdbTransaction
*
myTransaction
=
myNdb
.
startTransaction
();
if
(
myTransaction
==
NULL
)
APIERROR
(
myNdb
.
getNdbError
());
NdbOperation
*
myOperation
=
myTransaction
->
getNdbOperation
(
myTable
);
if
(
myOperation
==
NULL
)
APIERROR
(
myTransaction
->
getNdbError
());
myOperation
->
deleteTuple
();
myOperation
->
equal
(
"ATTR1"
,
3
);
if
(
myTransaction
->
execute
(
NdbTransaction
::
Commit
)
==
-
1
)
APIERROR
(
myTransaction
->
getNdbError
());
myNdb
.
closeTransaction
(
myTransaction
);
}
/*****************************
* Read and print all tuples *
*****************************/
static
void
do_read
(
Ndb
&
myNdb
,
const
char
*
table
)
{
const
NdbDictionary
::
Dictionary
*
myDict
=
myNdb
.
getDictionary
();
const
NdbDictionary
::
Table
*
myTable
=
myDict
->
getTable
(
table
);
if
(
myTable
==
NULL
)
APIERROR
(
myDict
->
getNdbError
());
std
::
cout
<<
"ATTR1 ATTR2"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
NdbTransaction
*
myTransaction
=
myNdb
.
startTransaction
();
if
(
myTransaction
==
NULL
)
APIERROR
(
myNdb
.
getNdbError
());
NdbOperation
*
myOperation
=
myTransaction
->
getNdbOperation
(
myTable
);
if
(
myOperation
==
NULL
)
APIERROR
(
myTransaction
->
getNdbError
());
myOperation
->
readTuple
(
NdbOperation
::
LM_Read
);
myOperation
->
equal
(
"ATTR1"
,
i
);
NdbRecAttr
*
myRecAttr
=
myOperation
->
getValue
(
"ATTR2"
,
NULL
);
if
(
myRecAttr
==
NULL
)
APIERROR
(
myTransaction
->
getNdbError
());
if
(
myTransaction
->
execute
(
NdbTransaction
::
Commit
)
==
-
1
)
if
(
i
==
3
)
{
std
::
cout
<<
"Detected that deleted tuple doesn't exist!"
<<
std
::
endl
;
}
else
{
APIERROR
(
myTransaction
->
getNdbError
());
}
if
(
i
!=
3
)
{
printf
(
" %2d %2d
\n
"
,
i
,
myRecAttr
->
u_32_value
());
}
myNdb
.
closeTransaction
(
myTransaction
);
}
}
storage/ndb/ndbapi-examples/ndbapi_simple_index/Makefile
View file @
8fdc781d
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
...
@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
INCLUDE_DIR
=
$(TOP_SRCDIR)
INCLUDE_DIR
=
$(TOP_SRCDIR)
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
LIB_DIR
=
-L
$(TOP_SRCDIR)
/storage/ndb/src/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/libmysql_r/.libs
\
-L
$(TOP_SRCDIR)
/zlib/.libs
\
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
-L
$(TOP_SRCDIR)
/mysys
-L
$(TOP_SRCDIR)
/strings
SYS_LIB
=
SYS_LIB
=
...
...
storage/ndb/ndbapi-examples/ndbapi_simple_index/ndbapi_simple_index.cpp
View file @
8fdc781d
...
@@ -49,8 +49,15 @@
...
@@ -49,8 +49,15 @@
PRINT_ERROR(error.code,error.message); \
PRINT_ERROR(error.code,error.message); \
exit(-1); }
exit(-1); }
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
{
if
(
argc
!=
3
)
{
std
::
cout
<<
"Arguments are <socket mysqld> <connect_string cluster>.
\n
"
;
exit
(
-
1
);
}
char
*
mysqld_sock
=
argv
[
1
];
const
char
*
connectstring
=
argv
[
2
];
ndb_init
();
ndb_init
();
MYSQL
mysql
;
MYSQL
mysql
;
...
@@ -63,7 +70,7 @@ int main()
...
@@ -63,7 +70,7 @@ int main()
exit
(
-
1
);
exit
(
-
1
);
}
}
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
if
(
!
mysql_real_connect
(
&
mysql
,
"localhost"
,
"root"
,
""
,
""
,
3306
,
"/tmp/mysql.sock"
,
0
)
)
0
,
mysqld_sock
,
0
)
)
MYSQLERROR
(
mysql
);
MYSQLERROR
(
mysql
);
mysql_query
(
&
mysql
,
"CREATE DATABASE TEST_DB_1"
);
mysql_query
(
&
mysql
,
"CREATE DATABASE TEST_DB_1"
);
...
@@ -85,7 +92,7 @@ int main()
...
@@ -85,7 +92,7 @@ int main()
**************************************************************/
**************************************************************/
Ndb_cluster_connection
*
cluster_connection
=
Ndb_cluster_connection
*
cluster_connection
=
new
Ndb_cluster_connection
();
// Object representing the cluster
new
Ndb_cluster_connection
(
connectstring
);
// Object representing the cluster
if
(
cluster_connection
->
connect
(
5
,
3
,
1
))
if
(
cluster_connection
->
connect
(
5
,
3
,
1
))
{
{
...
@@ -110,7 +117,7 @@ int main()
...
@@ -110,7 +117,7 @@ int main()
const
NdbDictionary
::
Table
*
myTable
=
myDict
->
getTable
(
"MYTABLENAME"
);
const
NdbDictionary
::
Table
*
myTable
=
myDict
->
getTable
(
"MYTABLENAME"
);
if
(
myTable
==
NULL
)
if
(
myTable
==
NULL
)
APIERROR
(
myDict
->
getNdbError
());
APIERROR
(
myDict
->
getNdbError
());
const
NdbDictionary
::
Index
*
myIndex
=
myDict
->
getIndex
(
"MYINDEXNAME"
,
"MYTABLENAME"
);
const
NdbDictionary
::
Index
*
myIndex
=
myDict
->
getIndex
(
"MYINDEXNAME
$unique
"
,
"MYTABLENAME"
);
if
(
myIndex
==
NULL
)
if
(
myIndex
==
NULL
)
APIERROR
(
myDict
->
getNdbError
());
APIERROR
(
myDict
->
getNdbError
());
...
...
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