summaryrefslogtreecommitdiff
path: root/ndb/test/ndbapi/old_dirs/lmc-bench/src
diff options
context:
space:
mode:
Diffstat (limited to 'ndb/test/ndbapi/old_dirs/lmc-bench/src')
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/Makefile8
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/README8
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/Makefile17
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.c542
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.h60
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/mainGenerator.c322
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/include/testData.h102
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/include/userInterface.h127
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.linux6
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.sparc15
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/Makefile15
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.c243
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.h58
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/mainPopulate.c75
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/Makefile11
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/localDbPrepare.c647
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/macros.h50
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/ndb_error.hpp30
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/Makefile10
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userHandle.h189
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userInterface.c452
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userTransaction.c472
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userHandle.h50
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userInterface.cpp738
-rw-r--r--ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userTransaction.c472
25 files changed, 0 insertions, 4719 deletions
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/Makefile b/ndb/test/ndbapi/old_dirs/lmc-bench/src/Makefile
deleted file mode 100644
index ae7fac9c49b..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-include .defs.mk
-
-DIRS = \
- user \
- populator \
-
-include $(NDB_TOP)/Epilogue.mk
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/README b/ndb/test/ndbapi/old_dirs/lmc-bench/src/README
deleted file mode 100644
index e81c8ba0051..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/README
+++ /dev/null
@@ -1,8 +0,0 @@
-
-Note that you have to use gnumake to build
-
-On ndbs05:
-use 'gmake' instead of 'make'
-
-On hfXXX:
-do 'module add make'
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/Makefile b/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/Makefile
deleted file mode 100644
index 143d9ba655e..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-include .defs.mk
-
-TYPE := ndbapitest
-
-SOURCES = mainGenerator.c dbGenerator.c
-
-CCFLAGS_LOC := -I../include -I../../include
-
-OBJECTS = \
- mainGenerator.o\
- dbGenerator.o
-
-BIN_TARGET := DbGenerator
-BIN_TARGET_ARCHIVES := lmc_User
-
-include $(NDB_TOP)/Epilogue.mk
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.c b/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.c
deleted file mode 100644
index a0df1e7c1d2..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.c
+++ /dev/null
@@ -1,542 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include <ndb_global.h>
-#include "dbGenerator.h"
-
-/***************************************************************
-* L O C A L C O N S T A N T S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L D A T A S T R U C T U R E S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L F U N C T I O N S *
-***************************************************************/
-
-static void getRandomSubscriberNumber(SubscriberNumber number);
-static void getRandomServerId(ServerId *serverId);
-static void getRandomChangedBy(ChangedBy changedBy);
-static void getRandomChangedTime(ChangedTime changedTime);
-
-static void clearTransaction(TransactionDefinition *trans);
-static void initGeneratorStatistics(GeneratorStatistics *gen);
-
-static void doOneTransaction(UserHandle *uh, GeneratorStatistics *gen);
-static void doTransaction_T1(UserHandle *uh, GeneratorStatistics *gen);
-static void doTransaction_T2(UserHandle *uh, GeneratorStatistics *gen);
-static void doTransaction_T3(UserHandle *uh, GeneratorStatistics *gen);
-static void doTransaction_T4(UserHandle *uh, GeneratorStatistics *gen);
-static void doTransaction_T5(UserHandle *uh, GeneratorStatistics *gen);
-
-/***************************************************************
-* L O C A L D A T A *
-***************************************************************/
-
-static SequenceValues transactionDefinition[] = {
- {25, 1},
- {25, 2},
- {20, 3},
- {15, 4},
- {15, 5},
- {0, 0}
-};
-
-static SequenceValues rollbackDefinition[] = {
- {98, 0},
- {2 , 1},
- {0, 0}
-};
-
-static int maxsize = 0;
-
-/***************************************************************
-* P U B L I C D A T A *
-***************************************************************/
-
-/***************************************************************
-****************************************************************
-* L O C A L F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-static void getRandomSubscriberNumber(SubscriberNumber number)
-{
- uint32 tmp;
- char sbuf[SUBSCRIBER_NUMBER_LENGTH + 1];
- tmp = myRandom48(NO_OF_SUBSCRIBERS);
- sprintf(sbuf, "%.*d", SUBSCRIBER_NUMBER_LENGTH, tmp);
- memcpy(number, sbuf, SUBSCRIBER_NUMBER_LENGTH);
-}
-
-static void getRandomServerId(ServerId *serverId)
-{
- *serverId = myRandom48(NO_OF_SERVERS);
-}
-
-static void getRandomChangedBy(ChangedBy changedBy)
-{
- memset(changedBy, myRandom48(26)+'A', CHANGED_BY_LENGTH);
- changedBy[CHANGED_BY_LENGTH] = 0;
-}
-
-static void getRandomChangedTime(ChangedTime changedTime)
-{
- memset(changedTime, myRandom48(26)+'A', CHANGED_TIME_LENGTH);
- changedTime[CHANGED_TIME_LENGTH] = 0;
-}
-
-static void clearTransaction(TransactionDefinition *trans)
-{
- trans->benchTime = 0.0;
- trans->count = 0;
- trans->branchExecuted = 0;
- trans->rollbackExecuted = 0;
-}
-
-static int listFull(SessionList *list)
-{
- return(list->numberInList == SESSION_LIST_LENGTH);
-}
-
-static int listEmpty(SessionList *list)
-{
- return(list->numberInList == 0);
-}
-
-static void insertSession(SessionList *list,
- SubscriberNumber number,
- ServerId serverId)
-{
- SessionElement *e;
- if( listFull(list) ) return;
-
- e = &list->list[list->writeIndex];
-
- strcpy(e->subscriberNumber, number);
- e->serverId = serverId;
-
- list->writeIndex = (list->writeIndex + 1) % SESSION_LIST_LENGTH;
- list->numberInList++;
-
-if( list->numberInList > maxsize )
-maxsize = list->numberInList;
-}
-
-static SessionElement *getNextSession(SessionList *list)
-{
- if( listEmpty(list) ) return(0);
-
- return(&list->list[list->readIndex]);
-}
-
-static void deleteSession(SessionList *list)
-{
- if( listEmpty(list) ) return;
-
- list->readIndex = (list->readIndex + 1) % SESSION_LIST_LENGTH;
- list->numberInList--;
-}
-
-static void initGeneratorStatistics(GeneratorStatistics *gen)
-{
- int i;
-
- if( initSequence(&gen->transactionSequence,
- transactionDefinition) != 0 ) {
- printf("could not set the transaction types\n");
- exit(0);
- }
-
- if( initSequence(&gen->rollbackSequenceT4,
- rollbackDefinition) != 0 ) {
- printf("could not set the rollback sequence\n");
- exit(0);
- }
-
- if( initSequence(&gen->rollbackSequenceT5,
- rollbackDefinition) != 0 ) {
- printf("could not set the rollback sequence\n");
- exit(0);
- }
-
- for(i = 0; i < NUM_TRANSACTION_TYPES; i++ )
- clearTransaction(&gen->transactions[i]);
-
- gen->totalTransactions = 0;
-
- gen->activeSessions.numberInList = 0;
- gen->activeSessions.readIndex = 0;
- gen->activeSessions.writeIndex = 0;
-}
-
-
-static void doOneTransaction(UserHandle *uh, GeneratorStatistics *gen)
-{
- unsigned int transactionType;
-
- transactionType = getNextRandom(&gen->transactionSequence);
-
- switch(transactionType) {
- case 1:
- doTransaction_T1(uh, gen);
- break;
- case 2:
- doTransaction_T2(uh, gen);
- break;
- case 3:
- doTransaction_T3(uh, gen);
- break;
- case 4:
- doTransaction_T4(uh, gen);
- break;
- case 5:
- doTransaction_T5(uh, gen);
- break;
- default:
- printf("Unknown transaction type: %d\n", transactionType);
- }
-
- gen->totalTransactions++;
-}
-
-static void doTransaction_T1(UserHandle *uh, GeneratorStatistics *gen)
-{
- SubscriberNumber number;
- Location new_location;
- ChangedBy changed_by;
- ChangedTime changed_time;
-
- double start_time;
- double end_time;
- double transaction_time;
-
- unsigned int tid = 0;
-
- /*----------------*/
- /* Init arguments */
- /*----------------*/
- getRandomSubscriberNumber(number);
- getRandomChangedBy(changed_by);
- getRandomChangedTime(changed_time);
- new_location = changed_by[0];
-
- /*-----------------*/
- /* Run transaction */
- /*-----------------*/
- start_time = userGetTimeSync();
- userTransaction_T1(uh,
- number,
- new_location,
- changed_by,
- changed_time);
- end_time = userGetTimeSync();
-
- /*-------------------*/
- /* Update Statistics */
- /*-------------------*/
- transaction_time = end_time - start_time;
- gen->transactions[tid].benchTime += transaction_time;
- gen->transactions[tid].count++;
-}
-
-static void doTransaction_T2(UserHandle *uh, GeneratorStatistics *gen)
-{
- SubscriberNumber number;
- Location new_location;
- ChangedBy changed_by;
- ChangedTime changed_time;
- SubscriberName subscriberName;
-
- double start_time;
- double end_time;
- double transaction_time;
-
- unsigned int tid = 1;
-
- /*----------------*/
- /* Init arguments */
- /*----------------*/
- getRandomSubscriberNumber(number);
-
- /*-----------------*/
- /* Run transaction */
- /*-----------------*/
- start_time = userGetTimeSync();
- userTransaction_T2(uh,
- number,
- &new_location,
- changed_by,
- changed_time,
- subscriberName);
- end_time = userGetTimeSync();
-
- /*-------------------*/
- /* Update Statistics */
- /*-------------------*/
- transaction_time = end_time - start_time;
- gen->transactions[tid].benchTime += transaction_time;
- gen->transactions[tid].count++;
-}
-
-static void doTransaction_T3(UserHandle *uh, GeneratorStatistics *gen)
-{
- SubscriberNumber number;
- ServerId serverId;
- ServerBit serverBit;
- SessionDetails sessionDetails;
- unsigned int branchExecuted;
- SessionElement *se;
-
- double start_time;
- double end_time;
- double transaction_time;
-
- unsigned int tid = 2;
-
- /*----------------*/
- /* Init arguments */
- /*----------------*/
- se = getNextSession(&gen->activeSessions);
- if( se ) {
- strcpy(number, se->subscriberNumber);
- serverId = se->serverId;
- }
- else {
- getRandomSubscriberNumber(number);
- getRandomServerId(&serverId);
- }
-
- serverBit = 1 << serverId;
-
- /*-----------------*/
- /* Run transaction */
- /*-----------------*/
- start_time = userGetTimeSync();
- userTransaction_T3(uh,
- number,
- serverId,
- serverBit,
- sessionDetails,
- &branchExecuted);
- end_time = userGetTimeSync();
-
- /*-------------------*/
- /* Update Statistics */
- /*-------------------*/
- transaction_time = end_time - start_time;
- gen->transactions[tid].benchTime += transaction_time;
- gen->transactions[tid].count++;
-
- if(branchExecuted)
- gen->transactions[tid].branchExecuted++;
-}
-
-static void doTransaction_T4(UserHandle *uh, GeneratorStatistics *gen)
-{
- SubscriberNumber number;
- ServerId serverId;
- ServerBit serverBit;
- SessionDetails sessionDetails;
- unsigned int branchExecuted;
- unsigned int rollback;
-
- double start_time;
- double end_time;
- double transaction_time;
-
- unsigned int tid = 3;
-
- /*----------------*/
- /* Init arguments */
- /*----------------*/
- getRandomSubscriberNumber(number);
- getRandomServerId(&serverId);
-
- serverBit = 1 << serverId;
- rollback = getNextRandom(&gen->rollbackSequenceT4);
-
- memset(sessionDetails, myRandom48(26)+'A', SESSION_DETAILS_LENGTH);
- sessionDetails[SESSION_DETAILS_LENGTH] = 0;
-
- /*-----------------*/
- /* Run transaction */
- /*-----------------*/
- start_time = userGetTimeSync();
- userTransaction_T4(uh,
- number,
- serverId,
- serverBit,
- sessionDetails,
- rollback,
- &branchExecuted);
- end_time = userGetTimeSync();
-
- /*-------------------*/
- /* Update Statistics */
- /*-------------------*/
- transaction_time = end_time - start_time;
- gen->transactions[tid].benchTime += transaction_time;
- gen->transactions[tid].count++;
-
- if(branchExecuted)
- gen->transactions[tid].branchExecuted++;
- if(rollback)
- gen->transactions[tid].rollbackExecuted++;
-
- if( branchExecuted && !rollback ) {
- insertSession(&gen->activeSessions, number, serverId);
- }
-}
-
-static void doTransaction_T5(UserHandle *uh, GeneratorStatistics *gen)
-{
- SubscriberNumber number;
- ServerId serverId;
- ServerBit serverBit;
- unsigned int branchExecuted;
- unsigned int rollback;
- SessionElement *se;
-
- double start_time;
- double end_time;
- double transaction_time;
-
- unsigned int tid = 4;
-
- /*----------------*/
- /* Init arguments */
- /*----------------*/
- se = getNextSession(&gen->activeSessions);
- if( se ) {
- strcpy(number, se->subscriberNumber);
- serverId = se->serverId;
- }
- else {
- getRandomSubscriberNumber(number);
- getRandomServerId(&serverId);
- }
-
- serverBit = 1 << serverId;
- rollback = getNextRandom(&gen->rollbackSequenceT5);
-
- /*-----------------*/
- /* Run transaction */
- /*-----------------*/
- start_time = userGetTimeSync();
- userTransaction_T5(uh,
- number,
- serverId,
- serverBit,
- rollback,
- &branchExecuted);
- end_time = userGetTimeSync();
-
- /*-------------------*/
- /* Update Statistics */
- /*-------------------*/
- transaction_time = end_time - start_time;
- gen->transactions[tid].benchTime += transaction_time;
- gen->transactions[tid].count++;
-
- if(branchExecuted)
- gen->transactions[tid].branchExecuted++;
- if(rollback)
- gen->transactions[tid].rollbackExecuted++;
-
- if( se && !rollback) {
- deleteSession(&gen->activeSessions);
- }
-}
-
-/***************************************************************
-****************************************************************
-* P U B L I C F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-
-void dbGenerator(UserHandle *uh, ThreadData *data)
-{
- GeneratorStatistics rg_warmUp;
- GeneratorStatistics rg_coolDown;
- GeneratorStatistics *st;
- double periodStop;
- double benchTimeStart;
- double benchTimeEnd;
- int i;
-
- myRandom48Init(data->randomSeed);
-
- initGeneratorStatistics(&rg_warmUp);
- initGeneratorStatistics(&data->generator);
- initGeneratorStatistics(&rg_coolDown);
-
- /*----------------*/
- /* warm up period */
- /*----------------*/
- periodStop = userGetTimeSync() + (double)data->warmUpSeconds;
- while(userGetTimeSync() < periodStop){
- doOneTransaction(uh, &rg_warmUp);
- }
-
- /*-------------------------*/
- /* normal benchmark period */
- /*-------------------------*/
- benchTimeStart = userGetTimeSync();
-
- if( data->numTransactions > 0 ) {
- for(i = 0; i < data->numTransactions; i++)
- doOneTransaction(uh, &data->generator);
- }
- else {
- periodStop = benchTimeStart + (double)data->testSeconds;
- while(userGetTimeSync() < periodStop)
- doOneTransaction(uh, &data->generator);
- }
-
- benchTimeEnd = userGetTimeSync();
-
- /*------------------*/
- /* cool down period */
- /*------------------*/
- periodStop = benchTimeEnd + data->coolDownSeconds;
- while(userGetTimeSync() < periodStop){
- doOneTransaction(uh, &rg_coolDown);
- }
-
- /*---------------------------------------------------------*/
- /* add the times for all transaction for inner loop timing */
- /*---------------------------------------------------------*/
- st = &data->generator;
- st->innerLoopTime = 0.0;
- for(i = 0 ; i < NUM_TRANSACTION_TYPES; i++) {
- st->innerLoopTime += st->transactions[i].benchTime;
- st->transactions[i].tps = getTps(st->transactions[i].count,
- st->transactions[i].benchTime);
- }
-
- st->outerLoopTime = benchTimeEnd - benchTimeStart;
- st->outerTps = getTps(st->totalTransactions, st->outerLoopTime);
- st->innerTps = getTps(st->totalTransactions, st->innerLoopTime);
-
- /* printf("maxsize = %d\n",maxsize); */
-}
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.h b/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.h
deleted file mode 100644
index 206b13c3f00..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-#ifndef DBGENERATOR_H
-#define DBGENERATOR_H
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include "testData.h"
-#include "userInterface.h"
-
-/***************************************************************
-* M A C R O S *
-***************************************************************/
-
-/***************************************************************/
-/* C O N S T A N T S */
-/***************************************************************/
-
-/***************************************************************
-* D A T A S T R U C T U R E S *
-***************************************************************/
-
-/***************************************************************
-* P U B L I C F U N C T I O N S *
-***************************************************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void dbGenerator(UserHandle *uh, ThreadData *data);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/***************************************************************
-* E X T E R N A L D A T A *
-***************************************************************/
-
-
-
-#endif /* DBGENERATOR_H */
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/mainGenerator.c b/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/mainGenerator.c
deleted file mode 100644
index cb47207a0f2..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/mainGenerator.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 <ndb_global.h>
-
-#include <NdbHost.h>
-#include <NdbSleep.h>
-#include <NdbThread.h>
-#include <NdbMain.h>
-
-#include "userInterface.h"
-#include "dbGenerator.h"
-
-
-static int numProcesses;
-static int numTransactions;
-static int numSeconds;
-static int numWarmSeconds;
-static char *testDbName;
-
-static ThreadData data[100];
-
-typedef struct {
- pthread_t threadId;
- int waitSeconds;
- int toExit;
-}CheckpointData;
-
-static void usage(char *prog)
-{
- char *progname;
-
- /*--------------------------------------------*/
- /* Get the name of the program (without path) */
- /*--------------------------------------------*/
- progname = strrchr(prog, '/');
-
- if (progname == 0)
- progname = prog;
- else
- ++progname;
-
- fprintf(stderr,
- "Usage: %s [-db <name>] [-proc <num>] [-transactions <num>] [-time <num>]\n"
- " -db <name> Specifies the database name\n"
- " default = '%s'\n"
- " -proc <num> Specifies that <num> is the number of\n"
- " concurrent processes. The default is 1.\n"
- " -transactions <num> Specifies that <num> transactions will be\n"
- " performed. The default is to do a specific time interval\n"
- " -time <num> Specifies that the test will run for <num> sec.\n"
- " The default is 10 sec\n"
- " -warm <num> Specifies the warm-up/cooldown period of <num> sec.\n"
- " The default is 10 sec\n",
- progname, DEFAULTDB);
- exit(1);
-}
-
-static void parse_args(int argc,char **argv)
-{
- int i;
-
- testDbName = DEFAULTDB;
- numProcesses = 1;
- numTransactions = 0;
- numSeconds = 10;
- numWarmSeconds = 10;
-
- i = 1;
- while (i < argc){
- if (strcmp("-db",argv[i]) == 0) {
- if (i + 1 >= argc) {
- usage(argv[0]);
- exit(1);
- }
- testDbName = argv[i + 1];
- i += 2;
- }
- else if (strcmp("-proc",argv[i]) == 0) {
- if (i + 1 >= argc) {
- usage(argv[0]);
- exit(1);
- }
- if (sscanf(argv[i+1], "%d", &numProcesses) == -1 ||
- numProcesses <= 0 || numProcesses > 99) {
- fprintf(stderr, "-proc flag requires a positive integer argument [1..99]\n");
- usage(argv[0]);
- exit(1);
- }
- i += 2;
- }
- else if (strcmp("-transactions",argv[i]) == 0) {
- if (i + 1 >= argc) {
- usage(argv[0]);
- exit(1);
- }
- if (sscanf(argv[i+1], "%d", &numTransactions) == -1 ||
- numTransactions < 0) {
- fprintf(stderr, "-transactions flag requires a positive integer argument\n");
- usage(argv[0]);
- exit(1);
- }
- i += 2;
- }
- else if (strcmp("-time",argv[i]) == 0) {
- if (i + 1 >= argc) {
- usage(argv[0]);
- exit(1);
- }
- if (sscanf(argv[i+1], "%d", &numSeconds) == -1 ||
- numSeconds < 0) {
- fprintf(stderr, "-time flag requires a positive integer argument\n");
- usage(argv[0]);
- exit(1);
- }
- i += 2;
- }
- else if (strcmp("-warm",argv[i]) == 0) {
- if (i + 1 >= argc) {
- usage(argv[0]);
- exit(1);
- }
- if (sscanf(argv[i+1], "%d", &numWarmSeconds) == -1 ||
- numWarmSeconds < 0) {
- fprintf(stderr, "-warm flag requires a positive integer argument\n");
- usage(argv[0]);
- exit(1);
- }
- i += 2;
- }
- else
- usage(argv[0]);
- }
-}
-
-static void print_transaction(const char *header,
- unsigned long totalCount,
- TransactionDefinition *trans,
- unsigned int printBranch,
- unsigned int printRollback)
-{
- double f;
-
- printf(" %s: %d (%.2f%%) Time: %.4f sec TPS = %.0f\n",
- header,
- trans->count,
- (double)trans->count / (double)totalCount * 100.0,
- trans->benchTime,
- trans->tps);
-
- if( printBranch ){
- if( trans->count == 0 )
- f = 0.0;
- else
- f = (double)trans->branchExecuted / (double)trans->count * 100.0;
- printf(" Branches Executed: %d (%.2f%%)\n", trans->branchExecuted, f);
- }
-
- if( printRollback ){
- if( trans->count == 0 )
- f = 0.0;
- else
- f = (double)trans->rollbackExecuted / (double)trans->count * 100.0;
- printf(" Rollback Executed: %d (%.2f%%)\n", trans->rollbackExecuted, f);
- }
-}
-
-void print_stats_sync(const char *title,
- unsigned int length,
- unsigned int transactionFlag,
- GeneratorStatistics *gen,
- int numProc)
-{
- int i;
- char buf[10];
- char name[100];
-
- name[0] = 0;
- NdbHost_GetHostName(name);
-
- printf("\n------ %s ------\n",title);
- printf("Length : %d %s\n",
- length,
- transactionFlag ? "Transactions" : "sec");
- printf("Processor : %s\n", name);
- printf("Number of Proc: %d\n",numProc);
- printf("\n");
-
- if( gen->totalTransactions == 0 ) {
- printf(" No Transactions for this test\n");
- }
- else {
- for(i = 0; i < 5; i++) {
- sprintf(buf, "T%d",i+1);
- print_transaction(buf,
- gen->totalTransactions,
- &gen->transactions[i],
- i >= 2,
- i >= 3 );
- }
-
- printf("\n");
- printf(" Overall Statistics:\n");
- printf(" Transactions: %d\n", gen->totalTransactions);
- printf(" Inner : %.0f TPS\n",gen->innerTps);
- printf(" Outer : %.0f TPS\n",gen->outerTps);
- printf("\n");
- }
-}
-
-static void *threadRoutine(void *arg)
-{
- UserHandle *uh;
- ThreadData *data = (ThreadData *)arg;
-
- uh = userDbConnect(0, testDbName);
- NdbSleep_MilliSleep(data->threadId);
- dbGenerator(uh,data);
- userDbDisconnect(uh);
-
- pthread_exit(0);
- return(0);
-}
-
-NDB_COMMAND(DbGenerator, "DbGenerator", "DbGenerator", "DbGenerator", 16384)
-{
- int i;
- int j;
- GeneratorStatistics stats;
- GeneratorStatistics *p;
- CheckpointData cd;
-
- parse_args(argc,argv);
-
- printf("\nStarting Test with %d process(es) for %d %s\n",
- numProcesses,
- numTransactions ? numTransactions : numSeconds,
- numTransactions ? "Transactions" : "sec");
- printf(" WarmUp/coolDown = %d sec\n", numWarmSeconds);
-
- /*
- cd.waitSeconds = 300;
- cd.toExit = 0;
- pthread_create(&cd.threadId, 0, checkpointRoutine, &cd);
- */
-
- for(i = 0; i < numProcesses; i++) {
- data[i].warmUpSeconds = numWarmSeconds;
- data[i].testSeconds = numSeconds;
- data[i].coolDownSeconds = numWarmSeconds;
- data[i].numTransactions = numTransactions;
- data[i].randomSeed = time(0)+i;
- j = pthread_create(&data[i].threadId, 0, threadRoutine, &data[i]);
- if(j != 0){
- perror("Failed to create thread");
- }
- }
-
- /*--------------------------------*/
- /* Wait for all processes to exit */
- /*--------------------------------*/
- for(i = 0; i < numProcesses; i++)
- pthread_join(data[i].threadId, 0);
-
- printf("All threads have finished\n");
-
- cd.toExit = 1;
-
- /*-------------------------------------------*/
- /* Clear all structures for total statistics */
- /*-------------------------------------------*/
- stats.totalTransactions = 0;
- stats.outerTps = 0.0;
- stats.innerTps = 0.0;
-
- for(i = 0; i < NUM_TRANSACTION_TYPES; i++ ) {
- stats.transactions[i].benchTime = 0.0;
- stats.transactions[i].count = 0;
- stats.transactions[i].tps = 0.0;
- stats.transactions[i].branchExecuted = 0;
- stats.transactions[i].rollbackExecuted = 0;
- }
-
- /*--------------------------------*/
- /* Add the values for all Threads */
- /*--------------------------------*/
- for(i = 0; i < numProcesses; i++) {
- p = &data[i].generator;
-
- stats.totalTransactions += p->totalTransactions;
- stats.outerTps += p->outerTps;
- stats.innerTps += p->innerTps;
-
- for(j = 0; j < NUM_TRANSACTION_TYPES; j++ ) {
- stats.transactions[j].benchTime += p->transactions[j].benchTime;
- stats.transactions[j].count += p->transactions[j].count;
- stats.transactions[j].tps += p->transactions[j].tps;
- stats.transactions[j].branchExecuted += p->transactions[j].branchExecuted;
- stats.transactions[j].rollbackExecuted += p->transactions[j].rollbackExecuted;
- }
- }
-
- print_stats_sync("Test Results",
- numTransactions ? numTransactions : numSeconds,
- numTransactions ? 1 : 0,
- &stats,
- numProcesses);
-
- return(0);
-}
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/testData.h b/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/testData.h
deleted file mode 100644
index 494b111ea7f..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/testData.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-#ifndef TESTDATA_H
-#define TESTDATA_H
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include "testDefinitions.h"
-#include <random.h>
-
-/***************************************************************
-* M A C R O S *
-***************************************************************/
-
-/***************************************************************/
-/* C O N S T A N T S */
-/***************************************************************/
-
-#define NUM_TRANSACTION_TYPES 5
-#define SESSION_LIST_LENGTH 1000
-
-/***************************************************************
-* D A T A S T R U C T U R E S *
-***************************************************************/
-
-typedef struct {
- SubscriberNumber subscriberNumber;
- ServerId serverId;
-} SessionElement;
-
-typedef struct {
- SessionElement list[SESSION_LIST_LENGTH];
- unsigned int readIndex;
- unsigned int writeIndex;
- unsigned int numberInList;
-} SessionList;
-
-typedef struct {
- double benchTime;
- unsigned int count;
- double tps;
- unsigned int branchExecuted;
- unsigned int rollbackExecuted;
-}TransactionDefinition;
-
-typedef struct {
- RandomSequence transactionSequence;
- RandomSequence rollbackSequenceT4;
- RandomSequence rollbackSequenceT5;
-
- TransactionDefinition transactions[NUM_TRANSACTION_TYPES];
-
- unsigned int totalTransactions;
-
- double innerLoopTime;
- double innerTps;
-
- double outerLoopTime;
- double outerTps;
-
- SessionList activeSessions;
-} GeneratorStatistics;
-
-typedef struct {
- unsigned long threadId;
- unsigned long randomSeed;
-
- unsigned int warmUpSeconds;
- unsigned int testSeconds;
- unsigned int coolDownSeconds;
- unsigned int numTransactions;
-
- GeneratorStatistics generator;
-}ThreadData;
-
-/***************************************************************
-* P U B L I C F U N C T I O N S *
-***************************************************************/
-
-/***************************************************************
-* E X T E R N A L D A T A *
-***************************************************************/
-
-
-
-#endif /* TESTDATA_H */
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/userInterface.h b/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/userInterface.h
deleted file mode 100644
index ed1146f3a0c..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/userInterface.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-#ifndef DBINTERFACE_H
-#define DBINTERFACE_H
-
-/***************************************************************/
-/* I N C L U D E D F I L E S */
-/***************************************************************/
-
-#include "testDefinitions.h"
-
-/***************************************************************
-* M A C R O S *
-***************************************************************/
-
-/***************************************************************/
-/* C O N S T A N T S */
-/***************************************************************/
-
-/*-----------------------*/
-/* Default Database Name */
-/*-----------------------*/
-#define DEFAULTDB "TestDbClient"
-
-/***************************************************************
-* D A T A S T R U C T U R E S *
-***************************************************************/
-
-typedef struct {
- struct Ndb * pNDB;
- struct NdbConnection * pCurrTrans;
-} UserHandle;
-
-/***************************************************************
-* P U B L I C F U N C T I O N S *
-***************************************************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern double userGetTimeSync(void);
-
-extern void userCheckpoint(UserHandle *uh);
-
-extern UserHandle *userDbConnect(uint32 createDb, char *dbName);
-extern void userDbDisconnect(UserHandle *uh);
-
-extern int userDbInsertServer(UserHandle *uh,
- ServerId serverId,
- SubscriberSuffix suffix,
- ServerName name);
-
-extern int userDbInsertSubscriber(UserHandle *uh,
- SubscriberNumber number,
- uint32 groupId,
- SubscriberName name);
-
-extern int userDbInsertGroup(UserHandle *uh,
- GroupId groupId,
- GroupName name,
- Permission allowRead,
- Permission allowInsert,
- Permission allowDelete);
-
-extern int userDbCommit(UserHandle *uh);
-extern int userDbRollback(UserHandle *uh);
-
-extern void userTransaction_T1(UserHandle *uh,
- SubscriberNumber number,
- Location new_location,
- ChangedBy changed_by,
- ChangedTime changed_time);
-
-extern void userTransaction_T2(UserHandle *uh,
- SubscriberNumber number,
- Location *new_location,
- ChangedBy changed_by,
- ChangedTime changed_time,
- SubscriberName subscriberName);
-
-extern void userTransaction_T3(UserHandle *uh,
- SubscriberNumber number,
- ServerId server_id,
- ServerBit server_bit,
- SessionDetails session_details,
- unsigned int *branch_executed);
-
-extern void userTransaction_T4(UserHandle *uh,
- SubscriberNumber number,
- ServerId server_id,
- ServerBit server_bit,
- SessionDetails session_details,
- unsigned int do_rollback,
- unsigned int *branch_executed);
-
-extern void userTransaction_T5(UserHandle *uh,
- SubscriberNumber number,
- ServerId server_id,
- ServerBit server_bit,
- unsigned int do_rollback,
- unsigned int *branch_executed);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/***************************************************************
-* E X T E R N A L D A T A *
-***************************************************************/
-
-#endif /* DBINTERFACE_H */
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.linux b/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.linux
deleted file mode 100644
index a933669cfe7..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.linux
+++ /dev/null
@@ -1,6 +0,0 @@
-PROJECT_TOP = /home/lmcritr/ecurlmc/users/lmcritr/dbBenchmark
-
-CFLAGS = -Wall -Wstrict-prototypes -O2 -I/opt/TimesTen4.1/32/include/ -I../include
-LDFLAGS = -L/opt/TimesTen4.1/32/lib -Wl,-rpath,/opt/TimesTen4.1/32/lib
-LIBS = -ltten -ldl
-LIBSCS = -lttclient -ldl
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.sparc b/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.sparc
deleted file mode 100644
index 57ab8bf982f..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.sparc
+++ /dev/null
@@ -1,15 +0,0 @@
-
-include $(UAS_TOP)/Defs.mk
-
-LINK.CC = CC
-CC := /opt/as/forte6/SUNWspro/bin/cc
-export CC
-
-NDB_LIB = -L$(UAS_TOP)/API -lNDB_API \
- -L$(UAS_OSPACE_LOC)/lib -lospace \
- -lrt
-
-CFLAGS = -xO3 -I../include -mt
-LDFLAGS = $(NDB_LIB) -lpthread
-LIBS =
-LIBSCS =
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/Makefile b/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/Makefile
deleted file mode 100644
index 2107c948843..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-include .defs.mk
-
-TYPE := ndbapitest
-
-BIN_TARGET := DbCreate
-BIN_TARGET_ARCHIVES := lmc_User
-
-CCFLAGS_LOC:= -I../include -I../../include
-
-SOURCES := \
- mainPopulate.c\
- dbPopulate.c
-
-include $(NDB_TOP)/Epilogue.mk
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.c b/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.c
deleted file mode 100644
index 89c312ab636..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include <ndb_global.h>
-
-#include "userInterface.h"
-
-#include "dbPopulate.h"
-#include <NdbOut.hpp>
-#include <random.h>
-
-/***************************************************************
-* L O C A L C O N S T A N T S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L D A T A S T R U C T U R E S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L F U N C T I O N S *
-***************************************************************/
-
-static void getRandomSubscriberData(int subscriberNo,
- SubscriberNumber number,
- SubscriberName name);
-
-static void populate(char *title,
- int count,
- void (*func)(UserHandle*,int),
- UserHandle *uh);
-
-static void populateServers(UserHandle *uh, int count);
-static void populateSubscribers(UserHandle *uh, int count);
-static void populateGroups(UserHandle *uh, int count);
-
-/***************************************************************
-* L O C A L D A T A *
-***************************************************************/
-
-static SequenceValues permissionsDefinition[] = {
- {90, 1},
- {10, 0},
- {0, 0}
-};
-
-/***************************************************************
-* P U B L I C D A T A *
-***************************************************************/
-
-
-/***************************************************************
-****************************************************************
-* L O C A L F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-static void getRandomSubscriberData(int subscriberNo,
- SubscriberNumber number,
- SubscriberName name)
-{
- char sbuf[SUBSCRIBER_NUMBER_LENGTH + 1];
- sprintf(sbuf, "%.*d", SUBSCRIBER_NUMBER_LENGTH, subscriberNo);
- memcpy(number, sbuf, SUBSCRIBER_NUMBER_LENGTH);
-
- memset(name, myRandom48(26)+'A', SUBSCRIBER_NAME_LENGTH);
-}
-
-static void populate(char *title,
- int count,
- void (*func)(UserHandle*, int),
- UserHandle *uh)
-{
- ndbout_c("Populating %d '%s' ... ",count, title);
- /* fflush(stdout); */
- func(uh,count);
- ndbout_c("done");
-}
-
-static void populateServers(UserHandle *uh, int count)
-{
- int i, j;
- int len;
- char tmp[80];
- int suffix_length = 1;
- ServerName serverName;
- SubscriberSuffix suffix;
-
- int commitCount = 0;
-
- for(i = 0; i < SUBSCRIBER_NUMBER_SUFFIX_LENGTH; i++)
- suffix_length *= 10;
-
- for(i = 0; i < count; i++) {
- sprintf(tmp, "-Server %d-", i);
-
- len = strlen(tmp);
- for(j = 0; j < SERVER_NAME_LENGTH; j++){
- serverName[j] = tmp[j % len];
- }
- /* serverName[j] = 0; not null-terminated */
-
- for(j = 0; j < suffix_length; j++){
- char sbuf[SUBSCRIBER_NUMBER_SUFFIX_LENGTH + 1];
- sprintf(sbuf, "%.*d", SUBSCRIBER_NUMBER_SUFFIX_LENGTH, j);
- memcpy(suffix, sbuf, SUBSCRIBER_NUMBER_SUFFIX_LENGTH);
- userDbInsertServer(uh, i, suffix, serverName);
- commitCount ++;
- if((commitCount % OP_PER_TRANS) == 0)
- userDbCommit(uh);
- }
- }
- if((commitCount % OP_PER_TRANS) != 0)
- userDbCommit(uh);
-}
-
-static void populateSubscribers(UserHandle *uh, int count)
-{
- SubscriberNumber number;
- SubscriberName name;
- int i, j, k;
- int res;
-
- SequenceValues values[NO_OF_GROUPS+1];
- RandomSequence seq;
-
- for(i = 0; i < NO_OF_GROUPS; i++) {
- values[i].length = 1;
- values[i].value = i;
- }
-
- values[i].length = 0;
- values[i].value = 0;
-
- if( initSequence(&seq, values) != 0 ) {
- ndbout_c("could not set the sequence of random groups");
- exit(0);
- }
-
-#define RETRIES 25
-
- for(i = 0; i < count; i+= OP_PER_TRANS) {
- for(j = 0; j<RETRIES; j++){
- for(k = 0; k<OP_PER_TRANS && i+k < count; k++){
- getRandomSubscriberData(i+k, number, name);
- userDbInsertSubscriber(uh, number, getNextRandom(&seq), name);
- }
- res = userDbCommit(uh);
- if(res == 0)
- break;
- if(res != 1){
- ndbout_c("Terminating");
- exit(0);
- }
- }
- if(j == RETRIES){
- ndbout_c("Terminating");
- exit(0);
- }
- }
-}
-
-static void populateGroups(UserHandle *uh, int count)
-{
- int i;
- int j;
- int len;
- RandomSequence seq;
- Permission allow[NO_OF_GROUPS];
- ServerBit serverBit;
- GroupName groupName;
- char tmp[80];
- int commitCount = 0;
-
- if( initSequence(&seq, permissionsDefinition) != 0 ) {
- ndbout_c("could not set the sequence of random permissions");
- exit(0);
- }
-
- for(i = 0; i < NO_OF_GROUPS; i++)
- allow[i] = 0;
-
- for(i = 0; i < NO_OF_SERVERS; i++) {
- serverBit = 1 << i;
-
- for(j = 0; j < NO_OF_GROUPS; j++ ) {
- if( getNextRandom(&seq) )
- allow[j] |= serverBit;
- }
- }
-
- for(i = 0; i < NO_OF_GROUPS; i++) {
- sprintf(tmp, "-Group %d-", i);
-
- len = strlen(tmp);
-
- for(j = 0; j < GROUP_NAME_LENGTH; j++) {
- groupName[j] = tmp[j % len];
- }
- /* groupName[j] = 0; not null-terminated */
-
- userDbInsertGroup(uh,
- i,
- groupName,
- allow[i],
- allow[i],
- allow[i]);
- commitCount ++;
- if((commitCount % OP_PER_TRANS) == 0)
- userDbCommit(uh);
- }
- if((commitCount % OP_PER_TRANS) != 0)
- userDbCommit(uh);
-}
-
-/***************************************************************
-****************************************************************
-* P U B L I C F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-void dbPopulate(UserHandle *uh)
-{
- populate("servers", NO_OF_SERVERS, populateServers, uh);
- populate("subscribers", NO_OF_SUBSCRIBERS, populateSubscribers, uh);
- populate("groups", NO_OF_GROUPS, populateGroups, uh);
-}
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.h b/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.h
deleted file mode 100644
index a7220b671b1..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-#ifndef DBPOPULATE_H
-#define DBPOPULATE_H
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include "userInterface.h"
-
-/***************************************************************
-* M A C R O S *
-***************************************************************/
-
-/***************************************************************/
-/* C O N S T A N T S */
-/***************************************************************/
-
-/***************************************************************
-* D A T A S T R U C T U R E S *
-***************************************************************/
-
-/***************************************************************
-* P U B L I C F U N C T I O N S *
-***************************************************************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void dbPopulate(UserHandle *uh);
-
-#ifdef __cplusplus
-}
-#endif
-
-/***************************************************************
-* E X T E R N A L D A T A *
-***************************************************************/
-
-
-
-#endif /* DBPOPULATE_H */
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/mainPopulate.c b/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/mainPopulate.c
deleted file mode 100644
index e882edcc186..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/mainPopulate.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 <ndb_global.h>
-
-#include "userInterface.h"
-#include "dbPopulate.h"
-#include <NdbMain.h>
-#include <NdbOut.hpp>
-#include <random.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-int useTableLogging;
-int useIndexTables;
-#ifdef __cplusplus
-}
-#endif
-
-
-static
-void usage(const char *prog)
-{
-
- ndbout_c(
- "Usage: %s [-l]\n"
- " -l Use logging and checkpointing on tables\n",
- " -i Use index tables\n",
- prog);
-
- exit(1);
-}
-
-NDB_COMMAND(DbCreate, "DbCreate", "DbCreate", "DbCreate", 16384)
-{
- int i;
- UserHandle *uh;
-
- useTableLogging = useIndexTables = 0;
-
- for(i = 1; i<argc; i++){
- if(strcmp(argv[i], "-l") == 0){
- useTableLogging = 1;
- } else if(strcmp(argv[i], "-i") == 0){
- useIndexTables = 1;
- } else {
- usage(argv[0]);
- return 0;
- }
- }
-
- ndbout_c("Using %s tables and %s key storage",
- useTableLogging ? "logging" : "temporary",
- useIndexTables ? "index" : "normal");
-
- myRandom48Init(0x3e6f);
-
- uh = userDbConnect(1, 0);
- dbPopulate(uh);
- userDbDisconnect(uh);
- return(0);
-}
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/Makefile b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/Makefile
deleted file mode 100644
index 9bf229ac84c..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-include .defs.mk
-
-TYPE := ndbapitest
-
-ARCHIVE_TARGET := lmc_User
-
-SOURCES := userInterface.C
-
-CCFLAGS_LOC = -I../include -I../../include
-
-include $(NDB_TOP)/Epilogue.mk
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/localDbPrepare.c b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/localDbPrepare.c
deleted file mode 100644
index f3ad4c9f12f..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/localDbPrepare.c
+++ /dev/null
@@ -1,647 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include <ndb_global.h>
-
-#include "userInterface.h"
-#include "userHandle.h"
-
-/***************************************************************
-* L O C A L C O N S T A N T S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L D A T A S T R U C T U R E S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L F U N C T I O N S *
-***************************************************************/
-
-
-/***************************************************************
-* L O C A L D A T A *
-***************************************************************/
-
-/*----------------*/
-/* Transaction T1 */
-/*----------------*/
-static char *update_subscriber_stmnt = "update subscriber set \
-location = ?,changedBy = ?, changedTime = ? where subscriberNumber = ?";
-
-/*----------------*/
-/* Transaction T2 */
-/*----------------*/
-static char *read_subscriber_stmnt = "select subscriberName,location,\
-changedBy,changedTime from subscriber where subscriberNumber = ? for update";
-
-/*----------------*/
-/* Transaction T3 */
-/*----------------*/
-static char *read_subscriber_session_stmnt = "select activeSessions,groupId,\
-changedBy,changedTime from subscriber where subscriberNumber = ? for update";
-
-static char *read_group_allowRead_stmnt = "select allowRead from userGroup \
-where groupId = ?";
-static char *read_group_allowInsert_stmnt = "select allowInsert from userGroup \
-where groupId = ?";
-static char *read_group_allowDelete_stmnt = "select allowDelete from userGroup \
-where groupId = ?";
-
-static char *read_session_details_stmnt = "select sessionData from userSession \
-where subscriberNumber = ? and serverId = ? for update";
-
-static char *update_noOfRead_stmnt = "update server \
-set noOfRead = noOfRead + 1 where serverId = ? and subscriberSuffix = ?";
-static char *update_noOfInsert_stmnt = "update server \
-set noOfInsert = noOfInsert + 1 where serverId = ? and subscriberSuffix = ?";
-static char *update_noOfDelete_stmnt = "update server \
-set noOfDelete = noOfDelete + 1 where serverId = ? and subscriberSuffix = ?";
-
-static char *insert_session_stmnt = "insert into userSession values (?,?,?)";
-
-static char *delete_session_stmnt = "delete from userSession \
-where subscriberNumber = ? and serverId = ?";
-
-static char *update_subscriber_session_stmnt = "update subscriber set \
-activeSessions = ? where subscriberNumber = ?";
-
-/***************************************************************
-* P U B L I C D A T A *
-***************************************************************/
-
-
-/***************************************************************
-****************************************************************
-* L O C A L F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-extern void handle_error(SQLHDBC hdbc,
- SQLHENV henv,
- SQLHSTMT hstmt,
- SQLRETURN rc,
- char *filename,
- int lineno);
-
-/***************************************************************
-****************************************************************
-* P U B L I C F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-int localDbPrepare(UserHandle *uh)
-{
- SQLRETURN rc;
-
- if(!uh) return(-1);
-
- /*-----------------------------*/
- /* Update Subscriber Statement */
- /*-----------------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->updateSubscriber.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate insert group statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->updateSubscriber.stmt,(SQLCHAR *) update_subscriber_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
-/*
-handle_error(uh->hdbc, uh->henv, uh->updateSubscriber.stmt, rc, __FILE__, __LINE__);
-*/
- printf("Unable to prepare update subscriber statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateSubscriber.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->updateSubscriber.values.location,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare update subscriber statement param 1\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateSubscriber.stmt,
- 2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- CHANGED_BY_LENGTH+1,0,
- uh->updateSubscriber.values.changedBy,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare update subscriber statement param 2\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateSubscriber.stmt,
- 3,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- CHANGED_TIME_LENGTH+1,0,
- uh->updateSubscriber.values.changedTime,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare update subscriber statement param 3\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateSubscriber.stmt,
- 4,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_LENGTH+1,0,
- uh->updateSubscriber.values.number,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare update subscriber statement param 3\n");
- return(-1);
- }
-
- /*---------------------------*/
- /* Read Subscriber Statement */
- /*---------------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->readSubscriber.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate read subscriber statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->readSubscriber.stmt,(SQLCHAR *) read_subscriber_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read subscriber statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->readSubscriber.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_LENGTH+1,0,
- uh->readSubscriber.values.number,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read subscriber statement param 1\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readSubscriber.stmt, 1,
- SQL_C_CHAR,
- uh->readSubscriber.values.name, SUBSCRIBER_NAME_LENGTH+1,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 1 to read subscriber statement\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readSubscriber.stmt, 2,
- SQL_C_DEFAULT,
- &uh->readSubscriber.values.location, 1,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 2 to read subscriber statement\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readSubscriber.stmt, 3,
- SQL_C_CHAR,
- uh->readSubscriber.values.changedBy, CHANGED_BY_LENGTH+1,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 3 to read subscriber statement\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readSubscriber.stmt, 4,
- SQL_C_CHAR,
- uh->readSubscriber.values.changedTime, CHANGED_TIME_LENGTH+1,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 4 to read subscriber statement\n");
- return(-1);
- }
-
- /*------------------------------------*/
- /* Read Subscriber Sessions Statement */
- /*------------------------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->readSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate read subscriber session statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->readSubscriberSession.stmt,(SQLCHAR *) read_subscriber_session_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read subscriber sessions statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->readSubscriberSession.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_LENGTH+1,0,
- uh->readSubscriberSession.values.number,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read subscriber statement param 1\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readSubscriberSession.stmt, 1,
- SQL_C_DEFAULT,
- &uh->readSubscriberSession.values.activeSessions, 0,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 1 to read subscriber sessions statement\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readSubscriberSession.stmt, 2,
- SQL_C_DEFAULT,
- &uh->readSubscriberSession.values.groupId, 0,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 2 to read subscriber sessions statement\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readSubscriberSession.stmt, 3,
- SQL_C_CHAR,
- uh->readSubscriberSession.values.changedBy, CHANGED_BY_LENGTH+1,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 3 to read subscriber sessions statement\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readSubscriberSession.stmt, 4,
- SQL_C_CHAR,
- uh->readSubscriberSession.values.changedTime, CHANGED_TIME_LENGTH+1,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 4 to read subscriber sessions statement\n");
- return(-1);
- }
-
- /*--------------------------------*/
- /* Read Group AllowRead Statement */
- /*--------------------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->readGroupAllowRead.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate read subscriber session statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->readGroupAllowRead.stmt,(SQLCHAR *) read_group_allowRead_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read group allow read statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->readGroupAllowRead.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->readGroupAllowRead.values.groupId,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read allow read statement param 1\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readGroupAllowRead.stmt, 1,
- SQL_C_DEFAULT,
- &uh->readGroupAllowRead.values.allowRead, 0,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 1 to read group allow read statement\n");
- return(-1);
- }
-
- /*----------------------------------*/
- /* Read Group AllowInsert Statement */
- /*----------------------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->readGroupAllowInsert.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate read subscriber session statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->readGroupAllowInsert.stmt,(SQLCHAR *) read_group_allowInsert_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read group allow read statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->readGroupAllowInsert.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->readGroupAllowInsert.values.groupId,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read allow read statement param 1\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readGroupAllowInsert.stmt, 1,
- SQL_C_DEFAULT,
- &uh->readGroupAllowInsert.values.allowInsert, 0,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 1 to read group allow read statement\n");
- return(-1);
- }
-
- /*----------------------------------*/
- /* Read Group AllowDelete Statement */
- /*----------------------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->readGroupAllowDelete.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate read subscriber session statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->readGroupAllowDelete.stmt,(SQLCHAR *) read_group_allowDelete_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read group allow read statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->readGroupAllowDelete.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->readGroupAllowDelete.values.groupId,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read allow read statement param 1\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readGroupAllowDelete.stmt, 1,
- SQL_C_DEFAULT,
- &uh->readGroupAllowDelete.values.allowDelete, 0,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 1 to read group allow read statement\n");
- return(-1);
- }
-
- /*----------------------*/
- /* read session details */
- /*----------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->readSessionDetails.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate read session details statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->readSessionDetails.stmt,(SQLCHAR *) read_session_details_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read session details statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->readSessionDetails.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_LENGTH+1,0,
- uh->readSessionDetails.values.number,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read sessions param 1\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->readSessionDetails.stmt,
- 2,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->readSessionDetails.values.serverId,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read sessions param 2\n");
- return(-1);
- }
-
- rc = SQLBindCol(uh->readSessionDetails.stmt, 1,
- SQL_C_CHAR,
- uh->readSessionDetails.values.details, SESSION_DETAILS_LENGTH+1,
- NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to bind column 1 to read group allow read statement\n");
- return(-1);
- }
-
- /*-------------------*/
- /* Update no of Read */
- /*-------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->updateServerNoOfRead.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate update noOfRead statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->updateServerNoOfRead.stmt,(SQLCHAR *) update_noOfRead_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare update noOfRead statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateServerNoOfRead.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->updateServerNoOfRead.values.serverId,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read noOfRead param 1\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateServerNoOfRead.stmt,
- 2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_SUFFIX_LENGTH+1,0,
- uh->updateServerNoOfRead.values.suffix,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read noOfRead param 2\n");
- return(-1);
- }
-
- /*----------------*/
- /* Insert Session */
- /*----------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->insertSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate update noOfRead statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->insertSession.stmt,(SQLCHAR *) insert_session_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare insert session statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->insertSession.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_LENGTH+1,0,
- uh->insertSession.values.number,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read sessions param 1\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->insertSession.stmt,
- 2,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->insertSession.values.serverId,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read noOfRead param 2\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->insertSession.stmt,
- 3,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SESSION_DETAILS_LENGTH+1,0,
- uh->insertSession.values.details,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read sessions param 1\n");
- return(-1);
- }
-
- /*----------------------------*/
- /* Update subscriber sessions */
- /*----------------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->updateSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate update noOfRead statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->updateSubscriberSession.stmt,(SQLCHAR *) update_subscriber_session_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare update subscriber session statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateSubscriberSession.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->updateSubscriberSession.values.activeSessions,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read noOfRead param 2\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateSubscriberSession.stmt,
- 2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_LENGTH+1,0,
- uh->updateSubscriberSession.values.number,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read sessions param 1\n");
- return(-1);
- }
-
- /*---------------------*/
- /* Update no of Insert */
- /*---------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->updateServerNoOfInsert.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate update noOfRead statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->updateServerNoOfInsert.stmt,(SQLCHAR *) update_noOfInsert_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare update noOfRead statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateServerNoOfInsert.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->updateServerNoOfInsert.values.serverId,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read noOfRead param 1\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateServerNoOfInsert.stmt,
- 2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_SUFFIX_LENGTH+1,0,
- uh->updateServerNoOfInsert.values.suffix,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read noOfRead param 2\n");
- return(-1);
- }
-
- /*----------------*/
- /* Delete Session */
- /*----------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->deleteSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate update noOfRead statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->deleteSession.stmt,(SQLCHAR *) delete_session_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare insert session statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->deleteSession.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_LENGTH+1,0,
- uh->deleteSession.values.number,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read sessions param 1\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->deleteSession.stmt,
- 2,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->deleteSession.values.serverId,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read noOfRead param 2\n");
- return(-1);
- }
-
- /*---------------------*/
- /* Update no of Delete */
- /*---------------------*/
- rc = SQLAllocStmt(uh->hdbc, &uh->updateServerNoOfDelete.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate update noOfRead statement\n");
- return(-1);
- }
-
- rc = SQLPrepare(uh->updateServerNoOfDelete.stmt,(SQLCHAR *) update_noOfDelete_stmnt, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare update noOfRead statement\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateServerNoOfDelete.stmt,
- 1,SQL_PARAM_INPUT,SQL_C_DEFAULT,SQL_INTEGER,
- 0,0,
- &uh->updateServerNoOfDelete.values.serverId,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read noOfRead param 1\n");
- return(-1);
- }
-
- rc = SQLBindParameter(uh->updateServerNoOfDelete.stmt,
- 2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,
- SUBSCRIBER_NUMBER_SUFFIX_LENGTH+1,0,
- uh->updateServerNoOfInsert.values.suffix,0,NULL);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to prepare read noOfRead param 2\n");
- return(-1);
- }
-
- /*-------------------------------*/
- /* Commit all prepare statements */
- /*-------------------------------*/
- rc = SQLTransact(uh->henv, uh->hdbc, SQL_COMMIT);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to commit all prepare insert statement\n");
- return(-1);
- }
-
- return(0);
-}
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/macros.h b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/macros.h
deleted file mode 100644
index c4a9c38f2a3..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/macros.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-#ifndef MACROS_H
-#define MACROS_H
-
-#include <ndb_global.h>
-#include <NdbOut.hpp>
-
-#define ERROR(x) {ndbout_c((x)); }
-#define ERROR1(x,y) {ndbout_c((x), (y)); }
-#define ERROR2(x,y,z) {ndbout_c((x), (y), (z)); }
-#define ERROR3(x,y,z,u) {ndbout_c((x), (y), (z), (u)); }
-#define ERROR4(x,y,z,u,w) {ndbout_c((x), (y), (z), (u), (w)); }
-
-#define INIT_RANDOM(x) srand48((x))
-#define UI_RANDOM(x) ((unsigned int)(lrand48()%(x)))
-
-#define ASSERT(cond, message) \
- { if(!(cond)) { ERROR(message); exit(-1); }}
-
-#ifdef DEBUG_ON
-#define DEBUG(x) {ndbout_c((x)); }
-#define DEBUG1(x,y) {ndbout_c((x), (y)); }
-#define DEBUG2(x,y,z) {ndbout_c((x), (y), (z)); }
-#define DEBUG3(x,y,z,u) {ndbout_c((x), (y), (z), (u)); }
-#define DEBUG4(x,y,z,u,w) {ndbout_c((x), (y), (z), (u), (w)); }
-#define DEBUG5(x,y,z,u,w, v) {ndbout_c((x), (y), (z), (u), (w), (v)); }
-#else
-#define DEBUG(x)
-#define DEBUG1(x,y)
-#define DEBUG2(x,y,z)
-#define DEBUG3(x,y,z,u)
-#define DEBUG4(x,y,z,u,w)
-#define DEBUG5(x,y,z,u,w, v)
-#endif
-
-#endif
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/ndb_error.hpp b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/ndb_error.hpp
deleted file mode 100644
index a86966d128e..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/ndb_error.hpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-#ifndef NDB_ERROR_H
-#define NDB_ERROR_H
-
-#include <NdbOut.hpp>
-
-#define error_handler(x,y, z) { \
- ndbout << x << " " << y << endl; \
- exit(-1); }
-
-#define CHECK_NULL(x,y, z) if(x == 0) \
- error_handler(y,(z->getNdbError()), 0)
-#define CHECK_MINUS_ONE(x, y, z) if(x == -1) \
- error_handler(y,(z->getNdbError()), 0)
-
-#endif
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/Makefile b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/Makefile
deleted file mode 100644
index 9b1247d44af..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-include ../makevars.$(ARCH)
-
-LIBRARY = ../../lib/libUser.so
-
-OBJECTS = \
- $(LIBRARY)(localDbPrepare.o)\
- $(LIBRARY)(userInterface.o)\
- $(LIBRARY)(userTransaction.o)
-
-$(LIBRARY): $(OBJECTS)
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userHandle.h b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userHandle.h
deleted file mode 100644
index 61baca41501..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userHandle.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-#ifndef USERHANDLE_H
-#define USERHANDLE_H
-
-/***************************************************************/
-/* I N C L U D E D F I L E S */
-/***************************************************************/
-
-#include "sql.h"
-#include "sqlext.h"
-#include "sqltypes.h"
-
-#include "testDefinitions.h"
-
-/***************************************************************
-* M A C R O S *
-***************************************************************/
-
-/***************************************************************/
-/* C O N S T A N T S */
-/***************************************************************/
-
-/***************************************************************
-* D A T A S T R U C T U R E S *
-***************************************************************/
-
-struct userHandle{
- SQLHENV henv;
- SQLHDBC hdbc;
- SQLHSTMT stmt;
-
- /*----------------*/
- /* Transaction T1 */
- /*----------------*/
- struct {
- SQLHSTMT stmt;
- struct {
- SubscriberNumber number;
- Location location;
- ChangedBy changedBy;
- ChangedTime changedTime;
- }values;
- }updateSubscriber;
-
- /*----------------*/
- /* Transaction T2 */
- /*----------------*/
- struct {
- SQLHSTMT stmt;
- struct {
- SubscriberNumber number;
- SubscriberName name;
- Location location;
- ChangedBy changedBy;
- ChangedTime changedTime;
- }values;
- }readSubscriber;
-
- /*----------------*/
- /* Transaction T3 */
- /*----------------*/
- struct {
- SQLHSTMT stmt;
- struct {
- GroupId groupId;
- Permission allowRead;
- }values;
- }readGroupAllowRead;
-
- struct {
- SQLHSTMT stmt;
- struct {
- SubscriberNumber number;
- ServerId serverId;
- SessionDetails details;
- }values;
- }readSessionDetails;
-
- struct {
- SQLHSTMT stmt;
- struct {
- ServerId serverId;
- SubscriberSuffix suffix;
- }values;
- }updateServerNoOfRead;
-
- /*----------------*/
- /* Transaction T4 */
- /*----------------*/
- struct {
- SQLHSTMT stmt;
- struct {
- GroupId groupId;
- Permission allowInsert;
- }values;
- }readGroupAllowInsert;
-
- struct {
- SQLHSTMT stmt;
- struct {
- SubscriberNumber number;
- ServerId serverId;
- SessionDetails details;
- }values;
- }insertSession;
-
- struct {
- SQLHSTMT stmt;
- struct {
- ServerId serverId;
- SubscriberSuffix suffix;
- }values;
- }updateServerNoOfInsert;
-
- /*----------------*/
- /* Transaction T5 */
- /*----------------*/
- struct {
- SQLHSTMT stmt;
- struct {
- GroupId groupId;
- Permission allowDelete;
- }values;
- }readGroupAllowDelete;
-
- struct {
- SQLHSTMT stmt;
- struct {
- SubscriberNumber number;
- ServerId serverId;
- }values;
- }deleteSession;
-
- struct {
- SQLHSTMT stmt;
- struct {
- ServerId serverId;
- SubscriberSuffix suffix;
- }values;
- }updateServerNoOfDelete;
-
- /*--------------------------*/
- /* Transaction T3 + T4 + T5 */
- /*--------------------------*/
- struct {
- SQLHSTMT stmt;
- struct {
- SubscriberNumber number;
- uint32 activeSessions;
- GroupId groupId;
- ChangedBy changedBy;
- ChangedTime changedTime;
- }values;
- }readSubscriberSession;
-
- struct {
- SQLHSTMT stmt;
- struct {
- SubscriberNumber number;
- uint32 activeSessions;
- }values;
- }updateSubscriberSession;
-};
-
-/***************************************************************
-* P U B L I C F U N C T I O N S *
-***************************************************************/
-
-/***************************************************************
-* E X T E R N A L D A T A *
-***************************************************************/
-
-
-#endif /* USERHANDLE_H */
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userInterface.c b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userInterface.c
deleted file mode 100644
index 03a9465b32c..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userInterface.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include <ndb_global.h>
-
-#include "userInterface.h"
-#include "userHandle.h"
-
-/***************************************************************
-* L O C A L C O N S T A N T S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L D A T A S T R U C T U R E S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L F U N C T I O N S *
-***************************************************************/
-
-extern int localDbPrepare(UserHandle *uh);
-
-static int dbCreate(UserHandle *uh);
-
-/***************************************************************
-* L O C A L D A T A *
-***************************************************************/
-
-static char *create_subscriber_table =
-"CREATE TABLE subscriber(\
-subscriberNumber CHAR(12) NOT NULL primary key,\
-subscriberName CHAR(32) NOT NULL,\
-groupId INT NOT NULL,\
-location INT NOT NULL,\
-activeSessions INT NOT NULL,\
-changedBy CHAR(32) NOT NULL,\
-changedTime CHAR(32) NOT NULL)";
-
-static char *create_group_table =
-"CREATE TABLE userGroup(\
-groupId INT NOT NULL primary key,\
-groupName CHAR(32) NOT NULL,\
-allowRead INT NOT NULL,\
-allowInsert INT NOT NULL,\
-allowDelete INT NOT NULL)";
-
-static char *create_server_table = "CREATE TABLE server(\
-serverId INT NOT NULL,\
-subscriberSuffix CHAR(2) NOT NULL,\
-serverName CHAR(32) NOT NULL,\
-noOfRead INT NOT NULL,\
-noOfInsert INT NOT NULL,\
-noOfDelete INT NOT NULL,\
-PRIMARY KEY(serverId,subscriberSuffix))";
-
-static char *create_session_table =
-"CREATE TABLE userSession(\
-subscriberNumber CHAR(12) NOT NULL,\
-serverId INT NOT NULL,\
-sessionData CHAR(2000) NOT NULL,\
-PRIMARY KEY(subscriberNumber,serverId))";
-
-/***************************************************************
-* P U B L I C D A T A *
-***************************************************************/
-
-
-/***************************************************************
-****************************************************************
-* L O C A L F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-/***************************************************************
-****************************************************************
-* P U B L I C F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-/*-----------------------------------*/
-/* Time related Functions */
-/* */
-/* Returns a double value in seconds */
-/*-----------------------------------*/
-double userGetTime(void)
-{
- static int initialized = 0;
- static struct timeval initTime;
- double timeValue;
-
- if( !initialized ) {
- initialized = 1;
- gettimeofday(&initTime, 0);
- timeValue = 0.0;
- }
- else {
- struct timeval tv;
- double s;
- double us;
-
- gettimeofday(&tv, 0);
- s = (double)tv.tv_sec - (double)initTime.tv_sec;
- us = (double)tv.tv_usec - (double)initTime.tv_usec;
-
- timeValue = s + (us / 1000000.0);
- }
-
- return(timeValue);
-}
-
-
-void handle_error(SQLHDBC hdbc,
- SQLHENV henv,
- SQLHSTMT hstmt,
- SQLRETURN rc,
- char *filename,
- int lineno)
-{
-#define MSG_LNG 512
-
- int isError = 0;
- SQLRETURN ret = SQL_SUCCESS;
- SQLCHAR szSqlState[MSG_LNG]; /* SQL state string */
- SQLCHAR szErrorMsg[MSG_LNG]; /* Error msg text buffer pointer */
- SQLINTEGER pfNativeError; /* Native error code */
- SQLSMALLINT pcbErrorMsg; /* Error msg text Available bytes */
-
- if ( rc == SQL_SUCCESS || rc == SQL_NO_DATA_FOUND )
- return;
- else if ( rc == SQL_INVALID_HANDLE ) {
- printf("ERROR in %s, line %d: invalid handle\n",
- filename, lineno);
- isError = 1;
- }
- else if ( rc == SQL_SUCCESS_WITH_INFO ) {
- printf("WARNING in %s, line %d\n",
- filename, lineno);
- isError = 0;
- }
- else if ( rc == SQL_ERROR ) {
- printf("ERROR in %s, line %d\n",
- filename, lineno);
- isError = 1;
- }
-
- fflush(stdout);
-
- while ( ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO ) {
- ret = SQLError(henv, hdbc, hstmt, szSqlState, &pfNativeError, szErrorMsg,
- MSG_LNG, &pcbErrorMsg);
-
- switch (ret) {
- case SQL_SUCCESS:
- case SQL_SUCCESS_WITH_INFO:
- printf("%s\n*** ODBC Error/Warning = %s, "
- "Additional Error/Warning = %d\n",
- szErrorMsg, szSqlState, pfNativeError);
-
- if(ret == SQL_SUCCESS_WITH_INFO)
- printf("(Note: error message was truncated.\n");
- break;
-
- case SQL_INVALID_HANDLE:
- printf("Call to SQLError failed with return code of "
- "SQL_INVALID_HANDLE.\n");
- break;
-
- case SQL_ERROR:
- printf("Call to SQLError failed with return code of SQL_ERROR.\n");
- break;
-
- case SQL_NO_DATA_FOUND:
- break;
-
- default:
- printf("Call to SQLError failed with return code of %d.\n", ret);
- }
- }
-
- if ( isError )
- exit(1);
-}
-
-static int dbCreate(UserHandle *uh)
-{
- SQLRETURN rc;
- SQLHSTMT creatstmt;
-
- if(!uh) return(-1);
-
- rc = SQLAllocStmt(uh->hdbc, &creatstmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate create statement\n");
- return(-1);
- }
-
- rc = SQLExecDirect(creatstmt,(SQLCHAR *)create_subscriber_table, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to create subscriber table\n");
- return(-1);
- }
-
- rc = SQLExecDirect(creatstmt,(SQLCHAR *)create_group_table, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to create group table\n");
- return(-1);
- }
-
- rc = SQLExecDirect(creatstmt,(SQLCHAR *)create_server_table, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to create server table\n");
- return(-1);
- }
-
- rc = SQLExecDirect(creatstmt,(SQLCHAR *)create_session_table, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to create session table\n");
- return(-1);
- }
-
- rc = SQLTransact(uh->henv, uh->hdbc, SQL_COMMIT);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to commit all create table\n");
- return(-1);
- }
-
- rc = SQLFreeStmt(creatstmt, SQL_DROP);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to free create statement\n");
- return(-1);
- }
-
- return(0);
-}
-
-UserHandle *userDbConnect(uint32 createDb, char *dbName)
-{
- char connStrIn[512]; /* ODBC Connection String */
- char connStrOut[2048];
- SQLRETURN rc;
- UserHandle *uh;
-
- /*--------------------------*/
- /* Build the Connect string */
- /*--------------------------*/
- sprintf(connStrIn,
- "AutoCreate=%d;OverWrite=%d;DSN=%s",
- createDb ? 1 : 0,
- createDb ? 1 : 0,
- dbName);
-
- uh = calloc(1, sizeof(UserHandle));
- if( !uh ) {
- printf("Unable to allocate memory for Handle\n");
- return(0);
- }
-
- /*---------------------------------*/
- /* Allocate the Environment Handle */
- /*---------------------------------*/
- rc = SQLAllocEnv(&uh->henv);
-
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate Environment Handle\n");
- return(0);
- }
-
- /*--------------------------------*/
- /* Allocate the DB Connect Handle */
- /*--------------------------------*/
- rc = SQLAllocConnect(uh->henv, &uh->hdbc);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate a connection handle\n");
- return(0);
- }
-
- /*-------------------------*/
- /* Connect to the Database */
- /*-------------------------*/
- rc = SQLDriverConnect(uh->hdbc, NULL,
- (SQLCHAR *)connStrIn, SQL_NTS,
- (SQLCHAR *)connStrOut, sizeof (connStrOut),
- NULL, SQL_DRIVER_NOPROMPT);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
-handle_error(uh->hdbc, uh->henv, NULL, rc, __FILE__, __LINE__);
- printf("Unable to connect to database server\n");
- return(0);
- }
-
- rc = SQLSetConnectOption(uh->hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to set connection option\n");
- return(0);
- }
-
- rc = SQLAllocStmt(uh->hdbc, &uh->stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to allocate immediate statement\n");
- return(0);
- }
-
- if( createDb )
- dbCreate(uh);
-
- if( localDbPrepare(uh) < 0 )
- return(0);
-
- return(uh);
-}
-
-void userDbDisconnect(UserHandle *uh)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- rc = SQLDisconnect(uh->hdbc);
-
- SQLFreeConnect(uh->hdbc);
- SQLFreeEnv(uh->henv);
- free(uh);
-}
-
-int userDbInsertServer(UserHandle *uh,
- ServerId serverId,
- SubscriberSuffix suffix,
- ServerName name)
-{
- SQLRETURN rc;
- char buf[1000];
-
- if(!uh) return(-1);
-
- sprintf(buf, "insert into server values (%d,'%.*s','%s',0,0,0)",
- serverId,
- SUBSCRIBER_NUMBER_SUFFIX_LENGTH, suffix,
- name);
-
- rc = SQLExecDirect(uh->stmt, (unsigned char *)buf, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to execute insert server\n");
- return(-1);
- }
-
- return( userDbCommit(uh) );
-}
-
-int userDbInsertSubscriber(UserHandle *uh,
- SubscriberNumber number,
- uint32 groupId,
- SubscriberName name)
-{
- SQLRETURN rc;
- char buf[1000];
-
- if(!uh) return(-1);
-
- sprintf(buf, "insert into subscriber values ('%s','%s',%d,0,0,'','')",
- number,
- name,
- groupId);
-
- rc = SQLExecDirect(uh->stmt, (unsigned char*)buf, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to execute insert subscriber\n");
- return(-1);
- }
-
- return( userDbCommit(uh) );
-}
-
-int userDbInsertGroup(UserHandle *uh,
- GroupId groupId,
- GroupName name,
- Permission allowRead,
- Permission allowInsert,
- Permission allowDelete)
-{
- SQLRETURN rc;
- char buf[1000];
-
- if(!uh) return(-1);
-
- sprintf(buf, "insert into usergroup values (%d,'%s',%d,%d,%d)",
- groupId,
- name,
- allowRead,
- allowInsert,
- allowDelete);
-
- rc = SQLExecDirect(uh->stmt, (unsigned char*)buf, SQL_NTS);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to execute insert group\n");
- return(-1);
- }
-
- return( userDbCommit(uh) );
-}
-
-int userDbCommit(UserHandle *uh)
-{
- SQLRETURN rc;
- if(!uh) return(-1);
-
- rc = SQLTransact(uh->henv, uh->hdbc, SQL_COMMIT);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
-handle_error(uh->hdbc, uh->henv, 0, rc, __FILE__, __LINE__);
- printf("Unable to commit Transaction\n");
- return(-1);
- }
-
- return(0);
-}
-
-int userDbRollback(UserHandle *uh)
-{
- SQLRETURN rc;
- if(!uh) return(-1);
-
- rc = SQLTransact(uh->henv, uh->hdbc, SQL_ROLLBACK);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("Unable to rollback Transaction\n");
- return(-1);
- }
-
- return(0);
-}
-
-void userCheckpoint(UserHandle *uh)
-{
- SQLRETURN rc;
- if(!uh) return;
-
- rc = SQLExecDirect(uh->stmt, (SQLCHAR *)"call ttCheckpointFuzzy", SQL_NTS);
- userDbCommit(uh);
-}
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userTransaction.c b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userTransaction.c
deleted file mode 100644
index bdc60912482..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userTransaction.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include <ndb_global.h>
-#include <time.h>
-
-#include "sql.h"
-#include "sqlext.h"
-
-
-#include "userInterface.h"
-#include "userHandle.h"
-
-/***************************************************************
-* L O C A L C O N S T A N T S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L D A T A S T R U C T U R E S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L F U N C T I O N S *
-***************************************************************/
-
-static int readSubscriberSessions(UserHandle *uh,
- SubscriberNumber number,
- char *transactionType);
-
-/***************************************************************
-* L O C A L D A T A *
-***************************************************************/
-
-extern void handle_error(SQLHDBC hdbc,
- SQLHENV henv,
- SQLHSTMT hstmt,
- SQLRETURN rc,
- char *filename,
- int lineno);
-
-/***************************************************************
-* P U B L I C D A T A *
-***************************************************************/
-
-
-/***************************************************************
-****************************************************************
-* L O C A L F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-static int readSubscriberSessions(UserHandle *uh,
- SubscriberNumber number,
- char *transactionType)
-{
- SQLRETURN rc;
-
- /*-----------------------------------------------------*/
- /* SELECT activeSessions,groupId,changedBy,changedTime */
- /* FROM SUBSCRIBER */
- /* WHERE subscriberNumber=x; */
- /*-----------------------------------------------------*/
- strcpy(uh->readSubscriberSession.values.number,number);
-
- rc = SQLExecute(uh->readSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("%s %s\n",
- transactionType,
- "Unable to execute read subscriber session");
- return(-1);
- }
-
- rc = SQLFetch(uh->readSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("%s %s\n",
- transactionType,
- "Unable to fetch read subscriber session");
- return(-1);
- }
-
- return(0);
-}
-
-/***************************************************************
-****************************************************************
-* P U B L I C F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-void userTransaction_T1(UserHandle *uh,
- SubscriberNumber number,
- Location new_location,
- ChangedBy changed_by,
- ChangedTime changed_time)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- /*---------------------------------------------*/
- /* Update the subscriber information */
- /* */
- /* UPDATE SUBSCRIBER */
- /* SET location=x, changedBy=x, changedTime=x */
- /* WHERE subscriberNumber=x; */
- /*---------------------------------------------*/
- strcpy(uh->updateSubscriber.values.number, number);
- uh->updateSubscriber.values.location = new_location;
- strcpy(uh->updateSubscriber.values.changedBy, changed_by);
- strcpy(uh->updateSubscriber.values.changedTime, changed_time);
-
- rc = SQLExecute(uh->updateSubscriber.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T1 Unable to execute update subscriber\n");
- return;
- }
-
- userDbCommit(uh);
-}
-
-void userTransaction_T2(UserHandle *uh,
- SubscriberNumber number,
- Location *new_location,
- ChangedBy changed_by,
- ChangedTime changed_time,
- SubscriberName subscriberName)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- /*------------------------------------------------------*/
- /* Read the information from the subscriber table */
- /* */
- /* SELECT location,subscriberName,changedBy,changedTime */
- /* FROM SUBSCRIBER */
- /* WHERE subscriberNumber=x; */
- /*------------------------------------------------------*/
- strcpy(uh->readSubscriber.values.number,number);
-
- rc = SQLExecute(uh->readSubscriber.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T2 Unable to execute read subscriber\n");
- return;
- }
-
- rc = SQLFetch(uh->readSubscriber.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T2 Unable to fetch read subscriber\n");
- return;
- }
-
- userDbCommit(uh);
-
- strcpy(subscriberName, uh->readSubscriber.values.name);
- *new_location = uh->readSubscriber.values.location;
- strcpy(changed_by, uh->readSubscriber.values.changedBy);
- strcpy(changed_time, uh->readSubscriber.values.changedTime);
-}
-
-void userTransaction_T3(UserHandle *uh,
- SubscriberNumber number,
- ServerId server_id,
- ServerBit server_bit,
- SessionDetails session_details,
- unsigned int *branch_executed)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- *branch_executed = 0;
-
- /*--------------------------------------*/
- /* Read active sessions from subscriber */
- /*--------------------------------------*/
- if( readSubscriberSessions(uh, number, "T3") < 0 )
- return;
-
- /*-----------------------------------------------*/
- /* Read the 'read' Permissions for the userGroup */
- /* */
- /* SELECT allowRead */
- /* FROM USERGROUP */
- /* WHERE groupId=x */
- /*-----------------------------------------------*/
- uh->readGroupAllowRead.values.groupId = uh->readSubscriberSession.values.groupId;
-
- rc = SQLExecute(uh->readGroupAllowRead.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to execute read group allow read\n");
- return;
- }
-
- rc = SQLFetch(uh->readGroupAllowRead.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to fetch read group allow read\n");
- return;
- }
-
- if( uh->readGroupAllowRead.values.allowRead & server_bit &&
- uh->readSubscriberSession.values.activeSessions & server_bit ) {
-
- /*----------------------------------------------------*/
- /* Read the sessionDetails from the userSession table */
- /* */
- /* SELECT sessionData */
- /* FROM userSession */
- /* WHERE subscriberNumber=x, serverId=x */
- /*----------------------------------------------------*/
- strcpy(uh->readSessionDetails.values.number,number);
- uh->readSessionDetails.values.serverId = server_id;
-
- rc = SQLExecute(uh->readSessionDetails.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to execute read session details\n");
- return;
- }
-
- rc = SQLFetch(uh->readSessionDetails.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to fetch read session details\n");
- return;
- }
-
- strcpy(session_details, uh->readSessionDetails.values.details);
-
- /*----------------------------------------*/
- /* Increment noOfRead field in the server */
- /* */
- /* UPDATE server */
- /* SET noOfRead=noOfRead+1 */
- /* WHERE serverId=x,subscriberSuffix=x */
- /*----------------------------------------*/
- uh->updateServerNoOfRead.values.serverId = server_id;
- strcpy(uh->updateServerNoOfRead.values.suffix,
- &number[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH]);
-
- rc = SQLExecute(uh->updateServerNoOfRead.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to execute read no of read\n");
- return;
- }
-
- *branch_executed = 1;
- }
-
- userDbCommit(uh);
-}
-
-void userTransaction_T4(UserHandle *uh,
- SubscriberNumber number,
- ServerId server_id,
- ServerBit server_bit,
- SessionDetails session_details,
- unsigned int do_rollback,
- unsigned int *branch_executed)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- *branch_executed = 0;
-
- /*--------------------------------------*/
- /* Read active sessions from subscriber */
- /*--------------------------------------*/
- if( readSubscriberSessions(uh, number, "T4") < 0 )
- return;
-
- /*-------------------------------------------------*/
- /* Read the 'insert' Permissions for the userGroup */
- /* */
- /* SELECT allowInsert */
- /* FROM USERGROUP */
- /* WHERE groupId=x */
- /*-------------------------------------------------*/
- uh->readGroupAllowInsert.values.groupId = uh->readSubscriberSession.values.groupId;
-
- rc = SQLExecute(uh->readGroupAllowInsert.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T4 Unable to execute read group allow insert\n");
- return;
- }
-
- rc = SQLFetch(uh->readGroupAllowInsert.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T4 Unable to fetch read group allow insert\n");
- return;
- }
-
- if( uh->readGroupAllowInsert.values.allowInsert & server_bit &&
- !(uh->readSubscriberSession.values.activeSessions & server_bit) ) {
-
- /*---------------------------------------------*/
- /* Insert the session to the userSession table */
- /* */
- /* INSERT INTO userSession */
- /* VALUES (x,x,x) */
- /*---------------------------------------------*/
- strcpy(uh->insertSession.values.number, number);
- uh->insertSession.values.serverId = server_id;
- strcpy(uh->insertSession.values.details, session_details);
-
- rc = SQLExecute(uh->insertSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
-handle_error(uh->hdbc, uh->henv, uh->insertSession.stmt, rc, __FILE__, __LINE__);
- printf("T4 Unable to execute insert session \n");
- return;
- }
-
- /*----------------------------------------*/
- /* Update subscriber activeSessions field */
- /* */
- /* UPDATE subscriber */
- /* SET activeSessions=x */
- /* WHERE subscriberNumber=x */
- /*----------------------------------------*/
- strcpy(uh->updateSubscriberSession.values.number, number);
- uh->updateSubscriberSession.values.activeSessions =
- uh->readSubscriberSession.values.activeSessions | server_bit;
-
- rc = SQLExecute(uh->updateSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T4 Unable to execute update session \n");
- return;
- }
-
- /*------------------------------------------*/
- /* Increment noOfInsert field in the server */
- /* */
- /* UPDATE server */
- /* SET noOfInsert=noOfInsert+1 */
- /* WHERE serverId=x,subscriberSuffix=x */
- /*------------------------------------------*/
- uh->updateServerNoOfInsert.values.serverId = server_id;
- strcpy(uh->updateServerNoOfInsert.values.suffix,
- &number[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH]);
-
- rc = SQLExecute(uh->updateServerNoOfInsert.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T4 Unable to execute update no of read\n");
- return;
- }
-
- *branch_executed = 1;
- }
-
- if(do_rollback)
- userDbRollback(uh);
- else
- userDbCommit(uh);
-}
-
-void userTransaction_T5(UserHandle *uh,
- SubscriberNumber number,
- ServerId server_id,
- ServerBit server_bit,
- unsigned int do_rollback,
- unsigned int *branch_executed)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- *branch_executed = 0;
-
- /*--------------------------------------*/
- /* Read active sessions from subscriber */
- /*--------------------------------------*/
- if( readSubscriberSessions(uh, number, "T5") < 0 )
- return;
-
- /*-------------------------------------------------*/
- /* Read the 'delete' Permissions for the userGroup */
- /* */
- /* SELECT allowDelete */
- /* FROM USERGROUP */
- /* WHERE groupId=x */
- /*-------------------------------------------------*/
- uh->readGroupAllowDelete.values.groupId = uh->readSubscriberSession.values.groupId;
-
- rc = SQLExecute(uh->readGroupAllowDelete.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to execute read group allow delete\n");
- return;
- }
-
- rc = SQLFetch(uh->readGroupAllowDelete.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to fetch read group allow delete\n");
- return;
- }
-
- if( uh->readGroupAllowDelete.values.allowDelete & server_bit &&
- uh->readSubscriberSession.values.activeSessions & server_bit ) {
-
- /*-----------------------------------------------*/
- /* Delete the session from the userSession table */
- /* */
- /* DELETE FROM userSession */
- /* WHERE subscriberNumber=x,serverId=x */
- /*-----------------------------------------------*/
- strcpy(uh->deleteSession.values.number,number);
- uh->deleteSession.values.serverId = server_id;
-
- rc = SQLExecute(uh->deleteSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to execute delete session\n");
- return;
- }
-
- /*----------------------------------------*/
- /* Update subscriber activeSessions field */
- /* */
- /* UPDATE subscriber */
- /* SET activeSessions=x */
- /* WHERE subscriberNumber=x */
- /*----------------------------------------*/
- strcpy(uh->updateSubscriberSession.values.number, number);
- uh->updateSubscriberSession.values.activeSessions =
- uh->readSubscriberSession.values.activeSessions & ~server_bit;
-
- rc = SQLExecute(uh->updateSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to execute update subscriber session \n");
- return;
- }
-
- /*------------------------------------------*/
- /* Increment noOfDelete field in the server */
- /* */
- /* UPDATE server */
- /* SET noOfDelete=noOfDelete+1 */
- /* WHERE serverId=x,subscriberSuffix=x */
- /*------------------------------------------*/
- uh->updateServerNoOfDelete.values.serverId = server_id;
- strcpy(uh->updateServerNoOfDelete.values.suffix,
- &number[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH]);
-
- rc = SQLExecute(uh->updateServerNoOfDelete.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to execute update no of delete\n");
- return;
- }
-
- *branch_executed = 1;
- }
-
- if(do_rollback)
- userDbRollback(uh);
- else
- userDbCommit(uh);
-}
-
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userHandle.h b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userHandle.h
deleted file mode 100644
index 9b6ac1ef161..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userHandle.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-#ifndef USERHANDLE_H
-#define USERHANDLE_H
-
-/***************************************************************/
-/* I N C L U D E D F I L E S */
-/***************************************************************/
-
-#include <NdbApi.hpp>
-#include "testDefinitions.h"
-
-/***************************************************************
-* M A C R O S *
-***************************************************************/
-
-/***************************************************************/
-/* C O N S T A N T S */
-/***************************************************************/
-
-/***************************************************************
-* D A T A S T R U C T U R E S *
-***************************************************************/
-
-typedef Ndb userHandle;
-
-/***************************************************************
-* P U B L I C F U N C T I O N S *
-***************************************************************/
-
-/***************************************************************
-* E X T E R N A L D A T A *
-***************************************************************/
-
-
-#endif /* USERHANDLE_H */
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userInterface.cpp b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userInterface.cpp
deleted file mode 100644
index f20316ec52a..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userInterface.cpp
+++ /dev/null
@@ -1,738 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include <ndb_global.h>
-#ifndef NDB_WIN32
-#include <sys/time.h>
-#endif
-
-#include "ndb_error.hpp"
-#include "userHandle.h"
-#include "userInterface.h"
-#include <NdbThread.h>
-#include <NdbTick.h>
-#include <NdbMutex.h>
-#include <NdbSleep.h>
-#include "ndb_schema.hpp"
-#include <NDBT.hpp>
-#include <NdbSchemaCon.hpp>
-
-/***************************************************************
-* L O C A L C O N S T A N T S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L D A T A S T R U C T U R E S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L F U N C T I O N S *
-***************************************************************/
-
-extern int localDbPrepare(UserHandle *uh);
-
-static int dbCreate(UserHandle *uh);
-
-/***************************************************************
-* L O C A L D A T A *
-***************************************************************/
-
-/***************************************************************
-* P U B L I C D A T A *
-***************************************************************/
-
-
-/***************************************************************
-****************************************************************
-* L O C A L F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-/***************************************************************
-****************************************************************
-* P U B L I C F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-/*-----------------------------------*/
-/* Time related Functions */
-/* */
-/* Returns a double value in seconds */
-/*-----------------------------------*/
-double userGetTimeSync(void)
-{
- static int initialized = 0;
- static NDB_TICKS initSecs = 0;
- static Uint32 initMicros = 0;
- double timeValue = 0;
-
- if ( !initialized ) {
- initialized = 1;
- NdbTick_CurrentMicrosecond(&initSecs, &initMicros);
- timeValue = 0.0;
- } else {
- NDB_TICKS secs = 0;
- Uint32 micros = 0;
-
- NdbTick_CurrentMicrosecond(&secs, &micros);
-
- double s = (double)secs - (double)initSecs;
- double us = (double)secs - (double)initMicros;
-
- timeValue = s + (us / 1000000.0);
- }
-
- return timeValue;
-}
-
-// 0 - OK
-// 1 - Retry transaction
-// 2 - Permanent
-int
-userDbCommit(UserHandle *uh){
- if(uh->pCurrTrans != 0){
- int check = uh->pCurrTrans->execute( Commit );
- NdbError err = uh->pCurrTrans->getNdbError();
- uh->pNDB->closeTransaction(uh->pCurrTrans);
- uh->pCurrTrans = 0;
-
- if(err.status != NdbError::Success)
- ndbout << err << endl;
-
- if(err.status == NdbError::TemporaryError &&
- err.classification == NdbError::OverloadError){
- NdbSleep_SecSleep(3);
- }
-
- return err.status;
- }
- return 2;
-}
-
-/**
- * TRUE - Normal table
- * FALSE - Table w.o. checkpoing and logging
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern int useTableLogging;
-extern int useIndexTables;
-#ifdef __cplusplus
-}
-#endif
-
-
-int
-create_table_server(Ndb * pNdb){
- int check;
- NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
- if( MySchemaTransaction == NULL )
- error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
-
- NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
- if( MySchemaOp == NULL )
- error_handler("getNdbSchemaOp", MySchemaTransaction->getNdbError(), 0);
-
- // Create table
- check = MySchemaOp->createTable( SERVER_TABLE,
- 8, // Table size
- TupleKey, // Key Type
- 1 // Nr of Pages
- ,DistributionGroup,
- 6,
- 78,
- 80,
- 1,
- useTableLogging
- );
- if( check == -1 )
- error_handler("createTable", MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute
- ( SERVER_SUBSCRIBER_SUFFIX,
- TupleKey,
- sizeof(char) << 3,
- SUBSCRIBER_NUMBER_SUFFIX_LENGTH,
- String,
- MMBased,
- NotNullAttribute,
- NormalStorageAttribute,
- 0,
- 1,
- 16);
- if( check == -1 )
- error_handler("createAttribute (subscriber suffix)",
- MySchemaTransaction->getNdbError(), 0);
-
- // Create first column, primary key
- check = MySchemaOp->createAttribute( SERVER_ID,
- TupleKey,
- sizeof(ServerId) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (serverid)",
- MySchemaTransaction->getNdbError(), 0);
-
-
- check = MySchemaOp->createAttribute( SERVER_NAME,
- NoKey,
- sizeof(char) << 3,
- SERVER_NAME_LENGTH,
- String,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (server name)",
- MySchemaTransaction->getNdbError(), 0);
-
-
- check = MySchemaOp->createAttribute( SERVER_READS,
- NoKey,
- sizeof(Counter) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (server reads)",
- MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute( SERVER_INSERTS,
- NoKey,
- sizeof(Counter) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (server inserts)",
- MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute( SERVER_DELETES,
- NoKey,
- sizeof(Counter) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (server deletes)",
- MySchemaTransaction->getNdbError(), 0);
-
- if( MySchemaTransaction->execute() == -1 ) {
- error_handler("schemaTransaction->execute()",
- MySchemaTransaction->getNdbError(), 0);
- }
- NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
- return 0;
-}
-
-int
-create_table_group(Ndb * pNdb){
- int check;
-
- NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
- if( MySchemaTransaction == NULL )
- error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
-
- NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
- if( MySchemaOp == NULL )
- error_handler("getNdbSchemaOp", MySchemaTransaction->getNdbError(), 0);
-
- // Create table
- check = MySchemaOp->createTable( GROUP_TABLE,
- 8, // Table size
- TupleKey, // Key Type
- 1 // Nr of Pages
- ,All,
- 6,
- 78,
- 80,
- 1,
- useTableLogging
- );
-
- if( check == -1 )
- error_handler("createTable", MySchemaTransaction->getNdbError(), 0);
-
- // Create first column, primary key
- check = MySchemaOp->createAttribute( GROUP_ID,
- TupleKey,
- sizeof(GroupId) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (group id)",
- MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute( GROUP_NAME,
- NoKey,
- sizeof(char) << 3,
- GROUP_NAME_LENGTH,
- String,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (group name)",
- MySchemaTransaction->getNdbError(), 0);
-
-
- check = MySchemaOp->createAttribute( GROUP_ALLOW_READ,
- NoKey,
- sizeof(Permission) << 3,
- 1,
- String,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (group read)",
- MySchemaTransaction->getNdbError(), 0);
-
-
- check = MySchemaOp->createAttribute( GROUP_ALLOW_INSERT,
- NoKey,
- sizeof(Permission) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (group insert)",
- MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute( GROUP_ALLOW_DELETE,
- NoKey,
- sizeof(Permission) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (group delete)",
- MySchemaTransaction->getNdbError(), 0);
-
- if( MySchemaTransaction->execute() == -1 ) {
- error_handler("schemaTransaction->execute()",
- MySchemaTransaction->getNdbError(), 0);
- }
- NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
- return 0;
-}
-
-int
-create_table_subscriber(Ndb * pNdb){
- int check;
- NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
- if( MySchemaTransaction == NULL )
- error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
-
- NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
- if( MySchemaOp == NULL )
- error_handler("getNdbSchemaOp", MySchemaTransaction->getNdbError(), 0);
-
- // Create table
- check = MySchemaOp->createTable( SUBSCRIBER_TABLE,
- 8, // Table size
- TupleKey, // Key Type
- 1 // Nr of Pages
- ,DistributionGroup,
- 6,
- 78,
- 80,
- 1,
- useTableLogging
- );
- if( check == -1 )
- error_handler("createTable", MySchemaTransaction->getNdbError(), 0);
-
- // Create first column, primary key
- check = MySchemaOp->createAttribute
- ( SUBSCRIBER_NUMBER,
- TupleKey,
- sizeof(char) << 3,
- SUBSCRIBER_NUMBER_LENGTH,
- String,
- MMBased,
- NotNullAttribute,
- (useIndexTables ? IndexStorageAttribute : NormalStorageAttribute),
- 0,
- 1,
- 16);
- if( check == -1 )
- error_handler("createAttribute (subscriber number)",
- MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute( SUBSCRIBER_NAME,
- NoKey,
- sizeof(char) << 3,
- SUBSCRIBER_NAME_LENGTH,
- String,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (subscriber name)",
- MySchemaTransaction->getNdbError(), 0);
-
-
- check = MySchemaOp->createAttribute( SUBSCRIBER_GROUP,
- NoKey,
- sizeof(GroupId) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (subscriber_group)",
- MySchemaTransaction->getNdbError(), 0);
-
-
- check = MySchemaOp->createAttribute( SUBSCRIBER_LOCATION,
- NoKey,
- sizeof(Location) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (server reads)",
- MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute( SUBSCRIBER_SESSIONS,
- NoKey,
- sizeof(ActiveSessions) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (subscriber_sessions)",
- MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute( SUBSCRIBER_CHANGED_BY,
- NoKey,
- sizeof(char) << 3,
- CHANGED_BY_LENGTH,
- String,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (subscriber_changed_by)",
- MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute( SUBSCRIBER_CHANGED_TIME,
- NoKey,
- sizeof(char) << 3,
- CHANGED_TIME_LENGTH,
- String,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (subscriber_changed_time)",
- MySchemaTransaction->getNdbError(), 0);
-
- if( MySchemaTransaction->execute() == -1 ) {
- error_handler("schemaTransaction->execute()",
- MySchemaTransaction->getNdbError(), 0);
- }
- NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
- return 0;
-}
-
-int
-create_table_session(Ndb * pNdb){
- int check;
- NdbSchemaCon * MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pNdb);
- if( MySchemaTransaction == NULL )
- error_handler("startSchemaTransaction", pNdb->getNdbError(), 0);
-
- NdbSchemaOp * MySchemaOp = MySchemaTransaction->getNdbSchemaOp();
- if( MySchemaOp == NULL )
- error_handler("getNdbSchemaOp",
- MySchemaTransaction->getNdbError(), 0);
-
- // Create table
- check = MySchemaOp->createTable( SESSION_TABLE,
- 8, // Table size
- TupleKey, // Key Type
- 1 // Nr of Pages
- ,DistributionGroup,
- 6,
- 78,
- 80,
- 1,
- useTableLogging
- );
- if( check == -1 )
- error_handler("createTable", MySchemaTransaction->getNdbError(), 0);
-
- check = MySchemaOp->createAttribute( SESSION_SUBSCRIBER,
- TupleKey,
- sizeof(char) << 3,
- SUBSCRIBER_NUMBER_LENGTH,
- String,
- MMBased,
- NotNullAttribute,
- NormalStorageAttribute,
- 0,
- 1,
- 16);
- if( check == -1 )
- error_handler("createAttribute (session_subscriber)",
- MySchemaTransaction->getNdbError(), 0);
-
- // Create first column, primary key
- check = MySchemaOp->createAttribute( SESSION_SERVER,
- TupleKey,
- sizeof(ServerId) << 3,
- 1,
- UnSigned,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (session_server)",
- MySchemaTransaction->getNdbError(), 0);
-
-
- check = MySchemaOp->createAttribute( SESSION_DATA,
- NoKey,
- sizeof(char) << 3,
- SESSION_DETAILS_LENGTH,
- String,
- MMBased,
- NotNullAttribute );
- if( check == -1 )
- error_handler("createAttribute (session_data)",
- MySchemaTransaction->getNdbError(), 0);
-
- if( MySchemaTransaction->execute() == -1 ) {
- error_handler("schemaTransaction->execute()",
- MySchemaTransaction->getNdbError(), 0);
- }
- NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
- return 0;
-}
-
-void
-create_table(const char * name, int (* function)(Ndb * pNdb), Ndb* pNdb){
- printf("creating table %s...", name);
- if(pNdb->getDictionary()->getTable(name) != 0){
- printf(" it already exists\n");
- return;
- } else {
- printf("\n");
- }
- function(pNdb);
- printf("creating table %s... done\n", name);
-}
-
-static int dbCreate(Ndb * pNdb)
-{
- create_table(SUBSCRIBER_TABLE, create_table_subscriber, pNdb);
- create_table(GROUP_TABLE , create_table_group, pNdb);
- create_table(SESSION_TABLE , create_table_session, pNdb);
- create_table(SERVER_TABLE , create_table_server, pNdb);
- return 0;
-}
-
-#ifndef NDB_WIN32
-#include <unistd.h>
-#endif
-
-static NdbMutex* startupMutex = NdbMutex_Create();
-
-UserHandle*
-userDbConnect(uint32 createDb, char *dbName)
-{
- NdbMutex_Lock(startupMutex);
-
- Ndb * pNdb = new Ndb("");
-
- //printf("Initializing...\n");
- pNdb->init();
-
- //printf("Waiting...");
- while(pNdb->waitUntilReady() != 0){
- //printf("...");
- }
- // printf("done\n");
-
- if( createDb )
- dbCreate(pNdb);
-
-
- UserHandle * uh = new UserHandle;
- uh->pNDB = pNdb;
- uh->pCurrTrans = 0;
-
- NdbMutex_Unlock(startupMutex);
-
- return uh;
-}
-
-void userDbDisconnect(UserHandle *uh)
-{
- delete uh;
-}
-
-int userDbInsertServer(UserHandle *uh,
- ServerId serverId,
- SubscriberSuffix suffix,
- ServerName name)
-{
- int check;
-
- uint32 noOfRead = 0;
- uint32 noOfInsert = 0;
- uint32 noOfDelete = 0;
-
- NdbConnection * MyTransaction = 0;
- if(uh->pCurrTrans != 0){
- MyTransaction = uh->pCurrTrans;
- } else {
- uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction();
- }
- if (MyTransaction == NULL)
- error_handler("startTranscation", uh->pNDB->getNdbError(), 0);
-
- NdbOperation *MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE);
- CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
-
- check = MyOperation->insertTuple();
- CHECK_MINUS_ONE(check, "insert tuple", MyTransaction);
-
- check = MyOperation->equal(SERVER_ID, (char*)&serverId);
- CHECK_MINUS_ONE(check, "setValue id", MyTransaction);
-
- check = MyOperation->setValue(SERVER_SUBSCRIBER_SUFFIX, suffix);
- CHECK_MINUS_ONE(check, "setValue suffix", MyTransaction);
-
- check = MyOperation->setValue(SERVER_NAME, name);
- CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
-
- check = MyOperation->setValue(SERVER_READS, (char*)&noOfRead);
- CHECK_MINUS_ONE(check, "setValue reads", MyTransaction);
-
- check = MyOperation->setValue(SERVER_INSERTS, (char*)&noOfInsert);
- CHECK_MINUS_ONE(check, "setValue inserts", MyTransaction);
-
- check = MyOperation->setValue(SERVER_DELETES, (char*)&noOfDelete);
- CHECK_MINUS_ONE(check, "setValue deletes", MyTransaction);
-
- return 0;
-}
-
-int userDbInsertSubscriber(UserHandle *uh,
- SubscriberNumber number,
- uint32 groupId,
- SubscriberName name)
-{
- int check;
- uint32 activeSessions = 0;
- Location l = 0;
- ChangedBy changedBy; snprintf(changedBy, sizeof(changedBy), "ChangedBy");
- ChangedTime changedTime; snprintf(changedTime, sizeof(changedTime), "ChangedTime");
-
- NdbConnection * MyTransaction = 0;
- if(uh->pCurrTrans != 0){
- MyTransaction = uh->pCurrTrans;
- } else {
- uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction();
- }
- if (MyTransaction == NULL)
- error_handler("startTranscation", uh->pNDB->getNdbError(), 0);
-
- NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
- CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
-
- check = MyOperation->insertTuple();
- CHECK_MINUS_ONE(check, "insertTuple", MyTransaction);
-
- check = MyOperation->equal(SUBSCRIBER_NUMBER, number);
- CHECK_MINUS_ONE(check, "equal", MyTransaction);
-
- check = MyOperation->setValue(SUBSCRIBER_NAME, name);
- CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
-
- check = MyOperation->setValue(SUBSCRIBER_GROUP, (char*)&groupId);
- CHECK_MINUS_ONE(check, "setValue group", MyTransaction);
-
- check = MyOperation->setValue(SUBSCRIBER_LOCATION, (char*)&l);
- CHECK_MINUS_ONE(check, "setValue location", MyTransaction);
-
- check = MyOperation->setValue(SUBSCRIBER_SESSIONS, (char*)&activeSessions);
- CHECK_MINUS_ONE(check, "setValue sessions", MyTransaction);
-
- check = MyOperation->setValue(SUBSCRIBER_CHANGED_BY, changedBy);
- CHECK_MINUS_ONE(check, "setValue changedBy", MyTransaction);
-
- check = MyOperation->setValue(SUBSCRIBER_CHANGED_TIME, changedTime);
- CHECK_MINUS_ONE(check, "setValue changedTime", MyTransaction);
-
- return 0;
-}
-
-int userDbInsertGroup(UserHandle *uh,
- GroupId groupId,
- GroupName name,
- Permission allowRead,
- Permission allowInsert,
- Permission allowDelete)
-{
- int check;
-
- NdbConnection * MyTransaction = 0;
- if(uh->pCurrTrans != 0){
- MyTransaction = uh->pCurrTrans;
- } else {
- uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction();
- }
- if (MyTransaction == NULL)
- error_handler("startTranscation", uh->pNDB->getNdbError(), 0);
-
- NdbOperation *MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE);
- CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
-
- check = MyOperation->insertTuple();
- CHECK_MINUS_ONE(check, "insertTuple", MyTransaction);
-
- check = MyOperation->equal(GROUP_ID, (char*)&groupId);
- CHECK_MINUS_ONE(check, "equal", MyTransaction);
-
- check = MyOperation->setValue(GROUP_NAME, name);
- CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
-
- check = MyOperation->setValue(GROUP_ALLOW_READ, (char*)&allowRead);
- CHECK_MINUS_ONE(check, "setValue allowRead", MyTransaction);
-
- check = MyOperation->setValue(GROUP_ALLOW_INSERT, (char*)&allowInsert);
- CHECK_MINUS_ONE(check, "setValue allowInsert", MyTransaction);
-
- check = MyOperation->setValue(GROUP_ALLOW_DELETE, (char*)&allowDelete);
- CHECK_MINUS_ONE(check, "setValue allowDelete", MyTransaction);
-
- return 0;
-}
-
diff --git a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userTransaction.c b/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userTransaction.c
deleted file mode 100644
index bdc60912482..00000000000
--- a/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userTransaction.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/* 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; version 2 of the License.
-
- 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 */
-
-/***************************************************************
-* I N C L U D E D F I L E S *
-***************************************************************/
-
-#include <ndb_global.h>
-#include <time.h>
-
-#include "sql.h"
-#include "sqlext.h"
-
-
-#include "userInterface.h"
-#include "userHandle.h"
-
-/***************************************************************
-* L O C A L C O N S T A N T S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L D A T A S T R U C T U R E S *
-***************************************************************/
-
-/***************************************************************
-* L O C A L F U N C T I O N S *
-***************************************************************/
-
-static int readSubscriberSessions(UserHandle *uh,
- SubscriberNumber number,
- char *transactionType);
-
-/***************************************************************
-* L O C A L D A T A *
-***************************************************************/
-
-extern void handle_error(SQLHDBC hdbc,
- SQLHENV henv,
- SQLHSTMT hstmt,
- SQLRETURN rc,
- char *filename,
- int lineno);
-
-/***************************************************************
-* P U B L I C D A T A *
-***************************************************************/
-
-
-/***************************************************************
-****************************************************************
-* L O C A L F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-static int readSubscriberSessions(UserHandle *uh,
- SubscriberNumber number,
- char *transactionType)
-{
- SQLRETURN rc;
-
- /*-----------------------------------------------------*/
- /* SELECT activeSessions,groupId,changedBy,changedTime */
- /* FROM SUBSCRIBER */
- /* WHERE subscriberNumber=x; */
- /*-----------------------------------------------------*/
- strcpy(uh->readSubscriberSession.values.number,number);
-
- rc = SQLExecute(uh->readSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("%s %s\n",
- transactionType,
- "Unable to execute read subscriber session");
- return(-1);
- }
-
- rc = SQLFetch(uh->readSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("%s %s\n",
- transactionType,
- "Unable to fetch read subscriber session");
- return(-1);
- }
-
- return(0);
-}
-
-/***************************************************************
-****************************************************************
-* P U B L I C F U N C T I O N S C O D E S E C T I O N *
-****************************************************************
-***************************************************************/
-
-void userTransaction_T1(UserHandle *uh,
- SubscriberNumber number,
- Location new_location,
- ChangedBy changed_by,
- ChangedTime changed_time)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- /*---------------------------------------------*/
- /* Update the subscriber information */
- /* */
- /* UPDATE SUBSCRIBER */
- /* SET location=x, changedBy=x, changedTime=x */
- /* WHERE subscriberNumber=x; */
- /*---------------------------------------------*/
- strcpy(uh->updateSubscriber.values.number, number);
- uh->updateSubscriber.values.location = new_location;
- strcpy(uh->updateSubscriber.values.changedBy, changed_by);
- strcpy(uh->updateSubscriber.values.changedTime, changed_time);
-
- rc = SQLExecute(uh->updateSubscriber.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T1 Unable to execute update subscriber\n");
- return;
- }
-
- userDbCommit(uh);
-}
-
-void userTransaction_T2(UserHandle *uh,
- SubscriberNumber number,
- Location *new_location,
- ChangedBy changed_by,
- ChangedTime changed_time,
- SubscriberName subscriberName)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- /*------------------------------------------------------*/
- /* Read the information from the subscriber table */
- /* */
- /* SELECT location,subscriberName,changedBy,changedTime */
- /* FROM SUBSCRIBER */
- /* WHERE subscriberNumber=x; */
- /*------------------------------------------------------*/
- strcpy(uh->readSubscriber.values.number,number);
-
- rc = SQLExecute(uh->readSubscriber.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T2 Unable to execute read subscriber\n");
- return;
- }
-
- rc = SQLFetch(uh->readSubscriber.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T2 Unable to fetch read subscriber\n");
- return;
- }
-
- userDbCommit(uh);
-
- strcpy(subscriberName, uh->readSubscriber.values.name);
- *new_location = uh->readSubscriber.values.location;
- strcpy(changed_by, uh->readSubscriber.values.changedBy);
- strcpy(changed_time, uh->readSubscriber.values.changedTime);
-}
-
-void userTransaction_T3(UserHandle *uh,
- SubscriberNumber number,
- ServerId server_id,
- ServerBit server_bit,
- SessionDetails session_details,
- unsigned int *branch_executed)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- *branch_executed = 0;
-
- /*--------------------------------------*/
- /* Read active sessions from subscriber */
- /*--------------------------------------*/
- if( readSubscriberSessions(uh, number, "T3") < 0 )
- return;
-
- /*-----------------------------------------------*/
- /* Read the 'read' Permissions for the userGroup */
- /* */
- /* SELECT allowRead */
- /* FROM USERGROUP */
- /* WHERE groupId=x */
- /*-----------------------------------------------*/
- uh->readGroupAllowRead.values.groupId = uh->readSubscriberSession.values.groupId;
-
- rc = SQLExecute(uh->readGroupAllowRead.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to execute read group allow read\n");
- return;
- }
-
- rc = SQLFetch(uh->readGroupAllowRead.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to fetch read group allow read\n");
- return;
- }
-
- if( uh->readGroupAllowRead.values.allowRead & server_bit &&
- uh->readSubscriberSession.values.activeSessions & server_bit ) {
-
- /*----------------------------------------------------*/
- /* Read the sessionDetails from the userSession table */
- /* */
- /* SELECT sessionData */
- /* FROM userSession */
- /* WHERE subscriberNumber=x, serverId=x */
- /*----------------------------------------------------*/
- strcpy(uh->readSessionDetails.values.number,number);
- uh->readSessionDetails.values.serverId = server_id;
-
- rc = SQLExecute(uh->readSessionDetails.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to execute read session details\n");
- return;
- }
-
- rc = SQLFetch(uh->readSessionDetails.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to fetch read session details\n");
- return;
- }
-
- strcpy(session_details, uh->readSessionDetails.values.details);
-
- /*----------------------------------------*/
- /* Increment noOfRead field in the server */
- /* */
- /* UPDATE server */
- /* SET noOfRead=noOfRead+1 */
- /* WHERE serverId=x,subscriberSuffix=x */
- /*----------------------------------------*/
- uh->updateServerNoOfRead.values.serverId = server_id;
- strcpy(uh->updateServerNoOfRead.values.suffix,
- &number[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH]);
-
- rc = SQLExecute(uh->updateServerNoOfRead.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T3 Unable to execute read no of read\n");
- return;
- }
-
- *branch_executed = 1;
- }
-
- userDbCommit(uh);
-}
-
-void userTransaction_T4(UserHandle *uh,
- SubscriberNumber number,
- ServerId server_id,
- ServerBit server_bit,
- SessionDetails session_details,
- unsigned int do_rollback,
- unsigned int *branch_executed)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- *branch_executed = 0;
-
- /*--------------------------------------*/
- /* Read active sessions from subscriber */
- /*--------------------------------------*/
- if( readSubscriberSessions(uh, number, "T4") < 0 )
- return;
-
- /*-------------------------------------------------*/
- /* Read the 'insert' Permissions for the userGroup */
- /* */
- /* SELECT allowInsert */
- /* FROM USERGROUP */
- /* WHERE groupId=x */
- /*-------------------------------------------------*/
- uh->readGroupAllowInsert.values.groupId = uh->readSubscriberSession.values.groupId;
-
- rc = SQLExecute(uh->readGroupAllowInsert.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T4 Unable to execute read group allow insert\n");
- return;
- }
-
- rc = SQLFetch(uh->readGroupAllowInsert.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T4 Unable to fetch read group allow insert\n");
- return;
- }
-
- if( uh->readGroupAllowInsert.values.allowInsert & server_bit &&
- !(uh->readSubscriberSession.values.activeSessions & server_bit) ) {
-
- /*---------------------------------------------*/
- /* Insert the session to the userSession table */
- /* */
- /* INSERT INTO userSession */
- /* VALUES (x,x,x) */
- /*---------------------------------------------*/
- strcpy(uh->insertSession.values.number, number);
- uh->insertSession.values.serverId = server_id;
- strcpy(uh->insertSession.values.details, session_details);
-
- rc = SQLExecute(uh->insertSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
-handle_error(uh->hdbc, uh->henv, uh->insertSession.stmt, rc, __FILE__, __LINE__);
- printf("T4 Unable to execute insert session \n");
- return;
- }
-
- /*----------------------------------------*/
- /* Update subscriber activeSessions field */
- /* */
- /* UPDATE subscriber */
- /* SET activeSessions=x */
- /* WHERE subscriberNumber=x */
- /*----------------------------------------*/
- strcpy(uh->updateSubscriberSession.values.number, number);
- uh->updateSubscriberSession.values.activeSessions =
- uh->readSubscriberSession.values.activeSessions | server_bit;
-
- rc = SQLExecute(uh->updateSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T4 Unable to execute update session \n");
- return;
- }
-
- /*------------------------------------------*/
- /* Increment noOfInsert field in the server */
- /* */
- /* UPDATE server */
- /* SET noOfInsert=noOfInsert+1 */
- /* WHERE serverId=x,subscriberSuffix=x */
- /*------------------------------------------*/
- uh->updateServerNoOfInsert.values.serverId = server_id;
- strcpy(uh->updateServerNoOfInsert.values.suffix,
- &number[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH]);
-
- rc = SQLExecute(uh->updateServerNoOfInsert.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T4 Unable to execute update no of read\n");
- return;
- }
-
- *branch_executed = 1;
- }
-
- if(do_rollback)
- userDbRollback(uh);
- else
- userDbCommit(uh);
-}
-
-void userTransaction_T5(UserHandle *uh,
- SubscriberNumber number,
- ServerId server_id,
- ServerBit server_bit,
- unsigned int do_rollback,
- unsigned int *branch_executed)
-{
- SQLRETURN rc;
-
- if(!uh) return;
-
- *branch_executed = 0;
-
- /*--------------------------------------*/
- /* Read active sessions from subscriber */
- /*--------------------------------------*/
- if( readSubscriberSessions(uh, number, "T5") < 0 )
- return;
-
- /*-------------------------------------------------*/
- /* Read the 'delete' Permissions for the userGroup */
- /* */
- /* SELECT allowDelete */
- /* FROM USERGROUP */
- /* WHERE groupId=x */
- /*-------------------------------------------------*/
- uh->readGroupAllowDelete.values.groupId = uh->readSubscriberSession.values.groupId;
-
- rc = SQLExecute(uh->readGroupAllowDelete.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to execute read group allow delete\n");
- return;
- }
-
- rc = SQLFetch(uh->readGroupAllowDelete.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to fetch read group allow delete\n");
- return;
- }
-
- if( uh->readGroupAllowDelete.values.allowDelete & server_bit &&
- uh->readSubscriberSession.values.activeSessions & server_bit ) {
-
- /*-----------------------------------------------*/
- /* Delete the session from the userSession table */
- /* */
- /* DELETE FROM userSession */
- /* WHERE subscriberNumber=x,serverId=x */
- /*-----------------------------------------------*/
- strcpy(uh->deleteSession.values.number,number);
- uh->deleteSession.values.serverId = server_id;
-
- rc = SQLExecute(uh->deleteSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to execute delete session\n");
- return;
- }
-
- /*----------------------------------------*/
- /* Update subscriber activeSessions field */
- /* */
- /* UPDATE subscriber */
- /* SET activeSessions=x */
- /* WHERE subscriberNumber=x */
- /*----------------------------------------*/
- strcpy(uh->updateSubscriberSession.values.number, number);
- uh->updateSubscriberSession.values.activeSessions =
- uh->readSubscriberSession.values.activeSessions & ~server_bit;
-
- rc = SQLExecute(uh->updateSubscriberSession.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to execute update subscriber session \n");
- return;
- }
-
- /*------------------------------------------*/
- /* Increment noOfDelete field in the server */
- /* */
- /* UPDATE server */
- /* SET noOfDelete=noOfDelete+1 */
- /* WHERE serverId=x,subscriberSuffix=x */
- /*------------------------------------------*/
- uh->updateServerNoOfDelete.values.serverId = server_id;
- strcpy(uh->updateServerNoOfDelete.values.suffix,
- &number[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH]);
-
- rc = SQLExecute(uh->updateServerNoOfDelete.stmt);
- if( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- printf("T5 Unable to execute update no of delete\n");
- return;
- }
-
- *branch_executed = 1;
- }
-
- if(do_rollback)
- userDbRollback(uh);
- else
- userDbCommit(uh);
-}
-
-