diff options
Diffstat (limited to 'storage/ndb/test/ndbapi/old_dirs')
101 files changed, 7185 insertions, 0 deletions
diff --git a/storage/ndb/test/ndbapi/old_dirs/acid/Makefile b/storage/ndb/test/ndbapi/old_dirs/acid/Makefile new file mode 100644 index 00000000000..33dc49fcdea --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/acid/Makefile @@ -0,0 +1,10 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := acid + +# Source files of non-templated classes (.C files) +SOURCES = acid.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/acid2/Makefile b/storage/ndb/test/ndbapi/old_dirs/acid2/Makefile new file mode 100644 index 00000000000..69c9d409b9e --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/acid2/Makefile @@ -0,0 +1,10 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := acid2 + +# Source files of non-templated classes (.C files) +SOURCES = acid2.cpp TraceNdbApi.cpp VerifyNdbApi.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/acid2/TraceNdbApi.hpp b/storage/ndb/test/ndbapi/old_dirs/acid2/TraceNdbApi.hpp new file mode 100644 index 00000000000..2bd4eab6b70 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/acid2/TraceNdbApi.hpp @@ -0,0 +1,132 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +#ifndef TraceNdbApi_hpp +#define TraceNdbApi_hpp + + +class CTraceNdbSchemaOp : public NdbSchemaOp +{ +public: + int createTable(const char* aTableName); + int createAttribute(const char* aAttrName, KeyType aTupleyKey); +}; + + + +class CTraceNdbSchemaCon : public NdbSchemaCon +{ +public: + CTraceNdbSchemaOp* getNdbSchemaOp(); + int execute(); +}; + + + +class CTraceNdbRecAttr : public NdbRecAttr +{ +public: + Uint32 u_32_value(); +}; + + +class CTraceNdbOperation : public NdbOperation +{ +public: + int insertTuple(); + int updateTuple(); + int interpretedUpdateTuple(); + int readTuple(); + int readTupleExclusive(); + int deleteTuple(); + int equal(const char* anAttrName, Uint32 aValue); + int setValue(const char* anAttrName, Uint32 aValue); + int incValue(const char* anAttrName, Uint32 aValue); + CTraceNdbRecAttr* getValue(const char* anAttrName); + +}; + + +class CTraceNdbIndexOperation : public NdbIndexOperation +{ +public: + int insertTuple(); + int updateTuple(); + int interpretedUpdateTuple(); + int readTuple(); + int readTupleExclusive(); + int deleteTuple(); + int equal(const char* anAttrName, Uint32 aValue); + int setValue(const char* anAttrName, Uint32 aValue); + int incValue(const char* anAttrName, Uint32 aValue); + CTraceNdbRecAttr* getValue(const char* anAttrName); +}; + + + +class CTraceNdbConnection : public NdbConnection +{ +public: + CTraceNdbOperation* getNdbOperation(const char* aTableName); + CTraceNdbIndexOperation* getNdbIndexOperation(const char* anIndexName, const char* aTableName); + + int execute(ExecType aTypeOfExec); + + int execute_ok(ExecType aTypeOfExec) + { + return execute(aTypeOfExec); + }; + + const NdbError & getNdbError(void) const; +}; + + + +class CTraceNdbDictionary : public NdbDictionary +{ +public: + class CTraceTable : public Table + { + }; + + class CTraceIndex : public Index + { + }; + + class CTraceColumn : public Column + { + }; + + int createTable(const CTraceTable &); + int createIndex(const CTraceIndex &); +}; + + + +class CTraceNdb : public Ndb +{ +public: + CTraceNdb(const char* aDataBase); + CTraceNdbSchemaCon* startSchemaTransaction(); + void closeSchemaTransaction(CTraceNdbSchemaCon* aSchemaCon); + CTraceNdbConnection* startTransaction(); + void closeTransaction(CTraceNdbConnection* aConnection); +}; + + + +#endif // TraceNdbApi_hpp diff --git a/storage/ndb/test/ndbapi/old_dirs/acid2/VerifyNdbApi.hpp b/storage/ndb/test/ndbapi/old_dirs/acid2/VerifyNdbApi.hpp new file mode 100644 index 00000000000..4a5b8cc8111 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/acid2/VerifyNdbApi.hpp @@ -0,0 +1,466 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + + +#ifndef VerifyNdbApi_hpp +#define VerifyNdbApi_hpp + + +class CVerifyNdbSchemaOp : public NdbSchemaOp +{ +public: + int createTable(const char* aTableName) + { + int i = NdbSchemaOp::createTable(aTableName); + VerifyInt(i, "createTable"); + return i; + }; + + int createAttribute(const char* aAttrName, KeyType aTupleyKey) + { + int i = NdbSchemaOp::createAttribute(aAttrName, aTupleyKey); + VerifyInt(i, "createAttribute"); + return i; + }; + +private: + void VerifyInt(const int i, const char* szMethod) + { + if(i) + { + VerifyIntError(i, szMethod); + } + } + + void VerifyIntError(const int i, const char* szMethod); +}; + + + +class CVerifyNdbSchemaCon : public NdbSchemaCon +{ +public: + CVerifyNdbSchemaOp* getNdbSchemaOp() + { + NdbSchemaOp* p = NdbSchemaCon::getNdbSchemaOp(); + VerifyPtr(p, "getNdbSchemaOp"); + return (CVerifyNdbSchemaOp*)p; + }; + + int execute() + { + int i = NdbSchemaCon::execute(); + VerifyInt(i, "execute"); + return i; + }; + +private: + void VerifyInt(const int i, const char* szMethod) + { + if(i) + { + VerifyIntError(i, szMethod); + } + } + + void VerifyPtr(void* p, const char* szMethod) + { + if(!p) + { + VerifyPtrError(p, szMethod); + } + } + + void VerifyIntError(const int i, const char* szMethod); + void VerifyPtrError(void* p, const char* szMethod); +}; + + + +class CVerifyNdbRecAttr : public NdbRecAttr +{ +public: + Uint32 u_32_value() + { + Uint32 n = NdbRecAttr::u_32_value(); + VerifyValue("u_32_value"); + return n; + }; + +private: + void VerifyValue(const char* szMethod) + { + int iNull = NdbRecAttr::isNULL(); + if(iNull) + { + VerifyValueError(iNull, szMethod); + } + }; + + void VerifyValueError(const int iNull, const char* szMethod); +}; + + +class CVerifyNdbOperation : public NdbOperation +{ +public: + int insertTuple() + { + int i = NdbOperation::insertTuple(); + VerifyInt(i, "insertTuple"); + return i; + }; + + int updateTuple() + { + int i = NdbOperation::updateTuple(); + VerifyInt(i, "updateTuple"); + return i; + }; + + int interpretedUpdateTuple() + { + int i = NdbOperation::interpretedUpdateTuple(); + VerifyInt(i, "interpretedUpdateTuple"); + return i; + } + + int readTuple() + { + int i = NdbOperation::readTuple(); + VerifyInt(i, "readTuple"); + return i; + } + + int readTupleExclusive() + { + int i = NdbOperation::readTupleExclusive(); + VerifyInt(i, "readTupleExclusive"); + return i; + } + + int deleteTuple() + { + int i = NdbOperation::deleteTuple(); + VerifyInt(i, "deleteTuple"); + return i; + } + + int equal(const char* anAttrName, Uint32 aValue) + { + int i = NdbOperation::equal(anAttrName, aValue); + VerifyInt(i, "equal"); + return i; + } + + int setValue(const char* anAttrName, Uint32 aValue) + { + int i = NdbOperation::setValue(anAttrName, aValue); + VerifyInt(i, "setValue"); + return i; + } + + int incValue(const char* anAttrName, Uint32 aValue) + { + int i = NdbOperation::incValue(anAttrName, aValue); + VerifyInt(i, "incValue"); + return i; + } + + CVerifyNdbRecAttr* getValue(const char* anAttrName) + { + NdbRecAttr* p = NdbOperation::getValue(anAttrName); + VerifyPtr(p, "getValue"); + return (CVerifyNdbRecAttr*)p; + } + + +private: + void VerifyInt(const int i, const char* szMethod) + { + if(i) + { + VerifyIntError(i, szMethod); + } + } + + void VerifyPtr(void* p, const char* szMethod) + { + if(!p) + { + VerifyPtrError(p, szMethod); + } + } + + void VerifyIntError(const int i, const char* szMethod); + void VerifyPtrError(void* p, const char* szMethod); +}; + + +class CVerifyNdbIndexOperation : public NdbIndexOperation +{ +public: + int insertTuple() + { + int i = NdbIndexOperation::insertTuple(); + VerifyInt(i, "insertTuple"); + return i; + }; + + int updateTuple() + { + int i = NdbIndexOperation::updateTuple(); + VerifyInt(i, "updateTuple"); + return i; + }; + + int interpretedUpdateTuple() + { + int i = NdbIndexOperation::interpretedUpdateTuple(); + VerifyInt(i, "interpretedUpdateTuple"); + return i; + } + + int readTuple() + { + int i = NdbIndexOperation::readTuple(); + VerifyInt(i, "readTuple"); + return i; + } + + int readTupleExclusive() + { + int i = NdbIndexOperation::readTupleExclusive(); + VerifyInt(i, "readTupleExclusive"); + return i; + } + + int deleteTuple() + { + int i = NdbIndexOperation::deleteTuple(); + VerifyInt(i, "deleteTuple"); + return i; + } + + int equal(const char* anAttrName, Uint32 aValue) + { + int i = NdbIndexOperation::equal(anAttrName, aValue); + VerifyInt(i, "equal"); + return i; + } + + int setValue(const char* anAttrName, Uint32 aValue) + { + int i = NdbIndexOperation::setValue(anAttrName, aValue); + VerifyInt(i, "setValue"); + return i; + } + + int incValue(const char* anAttrName, Uint32 aValue) + { + int i = NdbIndexOperation::incValue(anAttrName, aValue); + VerifyInt(i, "incValue"); + return i; + } + + CVerifyNdbRecAttr* getValue(const char* anAttrName) + { + NdbRecAttr* p = NdbIndexOperation::getValue(anAttrName); + VerifyPtr(p, "getValue"); + return (CVerifyNdbRecAttr*)p; + } + + +private: + void VerifyInt(const int i, const char* szMethod) + { + if(i) + { + VerifyIntError(i, szMethod); + } + } + + void VerifyPtr(void* p, const char* szMethod) + { + if(!p) + { + VerifyPtrError(p, szMethod); + } + } + + void VerifyIntError(const int i, const char* szMethod); + void VerifyPtrError(void* p, const char* szMethod); +}; + + +class CVerifyNdbConnection : public NdbConnection +{ +public: + CVerifyNdbOperation* getNdbOperation(const char* aTableName) + { + NdbOperation* p = NdbConnection::getNdbOperation(aTableName); + VerifyPtr(p, "getNdbOperation"); + return (CVerifyNdbOperation*)p; + } + + CVerifyNdbIndexOperation* getNdbIndexOperation(const char* anIndexName, const char* aTableName) + { + NdbIndexOperation* p = NdbConnection::getNdbIndexOperation(anIndexName, aTableName); + VerifyPtr(p, "getNdbIndexOperation"); + return (CVerifyNdbIndexOperation*)p; + } + + int execute(ExecType aTypeOfExec) + { + int i = NdbConnection::execute(aTypeOfExec); + VerifyInt(i, "execute"); + return i; + } + + int execute_ok(ExecType aTypeOfExec) + { + int iExec = NdbConnection::execute(aTypeOfExec); + NdbError err = NdbConnection::getNdbError(); + int iCode = err.code; + if(iExec + && ((aTypeOfExec==NoCommit && iCode!=0) + || (aTypeOfExec==Commit && iCode!=626 && iCode!=630))) + { + VerifyInt(iExec, "execute"); + } + return iExec; + } + + +private: + void VerifyInt(const int i, const char* szMethod) + { + if(i) + { + VerifyIntError(i, szMethod); + } + } + + void VerifyPtr(void* p, const char* szMethod) + { + if(!p) + { + VerifyPtrError(p, szMethod); + } + } + + void VerifyIntError(const int i, const char* szMethod); + void VerifyPtrError(void* p, const char* szMethod); +}; + + +//class CVerifyTable : public NdbDictionary::Table +//{ +//public: +//}; + + +class CVerifyNdbDictionary : public NdbDictionary +{ +public: + class CVerifyTable : public Table + { + public: + private: + }; + + class CVerifyIndex : public Index + { + public: + private: + }; + + class CVerifyColumn : public Column + { + public: + private: + }; + + int createTable(const CVerifyTable &); + int createIndex(const CVerifyIndex &); + + +private: +}; + + +class CVerifyNdb : public Ndb +{ +public: + CVerifyNdb(const char* aDataBase) + : Ndb(aDataBase) + { + VerifyVoid("Ndb"); + }; + + CVerifyNdbSchemaCon* startSchemaTransaction() + { + NdbSchemaCon* p = Ndb::startSchemaTransaction(); + VerifyPtr(p, "startSchemaTransaction"); + return (CVerifyNdbSchemaCon*)p; + }; + + void closeSchemaTransaction(CVerifyNdbSchemaCon* aSchemaCon) + { + Ndb::closeSchemaTransaction(aSchemaCon); + VerifyVoid("closeSchemaTransaction"); + }; + + CVerifyNdbConnection* startTransaction() + { + NdbConnection* p = Ndb::startTransaction(); + VerifyPtr(p, "startTransaction"); + return (CVerifyNdbConnection*)p; + }; + + void closeTransaction(CVerifyNdbConnection* aConnection) + { + Ndb::closeTransaction(aConnection); + VerifyVoid("closeTransaction"); + }; + + +private: + void VerifyPtr(void* p, const char* szMethod) + { + if(!p) + { + VerifyPtrError(p, szMethod); + } + } + + void VerifyVoid(const char* szMethod) + { + NdbError err = Ndb::getNdbError(); + int iCode = err.code; + if(iCode) + { + VerifyVoidError(iCode, szMethod); + } + } + + void VerifyPtrError(void* p, const char* szMethod); + void VerifyVoidError(const int iCode, const char* szMethod); +}; + + + +#endif // VerifyNdbApi_hpp diff --git a/storage/ndb/test/ndbapi/old_dirs/basicAsynch/Makefile b/storage/ndb/test/ndbapi/old_dirs/basicAsynch/Makefile new file mode 100755 index 00000000000..802c5e5a2bd --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/basicAsynch/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := testBasicAsynch + +SOURCES := testBasicAsynch.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/bulk_copy/Makefile b/storage/ndb/test/ndbapi/old_dirs/bulk_copy/Makefile new file mode 100644 index 00000000000..22c05b138b7 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/bulk_copy/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := bulk_copy + +SOURCES := bulk_copy.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/create_all_tabs/Makefile b/storage/ndb/test/ndbapi/old_dirs/create_all_tabs/Makefile new file mode 100644 index 00000000000..58309807682 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/create_all_tabs/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := create_all_tabs + +# Source files of non-templated classes (.C files) +SOURCES = create_all_tabs.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/create_tab/Makefile b/storage/ndb/test/ndbapi/old_dirs/create_tab/Makefile new file mode 100644 index 00000000000..c2ea0b52b15 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/create_tab/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := create_tab + +# Source files of non-templated classes (.C files) +SOURCES = create_tab.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/drop_all_tabs/Makefile b/storage/ndb/test/ndbapi/old_dirs/drop_all_tabs/Makefile new file mode 100644 index 00000000000..96db0781417 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/drop_all_tabs/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := drop_all_tabs + +# Source files of non-templated classes (.C files) +SOURCES = drop_all_tabs.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/flexAsynch/Makefile b/storage/ndb/test/ndbapi/old_dirs/flexAsynch/Makefile new file mode 100644 index 00000000000..2c77c8e21df --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flexAsynch/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := flexAsynch + +# Source files of non-templated classes (.C files) +SOURCES = flexAsynch.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/flexBench/Makefile.am b/storage/ndb/test/ndbapi/old_dirs/flexBench/Makefile.am new file mode 100644 index 00000000000..d4de4b92b60 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flexBench/Makefile.am @@ -0,0 +1,10 @@ + +bin_PROGRAMS = flexBench + +flexBench_SOURCES = flexBench.cpp + +include $(top_srcdir)/ndb/config/common.mk.am +include $(top_srcdir)/ndb/config/type_ndbapitest.mk.am + +# Don't update the files from bitkeeper +%::SCCS/s.% diff --git a/storage/ndb/test/ndbapi/old_dirs/flexBench/ndbplot.pl b/storage/ndb/test/ndbapi/old_dirs/flexBench/ndbplot.pl new file mode 100755 index 00000000000..b16f6d5897d --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flexBench/ndbplot.pl @@ -0,0 +1,305 @@ +#! /usr/bin/perl + +use strict; +use Getopt::Long; +use Symbol; +use Socket; + +my $progname = $0; +$progname =~ s!^.*/|\.pl$!!g; +my $defaultport = 27127; +my $defaulttotal = 120; +my $defaultsample = 5; +my $defaultrange = 5000; + +sub printhelp { + print <<END; +$progname -- plot ndb operation counts in X11 window +usage: $progname [options] +--help print this summary and exit +--debug print lots of debug information +--port N port number to listen on, default $defaultport +--total N total time interval shown, default $defaulttotal seconds +--sample N sample interval, default $defaultsample seconds +--range N range (max ops per second), default $defaultrange +--nopct show no percentages in graph titles +--z "..." add X11/gnuplot options, for example: + --z "-bg grey80 -geometry 500x300" --z "-persist" +END + exit(0); +} + +# get options +use vars qw( + $helpflag $debug $serverport $totaltime $sampletime $range $nopct + @zopts +); +$helpflag = 0; +$debug = 0; +$serverport = $defaultport; +$totaltime = $defaulttotal; +$sampletime = $defaultsample; +$range = $defaultrange; +$nopct = 0; +@zopts = (); +GetOptions( + 'help' => \$helpflag, + 'debug' => \$debug, + 'port=i' => \$serverport, + 'total=i' => \$totaltime, + 'sample=i' => \$sampletime, + 'range=i' => \$range, + 'nopct' => \$nopct, + 'z=s' => \@zopts, +) or die "try: $progname -h\n"; +$helpflag && printhelp(); + +# calculate number of data points +my $samplecnt; +$samplecnt = int($totaltime / $sampletime) + 1; +$totaltime = ($samplecnt - 1) * $sampletime; +warn "total time = $totaltime sec, sample time = $sampletime sec\n"; + +# open gnuplot +my $plotfile; +sub openplot { + $plotfile = gensym(); + if (! open($plotfile, "| gnuplot @zopts")) { + die "open plot: $!\n"; + } + my $sav = select($plotfile); + $| = 1; + select($sav); + print $plotfile "clear\n"; +} + +# samples +my @sample; # samples 0..$samplecnt in time order +my $sampleready = 0; # samples 1..$samplecnt are ready (true/false) + +@sample = map({ start => 0 }, 0..$samplecnt); + +sub adddata { + my($node, $type, $value) = @_; + my $now = time; + my $s = $sample[0]; + if ($now - $s->{start} >= $sampletime) { + unshift(@sample, { + start => $now, + total => 0, + }); + $s = $sample[0]; + pop(@sample); # delete oldest + $sampleready = 1; + } + # if no type then this is just a time tick + if ($type) { + $s->{$type} += $value; + $s->{total} += $value; + } +} + +# data file name +my $datadir; +if ($ENV{NDB_BASE}) { + $datadir = "$ENV{NDB_BASE}/var/plot"; +} else { + $datadir = "/var/tmp"; +} +(-d $datadir || mkdir($datadir, 0777)) + or die "mkdir $datadir failed: $!\n"; +my $datafile = "$datadir/plot$$.dat"; +warn "writing plot data to $datafile\n"; + +# refresh the plot +sub plotsample { + my $fh = gensym(); + if (! open($fh, ">$datafile")) { + die "$datafile: $!\n"; + } + # sample 0 is never ready + my $currops = ""; + my $currpct = {}; + for (my $i = @sample; $i >= 1; $i--) { + my $s = $sample[$i]; + if (! $s->{start}) { # initial empty sample + next; + } + printf $fh "%d", -($i - 1) * $sampletime; + printf $fh " %.0f", 1.01 * $s->{"total"} / $sampletime; + for my $k (qw(insert update select delete)) { + printf $fh " %.0f", $s->{$k} / $sampletime; + } + printf $fh "\n"; + if ($i == 1) { + $currops = sprintf("%.0f", $s->{"total"} / $sampletime); + if (! $nopct && $currops > 0) { + $currpct->{"total"} = sprintf("%5s", ""); + for my $k (qw(insert update select delete)) { + $currpct->{$k} = sprintf(" %3.0f%%", + 100.0 * $s->{$k} / $s->{"total"}); + } + } + } + } + close($fh); + print $plotfile <<END; +clear +set title "ops/sec [ $currops ]" +set xrange [@{[ -($totaltime-1) ]}:0] +set yrange [0:$range] +plot \\ + '$datafile' \\ + using 1:3 \\ + title "insert$currpct->{insert}" \\ + with lines lt 2, \\ + '$datafile' \\ + using 1:4 \\ + title "update$currpct->{update}" \\ + with lines lt 3, \\ + '$datafile' \\ + using 1:5 \\ + title "select$currpct->{select}" \\ + with lines lt 4, \\ + '$datafile' \\ + using 1:6 \\ + title "delete$currpct->{delete}" \\ + with lines lt 5, \\ + '$datafile' \\ + using 1:2 \\ + title "total$currpct->{total}" \\ + with lines lt 1 lw 2 +END +} + +# set up server socket +my $sock = gensym(); +if (! socket($sock, PF_INET, SOCK_STREAM, getprotobyname("tcp"))) { + die "socket: $!\n"; +} +if (! setsockopt($sock, SOL_SOCKET, SO_REUSEADDR, pack("l*", 1))) { + die "setsockopt: $!\n"; +} +if (! bind($sock, pack_sockaddr_in($serverport, INADDR_ANY))) { + die "bind: $!\n"; +} +if (! listen($sock, SOMAXCONN)) { + die "listen: $!\n"; +} + +# bit vectors for select on server socket and clients +my $readin = ''; +vec($readin, fileno($sock), 1) = 1; + +# clients +my @client = (); +my $clientid = 0; +sub addclient { + my($conn) = @_; + my $c = { + conn => $conn, + data => "", + name => "client " . ++$clientid, + }; + push(@client, $c); + vec($readin, fileno($c->{conn}), 1) = 1; + if (1 || $debug) { + warn "added $c->{name}\n"; + } +} +sub deleteclient { + my($c) = @_; + @client = grep($_ ne $c, @client); + vec($readin, fileno($c->{conn}), 1) = 0; + shutdown($c->{conn}, 2); + if (1 || $debug) { + warn "deleted $c->{name}\n"; + } +} +sub readclient { + my($c) = @_; + my $data; + my $n; + eval { + local $SIG{ALRM} = sub { die "timeout\n" }; + alarm(5); + $n = sysread($c->{conn}, $data, 512); + alarm(0); + }; + if ($@) { + chomp($@); + warn "$c->{name}: read: $@\n"; + return undef; + } + if (!defined($n)) { + warn "$c->{name}: read: $!\n"; + return undef; + } + $c->{data} .= $data; + if ($debug) { + warn "$c->{name}: read @{[ length($data) ]} bytes\n"; + } + return $n; +} +sub processclient { + my($c) = @_; + my $i; + while (($i = index($c->{data}, "\n")) >= 0) { + my $line = substr($c->{data}, 0, $i); + $c->{data} = substr($c->{data}, $i+1); + my($node, $type, $value) = split(' ', $line); + if ($node !~ /^\d+$/) { + warn "$c->{name}: $line: bad node id\n"; + next; + } + if ($type !~ /^(insert|update|read|delete|verify|verifydelete)$/) { + warn "$c->{name}: $line: bad type\n"; + next; + } + if ($value !~ /^\d+$/) { + warn "$c->{name}: $line: bad value\n"; + next; + } + if ($type eq "read") { + $type = "select"; + } + adddata($node, $type, $value); + } +} + +# main loop +openplot(); +while (1) { + my $readout = ''; + my $ret = select($readout = $readin, undef, undef, 1.0); + if (vec($readout, fileno($sock), 1)) { + my $conn = gensym(); + if (! accept($conn, $sock)) { + warn "accept failed: $!\n"; + } else { + addclient($conn); + } + } + for my $c (@client) { + if (vec($readout, fileno($c->{conn}), 1)) { + my $n = readclient($c); + if (! defined($n)) { + deleteclient($c); + } else { + processclient($c); + if ($n == 0) { # end of file + deleteclient($c); + } + } + } + } + adddata(); # keep clock ticking + if ($sampleready) { + if ($debug) { + warn "sample ready\n"; + } + plotsample(); + $sampleready = 0; + } +} +# vim: set sw=4: diff --git a/storage/ndb/test/ndbapi/old_dirs/flexHammer/Makefile b/storage/ndb/test/ndbapi/old_dirs/flexHammer/Makefile new file mode 100644 index 00000000000..c8e436fb7f5 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flexHammer/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := flexHammer + +SOURCES := flexHammer.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/flexHammer/README b/storage/ndb/test/ndbapi/old_dirs/flexHammer/README new file mode 100644 index 00000000000..556582aab96 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flexHammer/README @@ -0,0 +1,67 @@ + +Executing flexHammer-tests automatically +======================================== + + +It is possible to execute almost al the flexHammer-tests +automatically. The procedure contains three steps: +- increase the number of tabels (flexHammer -c number) +- increase the number of threads (flexHammer -t number) +- increase the number of records (flexHammer -r number) +- increase the number of tabels and threads alternately + +Each of these steps are performed by the scripts test1.sh, +test2.sh, test3.sh and test4.sh. Each test will start Ndb, +execute the test and close Ndb again in order to execute +each test in a 'clean' Ndb-environment. So make sure that +there is no Ndb running when you start the test. + + +1. Setup + +To perform the tests automatically, the following issues +have to be taken care of: + +- be sure that you have a directory bin in your home-directory. + In this directory, you need to have a link 'runndb' to the + ndb executable. You can do this by executing a shell-command like: + ln -s ndb/Emulator/Main/ndb runndb + The script is not yet so far that it performs checks, so if + you forget about this, things will get messy. +- In this directory you need a Ndb.cfg for a server-configuration. + + +2. Command + +I assume you have Ndb and the API compiled or you use the +'released' version. Compile flexHammer as usual with 'make'. +Now you can start the tests by typing 'make test'. The +execution of the test will take a while. + + +3. Results + +The scripts will write their results in the file report.txt. +The scripts will start with a short summary on the test. Then +it will add 1 line documenting each run of flexHammer that is +ececuted. Finally, it will print highest 'score'. The file +report.txt is probably good enough to check in directly as +testprotocol in ndb/test/docs/testprotocols. + + +4. Log files. + +To make it possible to investigate errors, the output from +the flexScan-run where the error occurred is stored in +test1.log, test2.log, test3.log or test4.log respectively. +They are overwritten each time you start 'make test'. + + +HINT + +The number of iterations in each test-script is not directly +limited by the number of attributes or the size of the +attributes but by the number of tables that you are allowed +to create. Probably this will be the error that occurs if +you execute the test. You migh adjust the begin-values and +the step-size in the individual scripts if you want. diff --git a/storage/ndb/test/ndbapi/old_dirs/flexScan/Makefile b/storage/ndb/test/ndbapi/old_dirs/flexScan/Makefile new file mode 100644 index 00000000000..78f9d481063 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flexScan/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := flexScan + +SOURCES := flexScan.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/flexScan/README b/storage/ndb/test/ndbapi/old_dirs/flexScan/README new file mode 100644 index 00000000000..cddbdea5336 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flexScan/README @@ -0,0 +1,66 @@ + +Executing flexScan-tests automatically +====================================== + + +It is possible to execute almost al the flexBench-tests +automatically. The procedure contains three steps: +- increase the number of attributes (flexScan -a number) +- increase the size of attributes (flexScan -s number) +- increase the number of threads (flexScan -t number) + +Each of these steps are performed by the scripts test1.sh +test2.sh and test3.sh. Each test will start Ndb, execute +the test and close Ndb again in order to execute each test +in a 'clean' Ndb-environment. So make sure that there is +no Ndb running when you start the test. + + +1. Setup + +To perform the tests automatically, the following issues +have to be taken care of: + +- be sure that you have a directory bin in your home-directory. + In this directory, you need to have a link 'runndb' to the + ndb executable. You can do this by executing a shell-command like: + ln -s ndb/Emulator/Main/ndb runndb + The script is not yet so far that it performs checks, so if + you forget about this, things will get messy. +- In this directory you need a Ndb.cfg for a server-configuration. + + +2. Command + +I assume you have Ndb and the API compiled or you use the +'released' version. Compile flexScan as usual with 'make'. +Now you can start the tests by typing 'make test'. The +execution of the test will take a while. + + +3. Results + +The scripts will write their results in the file report.txt. +The scripts will start with a short summary on the test. Then +it will add 1 line documenting each run of flexScan that is +ececuted. Finally, it will print highest 'score'. The file +report.txt is probably good enough to check in directly as +testprotocol in ndb/test/docs/testprotocols. + + +4. Log files. + +To make it possible to investigate errors, the output from +the flexScan-run where the error occurred is stored in +test1.log, test2.log or test3.log respectively. They are +overwritten each time you start 'make test'. + + +HINT + +The number of iterations in each test-script is not directly +limited by the number of attributes or the size of the +attributes but by the number of tables that you are allowed +to create. Probably this will be the error that occurs if +you execute the test. You migh adjust the begin-values and +the step-size in the individual scripts if you want. diff --git a/storage/ndb/test/ndbapi/old_dirs/flexTT/Makefile b/storage/ndb/test/ndbapi/old_dirs/flexTT/Makefile new file mode 100644 index 00000000000..a63bd803d95 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flexTT/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := flexTT + +# Source files of non-templated classes (.C files) +SOURCES = flexTT.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/flexTimedAsynch/Makefile b/storage/ndb/test/ndbapi/old_dirs/flexTimedAsynch/Makefile new file mode 100644 index 00000000000..e9995dbd16f --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flexTimedAsynch/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := flexTimedAsynch + +# Source files of non-templated classes (.C files) +SOURCES = flexTimedAsynch.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/flex_bench_mysql/Makefile b/storage/ndb/test/ndbapi/old_dirs/flex_bench_mysql/Makefile new file mode 100644 index 00000000000..d2608526cae --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/flex_bench_mysql/Makefile @@ -0,0 +1,15 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := flex_bench_mysql + +# Source files of non-templated classes (.C files) +SOURCES = flex_bench_mysql.cpp + +CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/../include) +BIN_TARGET_LIBS_DIRS += $(NDB_TOP)/../libmysql_r/.libs +BIN_TARGET_LIBS += z mysqlclient_r + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/indexTest/Makefile b/storage/ndb/test/ndbapi/old_dirs/indexTest/Makefile new file mode 100644 index 00000000000..d842e487ee5 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/indexTest/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := index + +SOURCES := index.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/indexTest2/Makefile b/storage/ndb/test/ndbapi/old_dirs/indexTest2/Makefile new file mode 100644 index 00000000000..ad78fd51986 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/indexTest2/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := index2 + +SOURCES := index2.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/interpreterInTup/Makefile b/storage/ndb/test/ndbapi/old_dirs/interpreterInTup/Makefile new file mode 100644 index 00000000000..074adbf674a --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/interpreterInTup/Makefile @@ -0,0 +1,10 @@ +include .defs.mk + +TYPE := ndbapitest + + +BIN_TARGET := interpreterInTup + +SOURCES := interpreterInTup.cc + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/Makefile new file mode 100644 index 00000000000..af472b1589f --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/Makefile @@ -0,0 +1,6 @@ +include .defs.mk + +DIRS := src async-src script + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/Makefile new file mode 100644 index 00000000000..744d6171139 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/Makefile @@ -0,0 +1,8 @@ +include .defs.mk + +DIRS = \ + user \ + generator + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/generator/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/generator/Makefile new file mode 100644 index 00000000000..c1f84a3ef70 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/generator/Makefile @@ -0,0 +1,13 @@ +include .defs.mk + +TYPE := ndbapitest + +SOURCES = mainAsyncGenerator.cpp asyncGenerator.cpp + +CCFLAGS_LOC := -I../include -I../../include + +BIN_TARGET := DbAsyncGenerator +BIN_TARGET_ARCHIVES := lmc_AsyncUser + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/dbGenerator.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/dbGenerator.h new file mode 100644 index 00000000000..2256498e151 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/dbGenerator.h @@ -0,0 +1,63 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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 asyncGenerator(ThreadData *d, int parallellism, + int millisSendPoll, + int minEventSendPoll, + int forceSendPoll); + +#ifdef __cplusplus +} +#endif + +/*************************************************************** +* E X T E R N A L D A T A * +***************************************************************/ + + + +#endif /* DBGENERATOR_H */ + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/testData.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/testData.h new file mode 100644 index 00000000000..3db85e7342e --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/testData.h @@ -0,0 +1,156 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef TESTDATA_H +#define TESTDATA_H + +/*************************************************************** +* I N C L U D E D F I L E S * +***************************************************************/ +#include <NdbTick.h> +#include <NdbThread.h> +#include <NDBT_Stats.hpp> +#include <random.h> +#include "testDefinitions.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 { + unsigned int count; + unsigned int branchExecuted; + unsigned int rollbackExecuted; + + /** + * Latency measures + */ + NDB_TICKS startTime; + NDBT_Stats latency; + unsigned int latencyCounter; + + inline void startLatency(){ + if((latencyCounter & 127) == 127) + startTime = NdbTick_CurrentMillisecond(); + } + + inline void stopLatency(){ + if((latencyCounter & 127) == 127){ + const NDB_TICKS tmp = NdbTick_CurrentMillisecond() - startTime; + latency.addObservation(tmp); + } + latencyCounter++; + } +} TransactionDefinition; + +typedef struct { + RandomSequence transactionSequence; + RandomSequence rollbackSequenceT4; + RandomSequence rollbackSequenceT5; + + TransactionDefinition transactions[NUM_TRANSACTION_TYPES]; + + unsigned int totalTransactions; + + double outerLoopTime; + double outerTps; + + SessionList activeSessions; + +} GeneratorStatistics; + +typedef enum{ + Runnable, + Running +} RunState ; + +typedef struct { + SubscriberNumber number; + SubscriberSuffix suffix; + SubscriberName name; + Location location; + ChangedBy changed_by; + ChangedTime changed_time; + ServerId server_id; + ServerBit server_bit; + SessionDetails session_details; + + GroupId group_id; + ActiveSessions sessions; + Permission permission; + + unsigned int do_rollback; + + unsigned int branchExecuted; + unsigned int sessionElement; +} TransactionData ; + +typedef struct { + struct NdbThread* pThread; + + unsigned long randomSeed; + unsigned long changedTime; + + unsigned int warmUpSeconds; + unsigned int testSeconds; + unsigned int coolDownSeconds; + + GeneratorStatistics generator; + + /** + * For async execution + */ + RunState runState; + double startTime; + TransactionData transactionData; + struct Ndb * pNDB; +} 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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/userInterface.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/userInterface.h new file mode 100644 index 00000000000..94bd1e80ab3 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/include/userInterface.h @@ -0,0 +1,79 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef DBINTERFACE_H +#define DBINTERFACE_H + +/***************************************************************/ +/* I N C L U D E D F I L E S */ +/***************************************************************/ + +#include "testDefinitions.h" +#include "testData.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 * +***************************************************************/ + +/*************************************************************** +* P U B L I C F U N C T I O N S * +***************************************************************/ + +typedef struct Ndb Ndb; + +#ifdef __cplusplus +extern "C" { +#endif + extern void showTime(); + extern double userGetTime(void); + extern Ndb *asyncDbConnect(int parallellism); + extern void asyncDbDisconnect(Ndb* pNDB); + + extern void start_T1(Ndb * uh, ThreadData * data, int async); + extern void start_T2(Ndb * uh, ThreadData * data, int async); + extern void start_T3(Ndb * uh, ThreadData * data, int async); + extern void start_T4(Ndb * uh, ThreadData * data, int async); + extern void start_T5(Ndb * uh, ThreadData * data, int async); + + extern void complete_T1(ThreadData * data); + extern void complete_T2(ThreadData * data); + extern void complete_T3(ThreadData * data); + extern void complete_T4(ThreadData * data); + extern void complete_T5(ThreadData * data); + +#ifdef __cplusplus +} +#endif + +/*************************************************************** +* E X T E R N A L D A T A * +***************************************************************/ + +#endif /* DBINTERFACE_H */ + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/Makefile new file mode 100644 index 00000000000..c0b532a8359 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +ARCHIVE_TARGET := lmc_AsyncUser + +SOURCES := userInterface.C ndb_async2.C + +CCFLAGS_LOC = -I../include -I../../include + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/macros.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/macros.h new file mode 100644 index 00000000000..22b7f564490 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/macros.h @@ -0,0 +1,51 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/ndb_error.hpp b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/ndb_error.hpp new file mode 100644 index 00000000000..9e6c5e55e73 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/async-src/user/ndb_error.hpp @@ -0,0 +1,63 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef NDB_ERROR_H +#define NDB_ERROR_H + +#include <ndb_global.h> +#include <NdbOut.hpp> +#include "userInterface.h" +#include <NdbError.hpp> + +inline +void +CHECK_ALLOWED_ERROR(const char * str, + const ThreadData * td, + const struct NdbError & error){ + + char buf[100]; + snprintf(buf, sizeof(buf), "subscriber = %.*s ", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number); + ndbout << str << " " << error << endl + << buf; + showTime(); + + switch(error.classification) { + case NdbError::TimeoutExpired: + case NdbError::OverloadError: + case NdbError::TemporaryResourceError: + case NdbError::NodeRecoveryError: + break; + default: + if(error.status != NdbError::TemporaryError) + exit(-1); + } +} + +inline +void +CHECK_NULL(void * null, + const char * str, + const ThreadData * td, + const struct NdbError & err){ + if(null == 0){ + CHECK_ALLOWED_ERROR(str, td, err); + exit(-1); + } +} + +#endif diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/bin/.empty b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/bin/.empty new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/bin/.empty diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/include/ndb_schema.hpp b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/include/ndb_schema.hpp new file mode 100644 index 00000000000..af08bc2eecd --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/include/ndb_schema.hpp @@ -0,0 +1,78 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef NDB_SCHEMA_H +#define NDB_SCHEMA_H + +#include "testDefinitions.h" + +#define SUBSCRIBER_TABLE "SUBSCRIBER" +#define SUBSCRIBER_NUMBER "NUMBER" +#define SUBSCRIBER_LOCATION "LOCATION" +#define SUBSCRIBER_NAME "NAME" +#define SUBSCRIBER_GROUP "GROUP_ID" +#define SUBSCRIBER_SESSIONS "SESSIONS" +#define SUBSCRIBER_CHANGED_BY "CHANGED_BY" +#define SUBSCRIBER_CHANGED_TIME "CHANGED_TIME" + +#define SERVER_TABLE "SERVER" +#define SERVER_ID "SERVER_ID" +#define SERVER_SUBSCRIBER_SUFFIX "SUFFIX" +#define SERVER_NAME "NAME" +#define SERVER_READS "NO_OF_READ" +#define SERVER_INSERTS "NO_OF_INSERT" +#define SERVER_DELETES "NO_OF_DELETE" + +#define GROUP_TABLE "GROUP" +#define GROUP_ID "GROUP_ID" +#define GROUP_NAME "GROUP_NAME" +#define GROUP_ALLOW_READ "ALLOW_READ" +#define GROUP_ALLOW_INSERT "ALLOW_INSERT" +#define GROUP_ALLOW_DELETE "ALLOW_DELETE" + +#define SESSION_TABLE "SESSION" +#define SESSION_SERVER "SERVER_ID" +#define SESSION_SUBSCRIBER "NUMBER" +#define SESSION_DATA "DATA" + +/** Numbers */ + +#define IND_SUBSCRIBER_NUMBER (unsigned)0 +#define IND_SUBSCRIBER_NAME (unsigned)1 +#define IND_SUBSCRIBER_GROUP (unsigned)2 +#define IND_SUBSCRIBER_LOCATION (unsigned)3 +#define IND_SUBSCRIBER_SESSIONS (unsigned)4 +#define IND_SUBSCRIBER_CHANGED_BY (unsigned)5 +#define IND_SUBSCRIBER_CHANGED_TIME (unsigned)6 + +#define IND_SERVER_SUBSCRIBER_SUFFIX (unsigned)0 +#define IND_SERVER_ID (unsigned)1 +#define IND_SERVER_NAME (unsigned)2 +#define IND_SERVER_READS (unsigned)3 +#define IND_SERVER_INSERTS (unsigned)4 +#define IND_SERVER_DELETES (unsigned)5 + +#define IND_GROUP_ID (unsigned)0 +#define IND_GROUP_NAME (unsigned)1 +#define IND_GROUP_ALLOW_READ (unsigned)2 +#define IND_GROUP_ALLOW_INSERT (unsigned)3 +#define IND_GROUP_ALLOW_DELETE (unsigned)4 + +#define IND_SESSION_SUBSCRIBER (unsigned)0 +#define IND_SESSION_SERVER (unsigned)1 +#define IND_SESSION_DATA (unsigned)2 + +#endif diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/include/testDefinitions.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/include/testDefinitions.h new file mode 100644 index 00000000000..2f4aeb30975 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/include/testDefinitions.h @@ -0,0 +1,90 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef TESTDEFINITIONS_H +#define TESTDEFINITIONS_H + +/***************************************************************/ +/* I N C L U D E D F I L E S */ +/***************************************************************/ + +#include <ndb_types.h> + +/***************************************************************/ +/* C O N S T A N T S */ +/***************************************************************/ + +#define OP_PER_TRANS 200 +#define NO_OF_SUBSCRIBERS 500000 +#define NO_OF_GROUPS 100 +#define NO_OF_SERVERS 20 + +#define SUBSCRIBER_NUMBER_LENGTH 12 +#define SUBSCRIBER_NUMBER_SUFFIX_LENGTH 2 + +#define SUBSCRIBER_NAME_LENGTH 32 +#define CHANGED_BY_LENGTH 32 +#define CHANGED_TIME_LENGTH 32 +#define SESSION_DETAILS_LENGTH 2000 +#define SERVER_NAME_LENGTH 32 +#define GROUP_NAME_LENGTH 32 + +/*************************************************************** +* D A T A S T R U C T U R E S * +***************************************************************/ + +#define PADDING 4 + +typedef char SubscriberNumber[SUBSCRIBER_NUMBER_LENGTH]; +typedef char SubscriberSuffix[SUBSCRIBER_NUMBER_SUFFIX_LENGTH + 2]; +typedef char SubscriberName[SUBSCRIBER_NAME_LENGTH]; +typedef char ServerName[SERVER_NAME_LENGTH]; +typedef char GroupName[GROUP_NAME_LENGTH]; +typedef char ChangedBy[CHANGED_BY_LENGTH]; +typedef char ChangedTime[CHANGED_TIME_LENGTH]; +typedef char SessionDetails[SESSION_DETAILS_LENGTH]; +typedef Uint32 ServerId; +typedef Uint32 ServerBit; +typedef Uint32 GroupId; +typedef Uint32 Location; +typedef Uint32 Permission; + +typedef Uint32 Counter; +typedef Uint32 ActiveSessions; +typedef unsigned int BranchExecuted; +typedef unsigned int DoRollback; + +/*************************************************************** +* P U B L I C F U N C T I O N S * +***************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef __cplusplus +} +#endif + +/*************************************************************** +* E X T E R N A L D A T A * +***************************************************************/ + + + +#endif /* TESTDEFINITIONS_H */ + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/lib/.empty b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/lib/.empty new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/lib/.empty diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/Makefile new file mode 100644 index 00000000000..240b5957573 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/Makefile @@ -0,0 +1,5 @@ +include .defs.mk + +SOURCES.sh := async-lmc-bench.sh async-lmc-bench-l.sh async-lmc-bench-p10.sh async-lmc-bench-l-p10.sh + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench-l-p10.sh b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench-l-p10.sh new file mode 100755 index 00000000000..1ce3969f9fb --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench-l-p10.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +DbCreate -l +ret=$? +if [ $ret -ne 0 ] +then + echo "DbCreate failed" + exit $ret +fi + +DbAsyncGenerator -time 300 -p 10 $* +ret=$? +exit $ret + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench-l.sh b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench-l.sh new file mode 100755 index 00000000000..a5de71395c4 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench-l.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +DbCreate -l +ret=$? +if [ $ret -ne 0 ] +then + echo "DbCreate failed" + exit $ret +fi + +DbAsyncGenerator -time 300 $* +ret=$? +exit $ret + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench-p10.sh b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench-p10.sh new file mode 100755 index 00000000000..92c853cdd86 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench-p10.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +DbCreate +ret=$? +if [ $ret -ne 0 ] +then + echo "DbCreate failed" + exit $ret +fi + +DbAsyncGenerator -time 300 -p 10 $* +ret=$? +exit $ret + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench.sh b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench.sh new file mode 100755 index 00000000000..da8e9d9bf42 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/script/async-lmc-bench.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +DbCreate +ret=$? +if [ $ret -ne 0 ] +then + echo "DbCreate failed" + exit $ret +fi + +DbAsyncGenerator -time 300 $* +ret=$? +exit $ret + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/Makefile new file mode 100644 index 00000000000..ae7fac9c49b --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/Makefile @@ -0,0 +1,8 @@ +include .defs.mk + +DIRS = \ + user \ + populator \ + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/README b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/README new file mode 100644 index 00000000000..e81c8ba0051 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/README @@ -0,0 +1,8 @@ + +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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/Makefile new file mode 100644 index 00000000000..143d9ba655e --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/Makefile @@ -0,0 +1,17 @@ +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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.c b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.c new file mode 100644 index 00000000000..7484c7647f5 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.c @@ -0,0 +1,543 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/*************************************************************** +* 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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.h new file mode 100644 index 00000000000..824688b6cf9 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/dbGenerator.h @@ -0,0 +1,61 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/mainGenerator.c b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/mainGenerator.c new file mode 100644 index 00000000000..4a31db0b4e9 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/generator/mainGenerator.c @@ -0,0 +1,323 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include <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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/testData.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/testData.h new file mode 100644 index 00000000000..863c230502b --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/testData.h @@ -0,0 +1,103 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/userInterface.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/userInterface.h new file mode 100644 index 00000000000..b70ded87756 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/include/userInterface.h @@ -0,0 +1,128 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.linux b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.linux new file mode 100644 index 00000000000..a933669cfe7 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.linux @@ -0,0 +1,6 @@ +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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.sparc b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.sparc new file mode 100644 index 00000000000..57ab8bf982f --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/makevars.sparc @@ -0,0 +1,15 @@ + +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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/Makefile new file mode 100644 index 00000000000..2107c948843 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/Makefile @@ -0,0 +1,15 @@ +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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.c b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.c new file mode 100644 index 00000000000..42fbb52f3b2 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.c @@ -0,0 +1,244 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/*************************************************************** +* 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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.h new file mode 100644 index 00000000000..1916720e141 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/dbPopulate.h @@ -0,0 +1,59 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/mainPopulate.c b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/mainPopulate.c new file mode 100644 index 00000000000..838ac8a7196 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/populator/mainPopulate.c @@ -0,0 +1,76 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include <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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/Makefile new file mode 100644 index 00000000000..9bf229ac84c --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/Makefile @@ -0,0 +1,11 @@ +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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/localDbPrepare.c b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/localDbPrepare.c new file mode 100644 index 00000000000..dd100507016 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/localDbPrepare.c @@ -0,0 +1,648 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/*************************************************************** +* 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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/macros.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/macros.h new file mode 100644 index 00000000000..363f247b93f --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/macros.h @@ -0,0 +1,51 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/ndb_error.hpp b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/ndb_error.hpp new file mode 100644 index 00000000000..b3aaeac822e --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/ndb_error.hpp @@ -0,0 +1,31 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/Makefile b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/Makefile new file mode 100644 index 00000000000..9b1247d44af --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/Makefile @@ -0,0 +1,10 @@ +include ../makevars.$(ARCH) + +LIBRARY = ../../lib/libUser.so + +OBJECTS = \ + $(LIBRARY)(localDbPrepare.o)\ + $(LIBRARY)(userInterface.o)\ + $(LIBRARY)(userTransaction.o) + +$(LIBRARY): $(OBJECTS) diff --git a/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userHandle.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userHandle.h new file mode 100644 index 00000000000..1de468d4dad --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userHandle.h @@ -0,0 +1,190 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userInterface.c b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userInterface.c new file mode 100644 index 00000000000..bacf1861dde --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userInterface.c @@ -0,0 +1,453 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/*************************************************************** +* 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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userTransaction.c b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userTransaction.c new file mode 100644 index 00000000000..a2f4787bb0c --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/old/userTransaction.c @@ -0,0 +1,473 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/*************************************************************** +* 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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userHandle.h b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userHandle.h new file mode 100644 index 00000000000..6da76fc2bff --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userHandle.h @@ -0,0 +1,51 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userInterface.cpp b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userInterface.cpp new file mode 100644 index 00000000000..fe3c17acbf5 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userInterface.cpp @@ -0,0 +1,739 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/*************************************************************** +* 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, µs); + + 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/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userTransaction.c b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userTransaction.c new file mode 100644 index 00000000000..a2f4787bb0c --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/lmc-bench/src/user/userTransaction.c @@ -0,0 +1,473 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/*************************************************************** +* 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/storage/ndb/test/ndbapi/old_dirs/restarter/Makefile b/storage/ndb/test/ndbapi/old_dirs/restarter/Makefile new file mode 100644 index 00000000000..041fbfd82ba --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/restarter/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := restarter + +# Source files of non-templated classes (.C files) +SOURCES = restarter.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/restarter2/Makefile b/storage/ndb/test/ndbapi/old_dirs/restarter2/Makefile new file mode 100644 index 00000000000..ba33a2e21dc --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/restarter2/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := restarter2 + +# Source files of non-templated classes (.C files) +SOURCES = restarter2.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/restarts/Makefile b/storage/ndb/test/ndbapi/old_dirs/restarts/Makefile new file mode 100644 index 00000000000..9f14b81fae5 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/restarts/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := restarts + +# Source files of non-templated classes (.C files) +SOURCES = restarts.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/ronja/Makefile b/storage/ndb/test/ndbapi/old_dirs/ronja/Makefile new file mode 100644 index 00000000000..a11a27c5fd7 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/ronja/Makefile @@ -0,0 +1,6 @@ +include .defs.mk + +DIRS = initronja \ + benchronja + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/ronja/benchronja/Makefile b/storage/ndb/test/ndbapi/old_dirs/ronja/benchronja/Makefile new file mode 100644 index 00000000000..f0521c3ba77 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/ronja/benchronja/Makefile @@ -0,0 +1,10 @@ +include .defs.mk + +TYPE := ndbapitest + + +BIN_TARGET := benchronja + +SOURCES := benchronja.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/ronja/initronja/Makefile b/storage/ndb/test/ndbapi/old_dirs/ronja/initronja/Makefile new file mode 100644 index 00000000000..dd66dd813d1 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/ronja/initronja/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := initronja + +SOURCES := initronja.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/telco/Makefile b/storage/ndb/test/ndbapi/old_dirs/telco/Makefile new file mode 100644 index 00000000000..8f82c714119 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/telco/Makefile @@ -0,0 +1,10 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := telco + +# Source files of non-templated classes (.C files) +SOURCES = msa.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/telco/readme b/storage/ndb/test/ndbapi/old_dirs/telco/readme new file mode 100644 index 00000000000..627b4256eef --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/telco/readme @@ -0,0 +1,9 @@ + +adoInsertRecs.cpp - the original evaluation program + +InsertRecs.cpp - replaced ado with ndb api, still windows only + +msa.cpp - removed windows and exceptions, portable + + + diff --git a/storage/ndb/test/ndbapi/old_dirs/testBackup/Makefile b/storage/ndb/test/ndbapi/old_dirs/testBackup/Makefile new file mode 100644 index 00000000000..abf47dcfb2d --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testBackup/Makefile @@ -0,0 +1,8 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testBackup +SOURCES = testBackup.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testBasic/Makefile b/storage/ndb/test/ndbapi/old_dirs/testBasic/Makefile new file mode 100644 index 00000000000..755b19939cb --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testBasic/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := testBasic + +SOURCES := testBasic.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testBlobs/Makefile b/storage/ndb/test/ndbapi/old_dirs/testBlobs/Makefile new file mode 100644 index 00000000000..cc5bb629c17 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testBlobs/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testBlobs + +SOURCES = testBlobs.cpp + +include $(NDB_TOP)/Epilogue.mk + +CCFLAGS_LOC += -I$(NDB_TOP)/include/kernel diff --git a/storage/ndb/test/ndbapi/old_dirs/testDataBuffers/Makefile b/storage/ndb/test/ndbapi/old_dirs/testDataBuffers/Makefile new file mode 100644 index 00000000000..181fbc829d4 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testDataBuffers/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testDataBuffers + +SOURCES = testDataBuffers.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testDict/Makefile b/storage/ndb/test/ndbapi/old_dirs/testDict/Makefile new file mode 100644 index 00000000000..75d493c3424 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testDict/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testDict + +SOURCES = testDict.cpp + +CFLAGS_testDict.cpp := -I$(call fixpath,$(NDB_TOP)/include/kernel) + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testGrep/Makefile b/storage/ndb/test/ndbapi/old_dirs/testGrep/Makefile new file mode 100644 index 00000000000..6bad3d56a00 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testGrep/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest +DIRS = verify +BIN_TARGET = testGrep +SOURCES = testGrep.cpp + +include $(NDB_TOP)/Epilogue.mk + diff --git a/storage/ndb/test/ndbapi/old_dirs/testGrep/verify/Makefile b/storage/ndb/test/ndbapi/old_dirs/testGrep/verify/Makefile new file mode 100644 index 00000000000..256e3c98f36 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testGrep/verify/Makefile @@ -0,0 +1,10 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testGrepVerify +SOURCES = testGrepVerify.cpp + +CFLAGS_testGrepVerify.cpp += -I$(call fixpath,$(NDB_TOP)/include/kernel) -I$(call fixpath,$(NDB_TOP)/include/mgmcommon) + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testIndex/Makefile b/storage/ndb/test/ndbapi/old_dirs/testIndex/Makefile new file mode 100644 index 00000000000..e5cd4542c9c --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testIndex/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testIndex + +SOURCES = testIndex.cpp + +CFLAGS_testIndex.cpp := -I$(call fixpath,$(NDB_TOP)/include/kernel) + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testInterpreter/Makefile b/storage/ndb/test/ndbapi/old_dirs/testInterpreter/Makefile new file mode 100644 index 00000000000..e84287a1b16 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testInterpreter/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testInterpreter + +SOURCES = testInterpreter.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testMgm/Makefile b/storage/ndb/test/ndbapi/old_dirs/testMgm/Makefile new file mode 100644 index 00000000000..be50d3dae7e --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testMgm/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testMgm + +SOURCES = testMgm.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testNdbApi/Makefile b/storage/ndb/test/ndbapi/old_dirs/testNdbApi/Makefile new file mode 100644 index 00000000000..3bb3cba427e --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testNdbApi/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testNdbApi + +SOURCES = testNdbApi.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testNodeRestart/Makefile b/storage/ndb/test/ndbapi/old_dirs/testNodeRestart/Makefile new file mode 100644 index 00000000000..8c13ab3beb4 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testNodeRestart/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testNodeRestart + +SOURCES = testNodeRestart.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testOIBasic/Makefile b/storage/ndb/test/ndbapi/old_dirs/testOIBasic/Makefile new file mode 100644 index 00000000000..1bbbcf1d17e --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testOIBasic/Makefile @@ -0,0 +1,13 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testOIBasic + +SOURCES = testOIBasic.cpp + +ifeq ($(NDB_COMPILER),GCC) +CCFLAGS_WARNINGS += -Wno-unused -Wformat +endif + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testOIBasic/times.txt b/storage/ndb/test/ndbapi/old_dirs/testOIBasic/times.txt new file mode 100644 index 00000000000..641e9ddb4bf --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testOIBasic/times.txt @@ -0,0 +1,8 @@ +one db-node +testOIBasic -case t -table 1 -index 1 -fragtype small -threads 10 -rows 5000 -subloop 1 +------------------------------------------------------------ +040331 +build index - 5769 ms per 50000 ( 115 ms per 1000 ) +update - 5962 ms per 50000 ( 119 ms per 1000 ) +update indexed - 14851 ms per 50000 ( 297 ms per 1000 ) +overhead - 149 pct diff --git a/storage/ndb/test/ndbapi/old_dirs/testOperations/Makefile b/storage/ndb/test/ndbapi/old_dirs/testOperations/Makefile new file mode 100644 index 00000000000..25546ade639 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testOperations/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := testOperations + +SOURCES := testOperations.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testOrderedIndex/Makefile b/storage/ndb/test/ndbapi/old_dirs/testOrderedIndex/Makefile new file mode 100644 index 00000000000..d8899a37895 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testOrderedIndex/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testOrderedIndex + +SOURCES = testOrderedIndex.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testRestartGci/Makefile b/storage/ndb/test/ndbapi/old_dirs/testRestartGci/Makefile new file mode 100644 index 00000000000..24f449b747d --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testRestartGci/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := testRestartGci + +SOURCES := testRestartGci.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testScan/Makefile b/storage/ndb/test/ndbapi/old_dirs/testScan/Makefile new file mode 100644 index 00000000000..fe48f5bc926 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testScan/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testScan + +SOURCES = testScan.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testScanInterpreter/Makefile b/storage/ndb/test/ndbapi/old_dirs/testScanInterpreter/Makefile new file mode 100644 index 00000000000..c7d96494148 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testScanInterpreter/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testScanInterpreter + +SOURCES = testScanInterpreter.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testSystemRestart/Makefile b/storage/ndb/test/ndbapi/old_dirs/testSystemRestart/Makefile new file mode 100644 index 00000000000..7a306eb313d --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testSystemRestart/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testSystemRestart + +SOURCES = testSystemRestart.cpp + +CFLAGS_testSystemRestart.cpp := -I$(call fixpath,$(NDB_TOP)/include/kernel) + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testTimeout/Makefile b/storage/ndb/test/ndbapi/old_dirs/testTimeout/Makefile new file mode 100644 index 00000000000..01a9df9887f --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testTimeout/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE = ndbapitest + +BIN_TARGET = testTimeout + +SOURCES = testTimeout.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/testTransactions/Makefile b/storage/ndb/test/ndbapi/old_dirs/testTransactions/Makefile new file mode 100644 index 00000000000..0279a526923 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/testTransactions/Makefile @@ -0,0 +1,10 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := testTransactions + +SOURCES := testTransactions.cpp +CFLAGS_testTransactions.cpp := -I$(call fixpath,$(NDB_TOP)/include/kernel) + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/test_event/Makefile b/storage/ndb/test/ndbapi/old_dirs/test_event/Makefile new file mode 100644 index 00000000000..6299fa47845 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/test_event/Makefile @@ -0,0 +1,9 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := test_event + +SOURCES := test_event.cpp + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/vw_test/Makefile b/storage/ndb/test/ndbapi/old_dirs/vw_test/Makefile new file mode 100644 index 00000000000..144873dcc69 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/vw_test/Makefile @@ -0,0 +1,11 @@ +include .defs.mk + +TYPE := ndbapitest + +BIN_TARGET := vw_test +BIN_TARGET_LIBS := orafunctr decode cirk inifunc +BIN_TARGET_LIBS_DIRS := /home/ndb/junk/vw/ndb/lib + +SOURCES := cdrserver.C + +include $(NDB_TOP)/Epilogue.mk diff --git a/storage/ndb/test/ndbapi/old_dirs/vw_test/bcd.h b/storage/ndb/test/ndbapi/old_dirs/vw_test/bcd.h new file mode 100644 index 00000000000..d0aaffbd8b7 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/vw_test/bcd.h @@ -0,0 +1,26 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include <ndb_global.h> + +struct bcdtab { + char tab[3]; +}; + +int dec2hex(int dec,int last); +int bcd_code (char *bcd_in,char *bcd_out); +int bcd_decode (int bcd_len,char *bcd_in,char *bcd_out); +int bcd_decode2 (int bcd_len,char *bcd_in,char *bcd_out); diff --git a/storage/ndb/test/ndbapi/old_dirs/vw_test/script/client_start b/storage/ndb/test/ndbapi/old_dirs/vw_test/script/client_start new file mode 100644 index 00000000000..2965be6fbb5 --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/vw_test/script/client_start @@ -0,0 +1,10 @@ +# Argument to the client program is: +# 1. ip-adress to the server +# 2. location to the raw cdr-file +# 3. nanoseconds (0-1000) between writing the buffer to the port +# 4. how many writes to the buffer before the sleep command should accur +# Argument 3 and 4 controlls the flow of the raw cdr-file to the cdrserver + +cd $VCDRPATH/bin +# ./client stat181.xxx.com /ext06/data/indata_fraud1/port2file.data.-2089540139 1000 0 & +./client xxx.xxx.xxx.xxx.xxx /export2/home/ndb/vw/data/port2file_data_-2089540139 0 100000 & diff --git a/storage/ndb/test/ndbapi/old_dirs/vw_test/utv.h b/storage/ndb/test/ndbapi/old_dirs/vw_test/utv.h new file mode 100644 index 00000000000..6f378e5595b --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/vw_test/utv.h @@ -0,0 +1,161 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include <semaphore.h> +#include <thread.h> +#include <limits.h> + +#define TESTLEV + +#define ASubscriberNumber_SIZE 16 +#define BSubscriberNumber_SIZE 29 +#define TRUE 1 +#define FALSE 0 +#define WRITE_LIMIT 100000 +#define EVER ;; +#define CONNINFO "/" +#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) + +#define BIT_1 0x1 +#define BIT_2 0x2 +#define BIT_3 0x4 +#define BIT_4 0x8 +#define BIT_5 0x10 +#define BIT_6 0x20 +#define BIT_7 0x40 +#define BIT_8 0x80 + +/*------------------------------------------------------*/ +/* record defines structure over an alarm thresholds */ +/* CallAttemptState Beskriver status på samtal */ +/* 0 - Subscriber is calling */ +/* 1 - Called part answer call */ +/* 2 - Release of call */ +/* 3-255 reserved for furter use */ +/* USED_FILEDS Indicates active fields within call */ +/* bit 1 - START_TIME */ +/* 2 - TimeForStartOfCharge */ +/* 3 - TimeForStopOfCharge */ +/* 4 - ReroutingIndicator */ +/* 5 - RINParameter */ +/* 6 - ACategory */ +/* 7 - EndOfSelectionInformation */ +/* 8 - UserToUserIndicatior */ +/* 9 - UserToUserInformation */ +/* 10 - CauseCode */ +/* 11 - ASubscriberNumber */ +/* 12 - BSubscriberNumber */ +/* 13 - RedirectingNumber */ +/* 14 - OriginalCalledNumber */ +/* 15 - LocationCode */ +/* 16 - OriginatingPointCode */ +/* 17 - DestinationPointCode */ +/* 18 - CircuitIdentificationCode */ +/* 19 - NetworkIndicator */ +/*------------------------------------------------------*/ + +struct cdr_record +{ + unsigned int USED_FIELDS; + unsigned long ClientId; + unsigned int CallIdentificationNumber; + unsigned int START_TIME; + unsigned int OurSTART_TIME; + unsigned int TimeForStartOfCharge; + unsigned int TimeForStopOfCharge; + time_t OurTimeForStartOfCharge; + time_t OurTimeForStopOfCharge; + unsigned short DestinationPointCode; + unsigned short CircuitIdentificationCode; + unsigned short OriginatingPointCode; + unsigned short ReroutingIndicator; + unsigned short RINParameter; + char NetworkIndicator; + char CallAttemptState; + char ACategory; + char EndOfSelectionInformation; + char UserToUserInformation; + char UserToUserIndicatior; + char CauseCode; + char ASubscriberNumber[ASubscriberNumber_SIZE]; + char ASubscriberNumberLength; + char TonASubscriberNumber; + char BSubscriberNumber[BSubscriberNumber_SIZE]; + char BSubscriberNumberLength; + char TonBSubscriberNumber; + char RedirectingNumber[16]; + char TonRedirectingNumber; + char OriginalCalledNumber[16]; + char TonOriginalCalledNumber; + char LocationCode[16]; + char TonLocationCode; +}; + +/*------------------------------------------------------*/ +/* Define switches for each tag */ +/*------------------------------------------------------*/ + +#define B_START_TIME 0x1 +#define B_TimeForStartOfCharge 0x2 +#define B_TimeForStopOfCharge 0x4 +#define B_ReroutingIndicator 0x8 +#define B_RINParameter 0x10 +#define B_ACategory 0x20 +#define B_EndOfSelectionInformation 0x40 +#define B_UserToUserIndicatior 0x80 +#define B_UserToUserInformation 0x100 +#define B_CauseCode 0x200 +#define B_ASubscriberNumber 0x400 +#define B_BSubscriberNumber 0x800 +#define B_RedirectingNumber 0x1000 +#define B_OriginalCalledNumber 0x2000 +#define B_LocationCode 0x4000 +#define B_OriginatingPointCode 0x8000 +#define B_DestinationPointCode 0x10000 +#define B_CircuitIdentificationCode 0x20000 + +#define B_NetworkIndicator 0x40000 +#define B_TonASubscriberNumber 0x80000 +#define B_TonBSubscriberNumber 0x100000 +#define B_TonRedirectingNumber 0x200000 +#define B_TonOriginalCalledNumber 0x4000000 +#define B_TonLocationCode 0x8000000 + +#define K_START_TIME 0xFF01 +#define K_TimeForStartOfCharge 0xFF02 +#define K_TimeForStopOfCharge 0xFF03 +#define K_ReroutingIndicator 0x13 +#define K_RINParameter 0xFC +#define K_ACategory 0x09 +#define K_EndOfSelectionInformation 0x11 +#define K_UserToUserIndicatior 0x2A +#define K_UserToUserInformation 0x20 +#define K_CauseCode 0x12 +#define K_ASubscriberNumber 0x0A +#define K_BSubscriberNumber 0x04 +#define K_RedirectingNumber 0x0B +#define K_OriginalCalledNumber 0x28 +#define K_LocationCode 0x3F +#define K_OriginatingPointCode 0xFD +#define K_DestinationPointCode 0xFE +#define K_CircuitIdentificationCode 0xFF + +#define K_NetworkIndicator 0xF0 +#define K_TonASubscriberNumber 0xF1 +#define K_TonBSubscriberNumber 0xF2 +#define K_TonRedirectingNumber 0xF3 +#define K_TonOriginalCalledNumber 0xF4 +#define K_TonLocationCode 0xF5 diff --git a/storage/ndb/test/ndbapi/old_dirs/vw_test/vcdrfunc.h b/storage/ndb/test/ndbapi/old_dirs/vw_test/vcdrfunc.h new file mode 100644 index 00000000000..3c5444d733b --- /dev/null +++ b/storage/ndb/test/ndbapi/old_dirs/vw_test/vcdrfunc.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/********************************************************/ +/* Common functions */ +/* unix_ps checks if a process is running with a */ +/* name and pid rc 0=not running */ +/* 1=Running */ +/* logname create a log filename */ +/* Parm */ +/* 1 lvl1 name */ +/* 2 lvl2 name */ +/* 3 lvl3 name */ +/* m2log Skriv log rader som moder */ +/* Parm */ +/* 1 pointer to filehandler */ +/* 2 Log text max 600 tecken */ +/* c2log Skriv log rader som barn */ +/* Parm */ +/* 1 pointer to filehandler */ +/* 2 Log text max 600 tecken */ +/* n2log Skriv log rader utan relation */ +/* Parm */ +/* 1 pointer to filehandler */ +/* 2 Log text max 600 tecken */ +/********************************************************/ + +int n2log(FILE *fi,char *text); +int m2log(FILE *fi,char *text); +int c2log(FILE *fi,char *text); +int checkchangelog(FILE* fp,char *filename); +void logname(char *filename, char *lvl1, char *lvl2, char *lvl3); +void logname_unique_day(char *filename, char *lvl1, char *lvl2, char *lvl3); +int unix_ps(char *proc_name,char *pid); +/* +int unix_ps2(char *proc_name,char *pid); +*/ +int unix_ps3(char *proc_name); +int replacetoken(const char* instring,char token,char replace); +int CompAsciiNum(char *, char *); +int CompareIt(char *,char *); +int CompCdrNum(const void *,const void *,void *); |