Commit 6138410c authored by unknown's avatar unknown

Fixed ndbapi-examples, and added tests for mysql-test-run.pl


storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/storage/ndb/ndbapi-examples/ndbapi_simple_dual/Makefile
storage/ndb/ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/storage/ndb/ndbapi-examples/ndbapi_simple_dual/ndbapi_simple_dual.cpp
storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/storage/ndb/ndbapi-examples/mgmapi_logevent_dual/Makefile
storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/storage/ndb/ndbapi-examples/mgmapi_logevent_dual/mgmapi_logevent_dual.cpp
mysql-test/include/have_ndbapi_examples.inc:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/mysql-test/include/have_ndbapi_examples.inc
mysql-test/t/ndbapi.test:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/mysql-test/t/ndbapi.test
mysql-test/t/rpl_ndbapi_multi.test:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/mysql-test/t/rpl_ndbapi_multi.test
mysql-test/r/have_ndbapi_examples.require:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/mysql-test/r/have_ndbapi_examples.require
mysql-test/r/ndbapi.result:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/mysql-test/r/ndbapi.result
mysql-test/r/rpl_ndbapi_multi.result:
  BitKeeper file /windows/Linux_space/MySQL/mysql-5.1/mysql-test/r/rpl_ndbapi_multi.result
parent 3dcf8673
--require r/have_ndbapi_examples.require
disable_query_log;
eval select LENGTH("$MY_NDB_EXAMPLES_BINARY") > 0 as "have_ndb_example";
enable_query_log;
......@@ -323,6 +323,8 @@ our $opt_skip_slave_binlog= 0;
our $exe_ndb_mgm;
our $exe_ndb_waiter;
our $path_ndb_tools_dir;
our $path_ndb_examples_dir;
our $exe_ndb_example;
our $file_ndb_testrun_log;
our @data_dir_lst;
......@@ -1233,6 +1235,9 @@ sub executable_setup () {
mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables",
"/usr/bin/false");
$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_waiter= "$glob_basedir/storage/ndb/tools/ndb_waiter";
$exe_ndbd= "$glob_basedir/storage/ndb/src/kernel/ndbd";
......@@ -1297,6 +1302,7 @@ sub executable_setup () {
}
$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_waiter= "$glob_basedir/bin/ndb_waiter";
$exe_ndbd= "$glob_basedir/bin/ndbd";
......@@ -1344,6 +1350,20 @@ sub environment_setup () {
($lib_udf_example ? dirname($lib_udf_example) : "") .
($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
......@@ -1360,6 +1380,7 @@ sub environment_setup () {
$ENV{'MASTER_MYSOCK1'}= $master->[1]->{'path_sock'};
$ENV{'MASTER_MYPORT'}= $master->[0]->{'port'};
$ENV{'MASTER_MYPORT1'}= $master->[1]->{'port'};
$ENV{'SLAVE_MYSOCK'}= $slave->[0]->{'path_sock'};
$ENV{'SLAVE_MYPORT'}= $slave->[0]->{'port'};
$ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'};
$ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'};
......@@ -3802,7 +3823,10 @@ sub run_mysqltest ($) {
$ENV{'NDB_BACKUP_DIR'}= $clusters->[0]->{'data_dir'};
$ENV{'NDB_DATA_DIR'}= $clusters->[0]->{'data_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_EXAMPLES_OUTPUT'}= $file_ndb_testrun_log;
$ENV{'NDB_CONNECTSTRING'}= $opt_ndbconnectstring;
my $exe= $exe_mysqltest;
......
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
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
-- 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
-- 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
......@@ -5,7 +5,9 @@ BIN_DIRS := ndbapi_simple \
ndbapi_simple_index \
ndbapi_event \
ndbapi_scan \
mgmapi_logevent
mgmapi_logevent \
ndbapi_simple_dual \
mgmapi_logevent_dual
bins: $(patsubst %, _bins_%, $(BIN_DIRS))
......
......@@ -10,6 +10,7 @@ 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 =
......
......@@ -39,7 +39,7 @@
exit(-1); \
}
int main()
int main(int argc, char** argv)
{
NdbMgmHandle h;
NdbLogEventHandle le;
......@@ -51,22 +51,36 @@ int main()
0 };
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();
h= ndb_mgm_create_handle();
if ( h == 0)
{
printf("Unable to create handle\n");
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);
le= ndb_mgm_create_logevent_handle(h, filter);
if ( le == 0 ) MGMERROR(h);
while (1)
while (iterations-- != 0)
{
int timeout= 5000;
int timeout= 1000;
int r= ndb_logevent_get_next(le,&event,timeout);
if (r == 0)
printf("No event within %d milliseconds\n", timeout);
......
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)
/* 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;
}
......@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
INCLUDE_DIR = $(TOP_SRCDIR)
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 =
......
......@@ -136,7 +136,12 @@ void closeTransaction(Ndb * ndb , async_callback_t * cb);
/**
* 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
......@@ -193,7 +198,7 @@ callback(int result, NdbTransaction* trans, void* aObject)
/**
* Create table "GARAGE"
*/
int create_table(MYSQL &mysql)
void create_table(MYSQL &mysql)
{
while (mysql_query(&mysql,
"CREATE TABLE"
......@@ -208,15 +213,21 @@ int create_table(MYSQL &mysql)
MYSQLERROR(mysql);
std::cout << "MySQL Cluster already has example table: GARAGE. "
<< "Dropping it..." << std::endl;
/**************
* Drop table *
**************/
if (mysql_query(&mysql, "DROP TABLE GARAGE"))
MYSQLERROR(mysql);
drop_table(mysql);
create_table(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)
{
if (m_ndb != NULL)
......@@ -339,16 +350,12 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
{
transaction[current].conn = myNdb->startTransaction();
if (transaction[current].conn == NULL) {
if (asynchErrorHandler(transaction[current].conn, myNdb))
{
/**
* no transaction to close since conn == null
*/
milliSleep(10);
retries++;
continue;
}
asynchExitHandler(myNdb);
/**
* no transaction to close since conn == null
*/
milliSleep(10);
retries++;
continue;
}
myNdbOperation = transaction[current].conn->getNdbOperation(myTable);
if (myNdbOperation == NULL)
......@@ -406,8 +413,15 @@ int populate(Ndb * myNdb, int data, async_callback_t * cbData)
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();
MYSQL mysql;
......@@ -420,7 +434,7 @@ int main()
exit(-1);
}
if ( !mysql_real_connect(&mysql, "localhost", "root", "", "",
3306, "/tmp/mysql.sock", 0) )
0, mysqld_sock, 0) )
MYSQLERROR(mysql);
mysql_query(&mysql, "CREATE DATABASE TEST_DB");
......@@ -432,7 +446,7 @@ int main()
/**************************************************************
* Connect to ndb cluster *
**************************************************************/
Ndb_cluster_connection cluster_connection;
Ndb_cluster_connection cluster_connection(connectstring);
if (cluster_connection.connect(4, 5, 1))
{
std::cout << "Unable to connect to cluster within 30 secs." << std::endl;
......@@ -447,14 +461,14 @@ int main()
Ndb* myNdb = new Ndb( &cluster_connection,
"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());
}
/**
* Initialise transaction array
*/
for(int i = 0 ; i < 1024 ; i++)
for(int i = 0 ; i < 10 ; i++)
{
transaction[i].used = 0;
transaction[i].conn = 0;
......@@ -462,9 +476,9 @@ int main()
}
int i=0;
/**
* Do 20000 insert transactions.
* Do 10 insert transactions.
*/
while(i < 20000)
while(i < 10)
{
while(populate(myNdb,i,0)<0) // <0, no space on free list. Sleep and try again.
milliSleep(10);
......@@ -473,4 +487,6 @@ int main()
}
std::cout << "Number of temporary errors: " << tempErrors << std::endl;
delete myNdb;
drop_table(mysql);
}
......@@ -6,9 +6,10 @@ CFLAGS = -c -Wall -fno-rtti -fno-exceptions
DEBUG =
LFLAGS = -Wall
TOP_SRCDIR = ../../../..
INCLUDE_DIR = $(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 =
......@@ -16,7 +17,7 @@ $(TARGET): $(OBJS)
$(CXX) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lmystrings -lz $(SYS_LIB) -o $(TARGET)
$(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:
rm -f *.o $(TARGET)
......@@ -17,38 +17,48 @@
//
// 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:
//
// Successful insert.
// Successful insert.
#include <mysql.h>
#include <NdbApi.hpp>
// Used for cout
#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) \
{ std::cout << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
<< error.code << ", msg: " << error.message << "." << std::endl; \
exit(-1); }
static void create_table(MYSQL &);
static void drop_table(MYSQL &);
static void callback(int result, NdbTransaction* NdbObject, void* aObject);
int main()
int main(int argc, char** argv)
{
ndb_init();
Ndb_cluster_connection *cluster_connection=
new Ndb_cluster_connection(); // Object representing the cluster
if (cluster_connection->wait_until_ready(30,30))
if (argc != 3)
{
std::cout << "Cluster was not ready within 30 secs." << std::endl;
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_cluster_connection *cluster_connection=
new Ndb_cluster_connection(connectstring); // Object representing the cluster
int r= cluster_connection->connect(5 /* retries */,
3 /* delay between retries */,
......@@ -65,15 +75,32 @@ int main()
<< "Cluster connect failed.\n";
exit(-1);
}
if (cluster_connection->wait_until_ready(30,30))
if (cluster_connection->wait_until_ready(30,0))
{
std::cout << "Cluster was not ready within 30 secs." << std::endl;
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,
"TEST_DB_2" ); // Object representing the database
"TEST_DB_1" ); // Object representing the database
NdbTransaction* myNdbTransaction[2]; // For transactions
NdbOperation* myNdbOperation; // For operations
......@@ -119,10 +146,38 @@ int main()
delete myNdb;
delete cluster_connection;
drop_table(mysql);
ndb_end(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
*
......
......@@ -10,6 +10,7 @@ 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 =
......
......@@ -117,16 +117,23 @@ int myCreateEvent(Ndb* myNdb,
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();
bool merge_events = argc > 1 && strchr(argv[1], 'm') != 0;
bool merge_events = argc > 3 && strchr(argv[3], 'm') != 0;
#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) putenv("API_SIGNAL_LOG=-");
#endif
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 */,
3 /* delay between retries */,
......@@ -179,7 +186,7 @@ int main(int argc, char** argv)
int i, j, k, l;
j = 0;
while (j < 99) {
while (j < timeout) {
// Start "transaction" for handling events
NdbEventOperation* op;
......@@ -211,7 +218,7 @@ int main(int argc, char** argv)
NdbEventOperation* the_op = op;
i= 0;
while (i < 40) {
while (i < timeout) {
// printf("now waiting for event...\n");
int r = myNdb->pollEvents(1000); // wait for event or 1000 ms
if (r > 0) {
......@@ -287,7 +294,7 @@ int main(int argc, char** argv)
}
}
} else
;//printf("timed out\n");
printf("timed out (%i)\n", timeout);
}
// don't want to listen to events anymore
if (myNdb->dropEventOperation(the_op)) APIERROR(myNdb->getNdbError());
......
......@@ -6,9 +6,10 @@ CFLAGS = -c -Wall -fno-rtti -fno-exceptions
DEBUG =
LFLAGS = -Wall
TOP_SRCDIR = ../../../..
INCLUDE_DIR = ../../include
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 =
......@@ -16,7 +17,7 @@ $(TARGET): $(OBJS)
$(CXX) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient_r -lmysys -lmystrings -lz $(SYS_LIB) -o $(TARGET)
$(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:
rm -f *.o $(TARGET)
......@@ -17,9 +17,6 @@
//
// 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
// we execute two inserts in the same transaction using
// NdbConnection::execute(NoCommit).
......@@ -29,6 +26,7 @@
// Application errors (i.e. errors at points marked with APIERROR)
// should be handled by the application programmer.
#include <mysql.h>
#include <NdbApi.hpp>
// Used for cout
......@@ -38,6 +36,14 @@
#include <unistd.h>
#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
//
......@@ -176,13 +182,44 @@ int executeInsertTransaction(int transactionId, Ndb* myNdb,
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_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 */,
3 /* delay between retries */,
......@@ -205,6 +242,22 @@ int main()
std::cout << "Cluster was not ready within 30 secs." << std::endl;
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,
"TEST_DB_1" ); // Object representing the database
......@@ -230,7 +283,9 @@ int main()
delete myNdb;
delete cluster_connection;
drop_table(mysql);
ndb_end(0);
return 0;
}
......@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
INCLUDE_DIR = $(TOP_SRCDIR)
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 =
......
......@@ -113,10 +113,20 @@ struct Car
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
*/
int create_table(MYSQL &mysql)
void create_table(MYSQL &mysql)
{
while (mysql_query(&mysql,
"CREATE TABLE"
......@@ -131,16 +141,14 @@ int create_table(MYSQL &mysql)
MYSQLERROR(mysql);
std::cout << "MySQL Cluster already has example table: GARAGE. "
<< "Dropping it..." << std::endl;
/**************
* Drop table *
**************/
if (mysql_query(&mysql, "DROP TABLE GARAGE"))
MYSQLERROR(mysql);
/******************
* Recreate table *
******************/
drop_table(mysql);
create_table(mysql);
}
return 1;
}
int populate(Ndb * myNdb)
{
int i;
......@@ -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();
MYSQL mysql;
......@@ -735,7 +750,7 @@ int main()
exit(-1);
}
if ( !mysql_real_connect(&mysql, "localhost", "root", "", "",
3306, "/tmp/mysql.sock", 0) )
0, mysqld_sock, 0) )
MYSQLERROR(mysql);
mysql_query(&mysql, "CREATE DATABASE TEST_DB");
......@@ -748,7 +763,7 @@ int main()
* Connect to ndb cluster *
**************************************************************/
Ndb_cluster_connection cluster_connection;
Ndb_cluster_connection cluster_connection(connectstring);
if (cluster_connection.connect(4, 5, 1))
{
std::cout << "Unable to connect to cluster within 30 secs." << std::endl;
......@@ -821,5 +836,10 @@ int main()
if(scan_print(&myNdb) > 0)
std::cout << "scan_print: Success!" << std::endl << std::endl;
/**
* Drop table
*/
drop_table(mysql);
return 0;
}
......@@ -10,6 +10,7 @@ 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 =
......
......@@ -52,15 +52,22 @@ static void run_application(MYSQL &, Ndb_cluster_connection &);
PRINT_ERROR(error.code,error.message); \
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();
// connect to mysql server and cluster and run application
{
char * mysqld_sock = argv[1];
const char *connectstring = argv[2];
// Object representing the cluster
Ndb_cluster_connection cluster_connection;
Ndb_cluster_connection cluster_connection(connectstring);
// Connect to cluster management server (ndb_mgmd)
if (cluster_connection.connect(4 /* retries */,
......@@ -85,7 +92,7 @@ int main()
exit(-1);
}
if ( !mysql_real_connect(&mysql, "localhost", "root", "", "",
3306, "/tmp/mysql.sock", 0) )
0, mysqld_sock, 0) )
MYSQLERROR(mysql);
// run the application code
......@@ -94,13 +101,11 @@ int main()
ndb_end(0);
std::cout << "\nTo drop created table use:\n"
<< "echo \"drop table MYTABLENAME\" | mysql TEST_DB_1 -u root\n";
return 0;
}
static void create_table(MYSQL &);
static void drop_table(MYSQL &);
static void do_insert(Ndb &);
static void do_update(Ndb &);
static void do_delete(Ndb &);
......@@ -130,6 +135,8 @@ static void run_application(MYSQL &mysql,
do_update(myNdb);
do_delete(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)
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) *
**************************************************************************/
......
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)
......@@ -10,6 +10,7 @@ TOP_SRCDIR = ../../../..
INCLUDE_DIR = $(TOP_SRCDIR)
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 =
......
......@@ -49,8 +49,15 @@
PRINT_ERROR(error.code,error.message); \
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();
MYSQL mysql;
......@@ -63,7 +70,7 @@ int main()
exit(-1);
}
if ( !mysql_real_connect(&mysql, "localhost", "root", "", "",
3306, "/tmp/mysql.sock", 0) )
0, mysqld_sock, 0) )
MYSQLERROR(mysql);
mysql_query(&mysql, "CREATE DATABASE TEST_DB_1");
......@@ -85,7 +92,7 @@ int main()
**************************************************************/
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))
{
......@@ -110,7 +117,7 @@ int main()
const NdbDictionary::Table *myTable= myDict->getTable("MYTABLENAME");
if (myTable == NULL)
APIERROR(myDict->getNdbError());
const NdbDictionary::Index *myIndex= myDict->getIndex("MYINDEXNAME","MYTABLENAME");
const NdbDictionary::Index *myIndex= myDict->getIndex("MYINDEXNAME$unique","MYTABLENAME");
if (myIndex == NULL)
APIERROR(myDict->getNdbError());
......
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