diff options
author | unknown <ramil@mysql.com> | 2005-02-28 19:59:38 +0400 |
---|---|---|
committer | unknown <ramil@mysql.com> | 2005-02-28 19:59:38 +0400 |
commit | f9dd79c77d3690cee26aeb0949b74ac76fccdcae (patch) | |
tree | 6f12cb96c51f12a54cc4aaabfbed0b10a5a08834 /ndb | |
parent | 3bffc522317ad18102f8a2e5079e3242b6866dcf (diff) | |
parent | c8b3d65ca26ff2be783115da2fb7c790dd4338e4 (diff) | |
download | mariadb-git-f9dd79c77d3690cee26aeb0949b74ac76fccdcae.tar.gz |
merging
mysql-test/r/ps.result:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_select.cc:
Auto merged
Diffstat (limited to 'ndb')
465 files changed, 21370 insertions, 24895 deletions
diff --git a/ndb/Makefile.am b/ndb/Makefile.am index 82f424fcfb4..32c821383e6 100644 --- a/ndb/Makefile.am +++ b/ndb/Makefile.am @@ -17,3 +17,13 @@ dist-hook: done; \ fi; \ done + +windoze: + for i in `find . -name 'Makefile.am'`; do make -C `dirname $$i` windoze-dsp; done + +windoze-dsp: + +all-windoze-dsp: windoze + find . -name '*.dsp' | grep -v SCCS | xargs unix2dos + $(top_srcdir)/ndb/config/make-win-dsw.sh | unix2dos > ndb.dsw + tar cvfz ndb-win-dsp.tar.gz ndb.dsw `find . -name '*.dsp' | grep -v SCCS` diff --git a/ndb/config/make-win-dsw.sh b/ndb/config/make-win-dsw.sh new file mode 100755 index 00000000000..b0613620f8a --- /dev/null +++ b/ndb/config/make-win-dsw.sh @@ -0,0 +1,42 @@ + +cat <<EOF +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### +EOF + +for i in `find . -name '*.dsp' | grep -v SCCS` +do + name=`basename $i | sed 's/\.dsp//'` + cat<<EOF + +Project: "$name"="`echo $i | sed 's/\//\\\/g'`" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +EOF +done + +cat<<EOF +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + +EOF diff --git a/ndb/config/type_ndbapitest.mk.am b/ndb/config/type_ndbapitest.mk.am index f1fd8286337..392c4e9fc70 100644 --- a/ndb/config/type_ndbapitest.mk.am +++ b/ndb/config/type_ndbapitest.mk.am @@ -5,7 +5,7 @@ LDADD += $(top_builddir)/ndb/test/src/libNDBT.a \ $(top_builddir)/mysys/libmysys.a \ $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@ -INCLUDES += -I$(srcdir) -I$(top_srcdir)/include \ +INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/include \ -I$(top_srcdir)/ndb/include \ -I$(top_srcdir)/ndb/include/ndbapi \ -I$(top_srcdir)/ndb/include/util \ diff --git a/ndb/config/type_ndbapitools.mk.am b/ndb/config/type_ndbapitools.mk.am index ed6d8699e05..d4eb090112d 100644 --- a/ndb/config/type_ndbapitools.mk.am +++ b/ndb/config/type_ndbapitools.mk.am @@ -11,4 +11,5 @@ INCLUDES += -I$(srcdir) -I$(top_srcdir)/include \ -I$(top_srcdir)/ndb/include/util \ -I$(top_srcdir)/ndb/include/portlib \ -I$(top_srcdir)/ndb/test/include \ - -I$(top_srcdir)/ndb/include/mgmapi + -I$(top_srcdir)/ndb/include/mgmapi \ + -I$(top_srcdir)/ndb/include/kernel diff --git a/ndb/config/win-includes b/ndb/config/win-includes new file mode 100755 index 00000000000..fa5984fd25e --- /dev/null +++ b/ndb/config/win-includes @@ -0,0 +1,8 @@ +#!/bin/sh + +dst=$1 +shift + +out=`echo $* | sed 's/-I\([^ ]*\)/\/I "\1"/g'` +sed -e "s!@includes@!$out!g" $dst > /tmp/$dst.$$ +mv /tmp/$dst.$$ $dst diff --git a/ndb/config/win-lib.am b/ndb/config/win-lib.am new file mode 100644 index 00000000000..05ac1ec8a40 --- /dev/null +++ b/ndb/config/win-lib.am @@ -0,0 +1,100 @@ +# Microsoft Developer Studio Project File - Name="@name@" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=@name@ - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "@name@.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "@name@.mak" CFG="@name@ - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "@name@ - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "@name@ - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=xicl6.exe +RSC=rc.exe + +!IF "$(CFG)" == "@name@ - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /D "WIN32" /D "DBUG_OFF" /D "_WINDOWS" /D "NDEBUG" /FD /c +# ADD BASE CPP @includes@ +# ADD CPP @includes@ +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=xilink6.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:".\lib_release\@name@.lib" +@release_libs@ + +!ELSEIF "$(CFG)" == "@name@ - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "debug" +# PROP Intermediate_Dir "debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /Gf /D "WIN32" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /FD /c +# ADD BASE CPP @includes@ +# ADD CPP @includes@ +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=xilink6.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:".\lib_debug\@name@.lib" +@debug_libs@ + +!ENDIF + +# Begin Target + +# Name "@name@ - Win32 Release" +# Name "@name@ - Win32 Debug" + +# Begin Group "Source Files" +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + +@sources@ + +# End Group + +# End Target +# End Project diff --git a/ndb/config/win-libraries b/ndb/config/win-libraries new file mode 100755 index 00000000000..c7a6fb696ee --- /dev/null +++ b/ndb/config/win-libraries @@ -0,0 +1,56 @@ +#!/bin/sh + +dst=$1 +shift + +type=$1 +shift + +add_lib(){ + echo `dirname $2`/$1/`basename $2 | sed "s/\.[l]*a/$3.lib/g"` +} + +out_rel= +out_deb= +out_tls_rel= +out_tls_deb= +for i in $* +do +# mysql VC++ project files have for some unknown reason +# choosen NOT to put libdbug.lib in $(topdir)./dbug but rather in $(topdir) +# the same goes for mysys and strings + lib=$i + case $i in + *libdbug.a | *libmysys.a | *libmystrings.a) + lib=`echo $i | sed s'!dbug\/lib!!' | sed 's!mysys\/lib!!' | sed 's!strings\/libmy!!'` + echo "Changing from $i to $lib" + ;; + esac + + if [ `echo $i | grep -c gcc` -eq 0 ] + then + out_rel="${out_rel} `add_lib lib_release $lib`" + out_deb="${out_deb} `add_lib lib_debug $lib`" + out_tls_rel="${out_tls_rel} `add_lib lib_release $lib _tls`" + out_tls_deb="${out_tls_deb} `add_lib lib_debug $lib _tls`" + fi +done + +fix(){ + echo "# ADD BASE ${type}32 $*\n# ADD ${type}32 $*\n" +} + +if [ "$out_rel" ] +then + out_rel=`fix $out_rel` + out_deb=`fix $out_deb` + out_tls_rel=`fix $out_tls_rel` + out_tls_deb=`fix $out_tls_deb` +fi + +sed -e "s!@release_libs@!$out_rel!g" \ + -e "s!@debug_libs@!$out_deb!g" \ + -e "s!@tls_release_libs@!$out_tls_rel!g" \ + -e "s!@tls_debug_libs@!$out_tls_deb!g" \ + $dst > !tmp!$dst.$$ +mv !tmp!$dst.$$ $dst diff --git a/ndb/config/win-name b/ndb/config/win-name new file mode 100755 index 00000000000..036f2b9cc2e --- /dev/null +++ b/ndb/config/win-name @@ -0,0 +1,7 @@ +#!/bin/sh + +dst=$1 +shift + +sed -e "s/@name@/`echo $1 | sed 's/\.[l]*a//g'`/g" $dst > /tmp/$dst.$$ +mv /tmp/$dst.$$ $dst diff --git a/ndb/config/win-prg.am b/ndb/config/win-prg.am new file mode 100644 index 00000000000..10a8cfbca02 --- /dev/null +++ b/ndb/config/win-prg.am @@ -0,0 +1,98 @@ +# Microsoft Developer Studio Project File - Name="mysqld" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=@name@ - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "@name@.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "@name@.mak" CFG="@name@ - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "@name@ - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "@name@ - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=xicl6.exe +RSC=rc.exe + +!IF "$(CFG)" == "@name@ - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "NDB_WIN32" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /D "NDB_WIN32" /I "../zlib" /I "../include" /I "../regex" /D "NDEBUG" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c +# ADD BASE CPP @includes@ +# ADD CPP @includes@ +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x410 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=xilink6.exe +@release_libs@ +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"release/@name@-opt.exe" +# SUBTRACT LINK32 /debug + +!ELSEIF "$(CFG)" == "@name@ - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "debug" +# PROP Intermediate_Dir "debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "NDB_WIN32" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /D "NDB_WIN32" /I "../bdb/build_win32" /I "../include" /I "../regex" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /FD /c +# ADD BASE CPP @includes@ +# ADD CPP @includes@ +# SUBTRACT CPP /Fr /YX +# ADD BASE RSC /l 0x410 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=xilink6.exe +@debug_libs@ +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"debug/@name@.exe" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "@name@ - Win32 Release" +# Name "@name@ - Win32 Debug" + +@sources@ + +# End Target +# End Project diff --git a/ndb/config/win-sources b/ndb/config/win-sources new file mode 100755 index 00000000000..a383bb0e613 --- /dev/null +++ b/ndb/config/win-sources @@ -0,0 +1,8 @@ +#!/bin/sh + +dst=$1 +shift + +out=`echo $* | sed 's!\([^ ]*\)!# Begin Source File\\\nSOURCE=\1\\\n# End Source File\\\n!g'` +sed -e "s!@sources@!$out!g" $dst > /tmp/$dst.$$ +mv /tmp/$dst.$$ $dst diff --git a/ndb/docs/Makefile.am b/ndb/docs/Makefile.am index 554b2fb256e..1399ce3b6a5 100644 --- a/ndb/docs/Makefile.am +++ b/ndb/docs/Makefile.am @@ -38,7 +38,7 @@ ndbapidoc: ndbapi.pdf ndbapi.pdf: $(noinst_HEADERS) @set -x; \ - export NDB_RELEASE=$(NDB_RELEASE) \ + export NDB_RELEASE=$(NDB_RELEASE); \ @RM@ -f ndbapi.pdf ndbapi.html; \ @RM@ -rf $(DOXYTMP) $(DOXYOUT); \ mkdir -p $(DOXYTMP) $(DOXYOUT); \ @@ -62,7 +62,7 @@ mgmapidoc: mgmapi.pdf mgmapi.pdf: $(noinst_HEADERS) @set -x; \ - export NDB_RELEASE=$(NDB_RELEASE) \ + export NDB_RELEASE=$(NDB_RELEASE); \ @RM@ -f mgmapi.pdf mgmapi.html; \ @RM@ -rf $(DOXYTMP) $(DOXYOUT); \ mkdir -p $(DOXYTMP) $(DOXYOUT); \ @@ -100,3 +100,5 @@ odbcdoc: DUMMY testdoc: DUMMY mkdir -p $(OUTDIR) cd $(top_srcdir)/ndb ; $(DOXYGEN) $(DOXYDIR)/Doxyfile.test + +windoze-dsp: diff --git a/ndb/docs/wl2077.txt b/ndb/docs/wl2077.txt new file mode 100644 index 00000000000..f5b10bb702e --- /dev/null +++ b/ndb/docs/wl2077.txt @@ -0,0 +1,48 @@ + +100' * (select 1 from T1 (1M rows) where key = rand()); +1 host, 1 ndbd, api co-hosted +results in 1000 rows / sec + + wo/reset bounds w/ rb +4.1-read committed a) 4.9 b) 7.4 +4.1-read hold lock c) 4.7 d) 6.7 + +wl2077-read committed 6.4 (+30%) 10.8 (+45%) +wl2077-read hold lock 4.6 (-1%) 6.7 (+ 0%) + +5.0-ndb batch read committed f) 50' (+680%) g) 50' (+360%) +5.0-ndb batch read hold lock h) 12' (+160%) i) 13' (+79%) + +shm-mem read committed (cmp. wl2077) a) 9.5' (+48%) b) 14' (+30%) + read hold lock c) 6.7' (+45%) d) 9.8' (+46%) + +-- Comparision e) shm +serial pk: 10.9' 20' (+83%) +batched (1000): 59' 62' (+5%) +serial uniq index: 8.4' 14' (+66%) +batched (1000): 33' 36' (+9%) +index range (1000): 186' + +---- + +load) testScanPerf -c 1 -d 1 T1 +a) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 0 -r 2 -q 0 T1 +b) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 0 -r 2 -q 1 T1 +c) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 1 -r 2 -q 0 T1 +d) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 1 -r 2 -q 1 T1 +e) testReadPerf -i 25 -c 0 -d 0 T1 +f) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 0 -r 3 -q 0 -m 1000 -i 10 T1 +g) testScanPerf -s 100000 -c 0 -d 0 -a 1 -l 0 -r 3 -q 1 -m 1000 -i 10 T1 + +--- music join 1db-co 2db-co + +4.1 13s 14s +4.1 wo/ blobs 1.7s 3.2s + +wl2077 12s 14s +wl2077 wo/ blobs 1.2s (-30%) 2.5s (-22%) + +pekka-blob-fix 1.3s + +shm 1.2s 2.0s +shm wo/ blobs 1.1s 2.0s diff --git a/ndb/home/bin/cvschk b/ndb/home/bin/cvschk deleted file mode 100755 index 4510cc30888..00000000000 --- a/ndb/home/bin/cvschk +++ /dev/null @@ -1,569 +0,0 @@ -#!/usr/bin/perl -w -# -# cvschk -- fast offline check for new files and modifications of files - -# cvschk : A perl program which checks the status of the CVS controlled -# files and gives an ASCII table sorted after the status of files. -# -# If you have used CVS, then you know that it is hard to -# get a good overview the CVS-status of the files in you -# directories. Any new files? Any files changes? -# cvschk will help the programmer get the overview in the -# situation, where we do not have access to the CVS repository. -# -# Note that the program does only local checks of the files -# If you have fast access to the CVS repositiory, then consider -# the cvsstat-program - which additionally can tell if other -# people have made newer versions of the files. -# -# The program requires Perl 5.004 (maybe previous versions also work). -# -# It is tuned to parse the output of cvs(1) version 1.9. -# Earlier and later versions may require modifications to the script. -# -# ** Note that the first line might be wrong depending ** -# ** on the location of your perl program. ** -# -# Sample output: -# The directory ./mytempdir is not under CVS control -# -# Changed files -# --------------- -# ./cvs2html -# ./cvschk -# ./cvsstat -# -# New files -# --------------- -# ./.#cvschk -# ./XX -# ./cvs2html.ok -# -# Deleted files -# --------------- -# (none) - -# Changelog: -# -# Ver Date Author Changelog -# --- ---------- -------------------- ------------------------------------- -# 1.12 2002-01-04 Michael Kohne Fixed a $foo=<> warning for -# 5.004_01 with defined($foo=<>) -# Added a --tabular|-t switch -# -# 1.11 2001-12-27 Michael Kohne Added cvsignore functionality -# Handling of 'dummy timestamp' -# Handling of 'Result of Merge' -# -# 1.10 2001-11-06 Michael Kohne Added -r and -l options -# -# 1.9 2001-08-03 Lars G. T. Jørgensen Hack to allow special entry-line -# -# 1.8 2001-06-07 Peter Toft Back to the same as 1.6 -# CVS is my friend -# -# 1.7 2001-06-04 Peter Toft Peter was very tired and -# applied a wrong patch - -# version 1.7 is crap -# -# 1.6 2000-12-17 Peter Toft Better description added -# -# 1.5 2000-11-04 Peter Toft URL of cvsstat changed -# -# 1.4 2000-09-20 Peter Toft Must show deleted files also -# as the default -# -# 1.3 2000-08-08 Ole Tange and Initial version -# Peter Toft -# ---- ---------- -------------------- ------------------------------------- -# -# ----------------------------------------------------------------------------- -# -# This program is protected by the GPL, and all modifications of -# general interest should be emailed to the maintainer (pto@sslug.dk). -# -# This program also uses code parts from cvsstat -# (same homepage as cvschk) -# -# Copyright 2000,2001 by Peter Toft <pto@sslug.dk> and Ole Tange <ole@tange.dk> -# as well as -# Lars G. T. Jørgensen <larsj@diku.dk> -# -# The URL of the home page of cvschk is shown below. - - -use Time::Local; -use strict; -use Getopt::Long; - -my $startdir = "."; - -my $debug = 0; -my (%files,%filesok,%seen,%skip); - - -# Michael Kohne 12/16/01 -# -# Simulation of .cvsignore as CVS does it... -# -# using .cvsignore handling makes cvschk take from 2 to 3 times -# longer to run over the same set of files. -# in my tests, disabling cvsignore altogether, cvschk takes .2 -# seconds on my working directory. Adding cvsignore,takes -# .4 seconds. -# Note that I do not use individual .cvsignore files - if there -# are a lot of them in your directory tree, it will add run time -# -# variables used for .cvsignore handling -my $initcvsignoreregex;# regex holding all startup cvsignore pattersn (no ()) -my $cvsignoreregex;# one regex holding all current cvsignore patterns -my $disable_cvsignore=0;# set to 1 to disable cvsignore emulation - # (available in case it's REALLY screwed up) -my $disable_ind_cvsignore=0;# set to 1 to disable finding .cvsignore files - # in each directory. -my $debug_cvsignore = 0; # For debugging .cvsignore problems - -my %mon; -@mon{qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)}= - 0..11; # Perl months are 0 .. 11 - -my ($version) = ('$Revision: 1.12 $ ' =~ /^\$\w+: (.*) \$ $/); -my $URL = "http://cvs.sslug.dk/cvs2html"; -my $version_line = "cvschk version $version (see $URL)\n"; - -my $opt_all; -my $restrict; -my $local; -my $tabular; - -my $opt_restrict; - -sub show_version {print $version_line} - -sub die_version {die $version_line} - -sub die_usage { - my $bundled = ($] > 5.00399 - ? "can be bundled" - : "can't be bundled, because your Perl is too old"); - die <<END_OF_USAGE; # Help in the style of GNU `ls --help' or `make --help' -Usage: $0 [OPTION]... - Show the CVS status of FILEs (the current directory by default), - traversing directories recursively and telling if new files exist - in the repository. -Options: - -a, --all Show all statistics, including the names of files that - are up to date, used tags, ignored patterns and more - -r, --restrict Don't show the names of the unknown files - (useful if you have many temporary files) - -t, --tabular Show one file per line, each preceeded with a status word, - Sorted by filename. - -l, --local Don't descend into sub-directories - -d, --debug Debug info - -h, --help Show this help end exit immediately - -V, --version Show the version line and exit immediately -The one-letter options $bundled. -END_OF_USAGE -} - -sub die_help {show_version; die_usage} - -# Let `-ar' mean `-a -r' and require `--all' (or -a) instead of `-all'. -if ($] > 5.00399) { # This requires 5.004, so silently skip it for older Perls. - eval {Getopt::Long::config("bundling")}; # avoid 5.003 compilation error - warn $@ if $@; # For Perl 5.004+ we do want to see any compilation error -} - - -GetOptions( "all|a" => \$opt_all, - "tabular|t" => \$tabular, - "restrict|r" => \$restrict, - "local|l" => \$local, - "help|h" => \&die_help, - "debug|d" => \$debug, - "version|V" => \&die_version, - ) or die_usage; - -sub cvs_changed_in_dir($); #define prototype (for recursion) - -# functions for .cvsignore handling - -# converts a given filename pattern -# (of the sort that sh(1) takes) to -# a perl regex of similar meaning. -# -# It works by doing the following: -# -# change: -# . to \. -# $ to \$ -# * to .* -# ? to . -# -sub fpat_to_regex($) -{ - my $fexp; - $fexp = shift; - $fexp =~ s/\./\\\./g;#change . to \. - $fexp =~ s/\$/\\\$/g;#change dollar sign to \dollar sign - $fexp =~ s/\*/.*/g;# change * to .* - $fexp =~ s/\?/./g; # change ? to . - return $fexp; -} - -# copy the input list to one single regex, -# items seperated by | symbols. -# return the regex string -sub do_regex_convert -{ - my $rx = ""; - my $first = 1;#true for first element only - - - # convert each element of cvsignore into a regex - # this makes the patterns usable in perl - my $cp; - foreach $cp (@_) { - if (not $first) { $rx = $rx . "|"; } - if ($first) { $first = 0; } - $rx = $rx . fpat_to_regex($cp); - } - - return $rx; -} - -# first parameter is a reference to the array -# to be loaded -# the rest of the parameters are just items -# that need to be loaded into the array. -# Note that if a ! is found, the list is -# emptied, then further items are added. -# returns true if a ! was found -sub load_list_from_list -{ - my $arref = shift;# get reference to array from front - my $item; - my $ret=0;#false means no ! found - - chomp @_;#kill newlines - foreach $item (@_) { - $item =~ s/^\s*(.*?)\s*$/$1/;#kill leading/trailing whitespace - if ($item) { # empty string is false - push @$arref,$item; - } - if ($item eq "!") { - @$arref = ();# '!' causes list to clear - $ret = 1;# ! found - } - } - - return $ret; -} - -# loads the given list with lines from the -# specified file. Note that if a '!' is found -# all prior patterns are removed from the list -# before the following patterns are loaded -# first param is the filename, -# second param is a reference to an array -# that the data is to go into -# returns true if a ! was found -sub load_list_from_file -{ - my @inlist; - my $fname = shift;#filename to read from - #if (not -e $fname) { return; } - my $arref = shift;#array to store into - open CVSIGNORE,"$fname" or return;#file might not exist, that's OK - @inlist = <CVSIGNORE>; - close CVSIGNORE; - return load_list_from_list($arref,@inlist); -} - -# loads $cvsignoreregex from -# $initcvsignoreregex and the .cvsignore file -# in the local directory -sub load_cvsignore -{ - if ($disable_ind_cvsignore) {return;}#don't look for local .cvsignore files - if ($disable_cvsignore) {return;}#don't do anything - - my $dir = shift; - my @cvsignore; - - # bang will be true if a ! was found. In such cases, I need - # to not use the pre-exisitng regex list. - my $bang = load_list_from_file("$dir/.cvsignore",\@cvsignore); - - # if we get a local cvsignore list, then... - my $rx = do_regex_convert(@cvsignore); - if ($rx) { - $cvsignoreregex = "("; - if (not $bang) {$cvsignoreregex = $cvsignoreregex . $initcvsignoreregex . "|";} - $cvsignoreregex = $cvsignoreregex . $rx . ")"; - } else { - if ($bang) {$cvsignoreregex = "";} - else {$cvsignoreregex = "(" . $initcvsignoreregex . ")";} - } - - if ($debug_cvsignore) {print $dir,":",$cvsignoreregex, "\n";} -} - - -# loads all of the cvsignore patterns that -# can be loaded at script startup -sub load_initial_cvsignore() -{ - #load the default patterns - # (taken from http://www.gnu.org/manual/cvs-1.9/html_node/cvs_141.html#IDX399) - # - # this gives you the patterns that cvs normally starts with - my @initcvsignore; - push @initcvsignore,("RCS"); - push @initcvsignore,("SCCS"); - push @initcvsignore,("CVS"); - push @initcvsignore,("CVS.adm"); - push @initcvsignore,("RCSLOG"); - push @initcvsignore,("cvslog.*"); - push @initcvsignore,("tags"); - push @initcvsignore,("TAGS"); - push @initcvsignore,(".make.state"); - push @initcvsignore,(".nse_depinfo"); - push @initcvsignore,("*~"); - push @initcvsignore,("\#*"); - push @initcvsignore,(".\#*"); - push @initcvsignore,("\,*"); - push @initcvsignore,("_\$\*"); - push @initcvsignore,("*\$"); - push @initcvsignore,("*.old"); - push @initcvsignore,("*.bak"); - push @initcvsignore,("*.BAK"); - push @initcvsignore,("*.orig"); - push @initcvsignore,("*.rej"); - push @initcvsignore,(".del-*"); - push @initcvsignore,("*.a"); - push @initcvsignore,("*.olb"); - push @initcvsignore,("*.o"); - push @initcvsignore,("*.obj"); - push @initcvsignore,("*.so"); - push @initcvsignore,("*.exe"); - push @initcvsignore,("*.Z"); - push @initcvsignore,("*.elc"); - push @initcvsignore,("*.ln"); - push @initcvsignore,("core"); - - - # now, load (in proper order!) - # each of the possible cvsignore files - - # there are 4 possible .cvsignore files: - - # $CVSROOT/CVSROOT/cvsignore - # ~/.cvsignore - # $CVSIGNORE environment variable - # .cvsignore in current directory - - # The first (CVSROOT/cvsignore) would require calling cvs, so - # we won't do that one. - # The last (.cvsignore in current directory) is done - # for each directory. It's handled in the load_cvsignore routine. - - # ~/.cvsignore - my @inlist; - my $item; - my $HOME=$ENV{"HOME"}; - if (not $HOME) {$HOME = ".";} - load_list_from_file("$HOME/.cvsignore",\@initcvsignore); - - # $CVSIGNORE environment variable - my $igstr = $ENV{"CVSIGNORE"}; # get env var - if ($igstr) { - my @iglist = split(/\s+/, $igstr); #if it exists, convert to list - load_list_from_list(\@initcvsignore,@iglist); - } - - # now that @initcvsignore is setup, - # turn it into a regex string - $initcvsignoreregex = do_regex_convert(@initcvsignore); - - # now preset the cvsignore regex string to match - # @initcvsignore. That way, if we aren't using local - # cvsignore files, we do nothing. - $cvsignoreregex = "(" . $initcvsignoreregex . ")"; -} -# routine to see if the given name is in the cvsignore regex -# returns true if it is, false if it's not -sub ignore_file($) -{ - #allow user to disable the cvsignore stuff - if ($disable_cvsignore) {return 0;} - if (not $cvsignoreregex) {return 0;}# if regex is empty, nothing matches the regex - my $filename = shift; - - if ($debug_cvsignore) {print "ignore_file:",$filename,"\n";} - - if ($filename =~ $cvsignoreregex) { - if ($debug_cvsignore) {print $filename," matches\n";} - return 1; - } - - if ($debug_cvsignore) {print $filename," doesn't match\n";} - return 0; -} - -sub cvs_changed_in_dir($) { - my $dir = shift; - - my ($line,$filename,$version,$mtime,$date, - $dir_filename,$cvstime,@subdirs, - @new_in_dir,$i); - - # Examine status of files in CVS/Entries - if(not open(ENTRIES,"$dir/CVS/Entries")) { - if ($tabular) { - push @{$files{Unknown}}, $dir; - } - else { - warn "The directory $dir is not under CVS control\n"; - } - } else { - load_cvsignore($dir);#load up proper cvsignore for given directory - - while(defined ($line=<ENTRIES>)) { - # Parse CVS/Entries-line - $line=~m!^/(.*)/(.*)/(.*)/.*/! or do { - $debug and warn("Skipping entry-line $line"); - next; - }; - ($filename,$version,$date) = ($1,$2,$3); - $dir_filename=$dir."/".$filename; - - # Mark this file as seen - $seen{$dir_filename}=1; - - # if not exists: Deleted - if(not -e $dir_filename) { - push @{$files{Deleted}}, $dir_filename; next; - } - # if dir: save name for recursion - -d $dir_filename and do { - push @subdirs, $dir_filename; next; - }; - - # modification time of $dir_filename - $mtime= (stat $dir_filename)[9]; - - - if($date eq "dummy timestamp") { - # dummy timestamp means it's new to the repository. - push @{$files{Changed}}, $dir_filename; - if ($debug) { - print "$dir_filename is changed\n"; - } - } - elsif($date eq "Result of merge") { - # result of merge means it's changed, then updated. - push @{$files{Changed}}, $dir_filename; - if ($debug) { - print "$dir_filename is changed\n"; - } - } - elsif(not - $date=~/... (...)\s+(\d+)\s+(\d+):(\d+):(\d+) (\d{4})/) - { - #bogus entry in Entires - warn "Warning: $dir_filename -> '$date' ". - "not in ctime(3) format\n"; - } else { - $cvstime=timegm($5,$4,$3,$2,$mon{$1},$6); - if($cvstime != $mtime) { - push @{$files{Changed}}, $dir_filename; - if ($debug) { - print "$dir_filename is changed\n"; - } - } else { - push @{$files{Unchanged}}, $dir_filename; - if ($debug) { - print "$dir_filename is Unchanged\n"; - } - } - } - } - close ENTRIES; - - # Locate any new files/dirs - if(not opendir(D,$dir)) { - warn("Cannot open $dir"); - @new_in_dir= (); - } else { - @skip{qw(. .. CVS)}=1..3; # Filenames that that we want to ignore - #(note: these are exact filenames) - @new_in_dir= - (grep { not $seen{$_} } # files we have not already processed - map { $dir."/".$_ } # map from file to dir/file - grep { not ignore_file($_) } # ignore files in the cvsignore list - grep { not $skip{$_} } # skip files to be ignored - readdir(D)); - closedir(D); - } - - # Remember new files (actually non-directories) - push @{$files{New}}, grep { not -d $_ } @new_in_dir; - if ($debug) { print "@{$files{New}} are new in $dir\n"; } - - # Remember new subdirs - push @subdirs, grep { -d $_ } @new_in_dir; - - # Recurse all subdirs - if (not $local) { - for $i (@subdirs) { cvs_changed_in_dir($i); } - } - } -} - -sub print_status() -{ - my $k; - my %show_these_states = ("Changed" => 1); - if(not $restrict) { - $show_these_states{"New"} = 1; - $show_these_states{"Deleted"} = 1; - } - - if($opt_all) { $show_these_states{"Unchanged"} = 1; } - - if ($tabular) { - my %allfiles; # key: filesname, value: state - my ($file, $state, $statefiles); - - $show_these_states{"Unknown"} = 1; - while (($state, $statefiles) = each %files) { - for my $f (@{$statefiles}) { - $allfiles{$f} = $state; - } - } - for $file (sort keys %allfiles) { - $state = $allfiles{$file}; - printf("%-10s %s\n", $state, $file) if $show_these_states{$state}; - } - } - else { - print "\n"; - for $k (keys %show_these_states) { - if(not $files{$k} or not @{$files{$k}}) { - # no files - $files{$k}=["(none)"]; - } - print("$k files\n", - "---------------\n", - map { "$_\n" } sort @{$files{$k}}); - print "\n"; - } - } -} - -load_initial_cvsignore(); -if ($debug_cvsignore) {print "initial regex:",$cvsignoreregex,"\n";} -cvs_changed_in_dir($startdir); -print_status(); - diff --git a/ndb/include/Makefile.am b/ndb/include/Makefile.am index 7b3f80b5560..ef4e9552566 100644 --- a/ndb/include/Makefile.am +++ b/ndb/include/Makefile.am @@ -2,11 +2,13 @@ include $(top_srcdir)/ndb/config/common.mk.am ndbinclude_HEADERS = \ +ndb_init.h \ ndb_types.h \ ndb_version.h ndbapiinclude_HEADERS = \ ndbapi/ndbapi_limits.h \ +ndbapi/ndb_opt_defaults.h \ ndbapi/Ndb.hpp \ ndbapi/NdbApi.hpp \ ndbapi/NdbConnection.hpp \ @@ -29,16 +31,18 @@ ndbapi/ndberror.h mgmapiinclude_HEADERS = \ mgmapi/mgmapi.h \ -mgmapi/mgmapi_debug.h +mgmapi/mgmapi_debug.h \ +mgmapi/mgmapi_config_parameters.h \ +mgmapi/mgmapi_config_parameters_debug.h noinst_HEADERS = \ ndb_global.h \ -ndb_net.h \ -mgmapi/mgmapi_config_parameters.h \ -mgmapi/mgmapi_config_parameters_debug.h +ndb_net.h EXTRA_DIST = debugger editline kernel logger mgmcommon \ portlib transporter util dist-hook: -rm -rf `find $(distdir) -type d -name SCCS` + +windoze-dsp: diff --git a/ndb/include/debugger/EventLogger.hpp b/ndb/include/debugger/EventLogger.hpp index 686989089ae..ddf21b79f5f 100644 --- a/ndb/include/debugger/EventLogger.hpp +++ b/ndb/include/debugger/EventLogger.hpp @@ -48,6 +48,10 @@ public: static const EventRepLogLevelMatrix matrix[]; static const Uint32 matrixSize; + static int event_lookup(int eventType, + LogLevel::EventCategory &cat, + Uint32 &threshold, + Logger::LoggerLevel &severity); }; /** diff --git a/ndb/include/debugger/GrepError.hpp b/ndb/include/debugger/GrepError.hpp index ab6a7b272a5..beedbd95c80 100644 --- a/ndb/include/debugger/GrepError.hpp +++ b/ndb/include/debugger/GrepError.hpp @@ -24,8 +24,8 @@ */ class GrepError { public: - enum Code { - NO_ERROR = 0, + enum GE_Code { + GE_NO_ERROR = 0, SUBSCRIPTION_ID_NOMEM = 1, SUBSCRIPTION_ID_NOT_FOUND = 2, SUBSCRIPTION_ID_NOT_UNIQUE = 3, @@ -82,12 +82,12 @@ public: }; struct ErrorDescription { - Code errCode; + GE_Code errCode; const char * name; }; static const ErrorDescription errorDescriptions[]; static const Uint32 noOfErrorDescs; - static const char * getErrorDesc(GrepError::Code err); + static const char * getErrorDesc(GrepError::GE_Code err); }; diff --git a/ndb/include/kernel/AttributeHeader.hpp b/ndb/include/kernel/AttributeHeader.hpp index b807b4ef4f1..ed9085301be 100644 --- a/ndb/include/kernel/AttributeHeader.hpp +++ b/ndb/include/kernel/AttributeHeader.hpp @@ -17,7 +17,6 @@ #ifndef ATTRIBUTE_HEADER #define ATTRIBUTE_HEADER -#include <new> /** * @class AttributeHeader * @brief Header passed in front of every attribute value in AttrInfo signal diff --git a/ndb/include/kernel/LogLevel.hpp b/ndb/include/kernel/LogLevel.hpp index 467f0604edd..3c2f349e0e1 100644 --- a/ndb/include/kernel/LogLevel.hpp +++ b/ndb/include/kernel/LogLevel.hpp @@ -73,7 +73,7 @@ public: /** * Note level is valid as 0-15 */ - void setLogLevel(EventCategory ec, Uint32 level = 7); + int setLogLevel(EventCategory ec, Uint32 level = 7); /** * Get the loglevel (0-15) for a category @@ -89,7 +89,7 @@ public: return memcmp(this, &l, sizeof(* this)) == 0; } - LogLevel& operator=(const class EventSubscribeReq & req); + LogLevel& operator=(const struct EventSubscribeReq & req); private: /** @@ -119,10 +119,14 @@ LogLevel::clear(){ } inline -void +int LogLevel::setLogLevel(EventCategory ec, Uint32 level){ - assert(ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES); - logLevelData[ec] = (Uint8)level; + if (ec >= 0 && (Uint32) ec < LOGLEVEL_CATEGORIES) + { + logLevelData[ec] = (Uint8)level; + return 0; + } + return 1; } inline diff --git a/ndb/include/kernel/ndb_limits.h b/ndb/include/kernel/ndb_limits.h index 88fcff22da7..48a56c019bb 100644 --- a/ndb/include/kernel/ndb_limits.h +++ b/ndb/include/kernel/ndb_limits.h @@ -117,4 +117,9 @@ */ #define NDB_BLOB_HEAD_SIZE 2 /* sizeof(NdbBlob::Head) >> 2 */ +/* + * Long signals + */ +#define NDB_SECTION_SEGMENT_SZ 60 + #endif diff --git a/ndb/include/kernel/signaldata/AlterIndx.hpp b/ndb/include/kernel/signaldata/AlterIndx.hpp index 1f464ded010..f5ad835b6f3 100644 --- a/ndb/include/kernel/signaldata/AlterIndx.hpp +++ b/ndb/include/kernel/signaldata/AlterIndx.hpp @@ -181,6 +181,7 @@ public: enum ErrorCode { NoError = 0, Busy = 701, + NotMaster = 702, IndexNotFound = 4243, IndexExists = 4244, BadRequestType = 4247, @@ -200,8 +201,10 @@ private: //Uint32 m_indexVersion; Uint32 m_errorCode; Uint32 m_errorLine; - Uint32 m_errorNode; - + union { + Uint32 m_errorNode; + Uint32 masterNodeId; // if NotMaster + }; public: AlterIndxConf* getConf() { return &m_conf; diff --git a/ndb/include/kernel/signaldata/ArbitSignalData.hpp b/ndb/include/kernel/signaldata/ArbitSignalData.hpp index f255b8dcbbe..34b73644a13 100644 --- a/ndb/include/kernel/signaldata/ArbitSignalData.hpp +++ b/ndb/include/kernel/signaldata/ArbitSignalData.hpp @@ -94,13 +94,14 @@ public: // arbitration result LoseNodes = 41, // lose on ndb node count - WinGroups = 42, // we win, no need for arbitration - LoseGroups = 43, // we lose, missing node group - Partitioning = 44, // possible network partitioning - WinChoose = 45, // positive reply - LoseChoose = 46, // negative reply - LoseNorun = 47, // arbitrator required but not running - LoseNocfg = 48, // arbitrator required but none configured + WinNodes = 42, // win on ndb node count + WinGroups = 43, // we win, no need for arbitration + LoseGroups = 44, // we lose, missing node group + Partitioning = 45, // possible network partitioning + WinChoose = 46, // positive reply + LoseChoose = 47, // negative reply + LoseNorun = 48, // arbitrator required but not running + LoseNocfg = 49, // arbitrator required but none configured // general error codes ErrTicket = 91, // invalid arbitrator-ticket diff --git a/ndb/include/kernel/signaldata/BackupImpl.hpp b/ndb/include/kernel/signaldata/BackupImpl.hpp index 1872069daa7..2ac91570aad 100644 --- a/ndb/include/kernel/signaldata/BackupImpl.hpp +++ b/ndb/include/kernel/signaldata/BackupImpl.hpp @@ -78,15 +78,15 @@ public: STATIC_CONST( SignalLength = 3 ); enum ErrorCode { - Undefined = 200, - FailedToAllocateBuffers = 202, - FailedToSetupFsBuffers = 203, - FailedToAllocateTables = 204, - FailedInsertFileHeader = 205, - FailedInsertTableList = 206, - FailedAllocateTableMem = 207, - FailedToAllocateFileRecord = 208, - FailedToAllocateAttributeRecord = 209 + Undefined = 1340, + FailedToAllocateBuffers = 1342, + FailedToSetupFsBuffers = 1343, + FailedToAllocateTables = 1344, + FailedInsertFileHeader = 1345, + FailedInsertTableList = 1346, + FailedAllocateTableMem = 1347, + FailedToAllocateFileRecord = 1348, + FailedToAllocateAttributeRecord = 1349 }; private: Uint32 backupId; diff --git a/ndb/include/kernel/signaldata/BackupSignalData.hpp b/ndb/include/kernel/signaldata/BackupSignalData.hpp index 42eb8464d53..fb018026a49 100644 --- a/ndb/include/kernel/signaldata/BackupSignalData.hpp +++ b/ndb/include/kernel/signaldata/BackupSignalData.hpp @@ -119,12 +119,13 @@ public: private: enum ErrorCodes { - Undefined = 100, - IAmNotMaster = 101, - OutOfBackupRecord = 102, - OutOfResources = 103, - SequenceFailure = 104, - BackupDefinitionNotImplemented = 105 + Undefined = 1300, + IAmNotMaster = 1301, + OutOfBackupRecord = 1302, + OutOfResources = 1303, + SequenceFailure = 1304, + BackupDefinitionNotImplemented = 1305, + CannotBackupDiskless = 1306 }; Uint32 senderData; Uint32 errorCode; @@ -232,13 +233,13 @@ public: STATIC_CONST( SignalLength = 3 ); enum RequestType { - ClientAbort = 1, - BackupComplete = 2, - BackupFailure = 3, // General backup failure coordinator -> slave - LogBufferFull = 4, // slave -> coordinator - FileOrScanError = 5, // slave -> coordinator - BackupFailureDueToNodeFail = 6, // slave -> slave - OkToClean = 7 // master -> slave + ClientAbort = 1321, + BackupComplete = 1322, + BackupFailure = 1323, // General backup failure coordinator -> slave + LogBufferFull = 1324, // slave -> coordinator + FileOrScanError = 1325, // slave -> coordinator + BackupFailureDueToNodeFail = 1326, // slave -> slave + OkToClean = 1327 // master -> slave }; private: Uint32 requestType; diff --git a/ndb/include/kernel/signaldata/BuildIndx.hpp b/ndb/include/kernel/signaldata/BuildIndx.hpp index 29dfaeb79a6..a6ea84c5ea0 100644 --- a/ndb/include/kernel/signaldata/BuildIndx.hpp +++ b/ndb/include/kernel/signaldata/BuildIndx.hpp @@ -234,6 +234,7 @@ public: enum ErrorCode { NoError = 0, Busy = 701, + NotMaster = 702, BadRequestType = 4247, InvalidPrimaryTable = 4249, InvalidIndexType = 4250, @@ -241,9 +242,8 @@ public: AllocationFailure = 4252, InternalError = 4346 }; - STATIC_CONST( SignalLength = BuildIndxConf::SignalLength + 1 ); + STATIC_CONST( SignalLength = BuildIndxConf::SignalLength + 2 ); -private: //Uint32 m_userRef; //Uint32 m_connectionPtr; //Uint32 m_requestInfo; @@ -252,6 +252,7 @@ private: //Uint32 m_indexId; BuildIndxConf m_conf; Uint32 m_errorCode; + Uint32 masterNodeId; public: BuildIndxConf* getConf() { diff --git a/ndb/include/kernel/signaldata/CreateEvnt.hpp b/ndb/include/kernel/signaldata/CreateEvnt.hpp index 65a07c122a2..e911fa36ce6 100644 --- a/ndb/include/kernel/signaldata/CreateEvnt.hpp +++ b/ndb/include/kernel/signaldata/CreateEvnt.hpp @@ -475,14 +475,14 @@ struct CreateEvntRef { } }; inline bool CreateEvntRef::isTemporary() const -{ return (errorCode & CreateEvntRef::Temporary) > 0; }; +{ return (errorCode & CreateEvntRef::Temporary) > 0; } inline void CreateEvntRef::setTemporary() -{ errorCode |= CreateEvntRef::Temporary; }; +{ errorCode |= CreateEvntRef::Temporary; } inline CreateEvntRef::ErrorCode CreateEvntRef::setTemporary(ErrorCode ec) { return (CreateEvntRef::ErrorCode) - (errorCode = ((Uint32) ec | (Uint32)CreateEvntRef::Temporary)); }; + (errorCode = ((Uint32) ec | (Uint32)CreateEvntRef::Temporary)); } inline CreateEvntRef::ErrorCode CreateEvntRef::makeTemporary(ErrorCode ec) { return (CreateEvntRef::ErrorCode) - ( (Uint32) ec | (Uint32)CreateEvntRef::Temporary ); }; + ( (Uint32) ec | (Uint32)CreateEvntRef::Temporary ); } #endif diff --git a/ndb/include/kernel/signaldata/CreateIndx.hpp b/ndb/include/kernel/signaldata/CreateIndx.hpp index 3e277b38dea..5563f80a555 100644 --- a/ndb/include/kernel/signaldata/CreateIndx.hpp +++ b/ndb/include/kernel/signaldata/CreateIndx.hpp @@ -184,7 +184,7 @@ public: /** * CreateIndxRef. */ -class CreateIndxRef { +struct CreateIndxRef { friend bool printCREATE_INDX_REF(FILE*, const Uint32*, Uint32, Uint16); public: @@ -210,7 +210,6 @@ public: InvalidAttributeOrder = 4255 }; -private: CreateIndxConf m_conf; //Uint32 m_userRef; //Uint32 m_connectionPtr; @@ -221,8 +220,10 @@ private: //Uint32 m_indexVersion; Uint32 m_errorCode; Uint32 m_errorLine; - Uint32 m_errorNode; - + union { + Uint32 m_errorNode; + Uint32 masterNodeId; // If NotMaster + }; public: CreateIndxConf* getConf() { return &m_conf; diff --git a/ndb/include/kernel/signaldata/CreateTrig.hpp b/ndb/include/kernel/signaldata/CreateTrig.hpp index a8de9e50dd4..62627256dcf 100644 --- a/ndb/include/kernel/signaldata/CreateTrig.hpp +++ b/ndb/include/kernel/signaldata/CreateTrig.hpp @@ -288,6 +288,7 @@ public: enum ErrorCode { NoError = 0, Busy = 701, + NotMaster = 702, TriggerNameTooLong = 4236, TooManyTriggers = 4237, TriggerNotFound = 4238, @@ -310,8 +311,10 @@ private: //Uint32 m_triggerInfo; Uint32 m_errorCode; Uint32 m_errorLine; - Uint32 m_errorNode; - + union { + Uint32 m_errorNode; + Uint32 masterNodeId; // When NotMaster + }; public: CreateTrigConf* getConf() { return &m_conf; diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index 6b4a3f34553..a2f9fcc9799 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -51,7 +51,6 @@ class DictTabInfo { friend class Trix; friend class DbUtil; // API - friend class Table; friend class NdbSchemaOp; /** @@ -303,15 +302,19 @@ public: ExtBigunsigned = NdbSqlUtil::Type::Bigunsigned, ExtFloat = NdbSqlUtil::Type::Float, ExtDouble = NdbSqlUtil::Type::Double, - ExtDecimal = NdbSqlUtil::Type::Decimal, + ExtOlddecimal = NdbSqlUtil::Type::Olddecimal, + ExtOlddecimalunsigned = NdbSqlUtil::Type::Olddecimalunsigned, ExtChar = NdbSqlUtil::Type::Char, ExtVarchar = NdbSqlUtil::Type::Varchar, ExtBinary = NdbSqlUtil::Type::Binary, ExtVarbinary = NdbSqlUtil::Type::Varbinary, ExtDatetime = NdbSqlUtil::Type::Datetime, - ExtTimespec = NdbSqlUtil::Type::Timespec, + ExtDate = NdbSqlUtil::Type::Date, ExtBlob = NdbSqlUtil::Type::Blob, - ExtText = NdbSqlUtil::Type::Text + ExtText = NdbSqlUtil::Type::Text, + ExtTime = NdbSqlUtil::Type::Time, + ExtYear = NdbSqlUtil::Type::Year, + ExtTimestamp = NdbSqlUtil::Type::Timestamp }; // Attribute data interpretation @@ -409,9 +412,20 @@ public: AttributeSize = DictTabInfo::a64Bit; AttributeArraySize = AttributeExtLength; return true; - case DictTabInfo::ExtDecimal: - // not yet implemented anywhere - break; + case DictTabInfo::ExtOlddecimal: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = + (1 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) * + AttributeExtLength; + return true; + case DictTabInfo::ExtOlddecimalunsigned: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = + (0 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) * + AttributeExtLength; + return true; case DictTabInfo::ExtChar: case DictTabInfo::ExtBinary: AttributeType = DictTabInfo::StringType; @@ -429,10 +443,10 @@ public: AttributeSize = DictTabInfo::an8Bit; AttributeArraySize = 8 * AttributeExtLength; return true; - case DictTabInfo::ExtTimespec: + case DictTabInfo::ExtDate: AttributeType = DictTabInfo::StringType; AttributeSize = DictTabInfo::an8Bit; - AttributeArraySize = 12 * AttributeExtLength; + AttributeArraySize = 3 * AttributeExtLength; return true; case DictTabInfo::ExtBlob: case DictTabInfo::ExtText: @@ -441,6 +455,21 @@ public: // head + inline part [ attr precision lower half ] AttributeArraySize = (NDB_BLOB_HEAD_SIZE << 2) + (AttributeExtPrecision & 0xFFFF); return true; + case DictTabInfo::ExtTime: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = 3 * AttributeExtLength; + return true; + case DictTabInfo::ExtYear: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = 1 * AttributeExtLength; + return true; + case DictTabInfo::ExtTimestamp: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = 4 * AttributeExtLength; + return true; }; return false; } diff --git a/ndb/include/kernel/signaldata/DropIndx.hpp b/ndb/include/kernel/signaldata/DropIndx.hpp index 0c0cf31aec8..fd2ea7f0b7b 100644 --- a/ndb/include/kernel/signaldata/DropIndx.hpp +++ b/ndb/include/kernel/signaldata/DropIndx.hpp @@ -160,7 +160,7 @@ public: /** * DropIndxRef. */ -class DropIndxRef { +struct DropIndxRef { friend bool printDROP_INDX_REF(FILE*, const Uint32*, Uint32, Uint16); public: @@ -168,6 +168,7 @@ public: NoError = 0, InvalidIndexVersion = 241, Busy = 701, + NotMaster = 702, IndexNotFound = 4243, BadRequestType = 4247, InvalidName = 4248, @@ -175,7 +176,6 @@ public: }; STATIC_CONST( SignalLength = DropIndxConf::SignalLength + 3 ); -private: DropIndxConf m_conf; //Uint32 m_userRef; //Uint32 m_connectionPtr; @@ -185,8 +185,10 @@ private: //Uint32 m_indexVersion; Uint32 m_errorCode; Uint32 m_errorLine; - Uint32 m_errorNode; - + union { + Uint32 m_errorNode; + Uint32 masterNodeId; + }; public: DropIndxConf* getConf() { return &m_conf; diff --git a/ndb/include/kernel/signaldata/FsCloseReq.hpp b/ndb/include/kernel/signaldata/FsCloseReq.hpp index c42afa143e6..10d094fb30b 100644 --- a/ndb/include/kernel/signaldata/FsCloseReq.hpp +++ b/ndb/include/kernel/signaldata/FsCloseReq.hpp @@ -75,7 +75,7 @@ inline void FsCloseReq::setRemoveFileFlag(UintR & fileflag, bool removefile){ // ASSERT_BOOL(removefile, "FsCloseReq::setRemoveFileFlag"); - if (removefile == true) + if (removefile) fileflag = 1; else fileflag = 0; diff --git a/ndb/include/kernel/signaldata/PackedSignal.hpp b/ndb/include/kernel/signaldata/PackedSignal.hpp index 057bb39b25a..ea0ff6db526 100644 --- a/ndb/include/kernel/signaldata/PackedSignal.hpp +++ b/ndb/include/kernel/signaldata/PackedSignal.hpp @@ -38,6 +38,6 @@ class PackedSignal { }; inline -Uint32 PackedSignal::getSignalType(Uint32 data) { return data >> 28; }; +Uint32 PackedSignal::getSignalType(Uint32 data) { return data >> 28; } #endif diff --git a/ndb/include/kernel/signaldata/RepImpl.hpp b/ndb/include/kernel/signaldata/RepImpl.hpp index affffe46f9c..0de1389a4a9 100644 --- a/ndb/include/kernel/signaldata/RepImpl.hpp +++ b/ndb/include/kernel/signaldata/RepImpl.hpp @@ -93,7 +93,7 @@ public: Uint32 subscriptionId; Uint32 subscriptionKey; Uint32 senderNodeId; - GrepError::Code err; + GrepError::GE_Code err; }; class RepGetGciReq @@ -151,7 +151,7 @@ public: Uint32 lastPSGCI; Uint32 firstSSGCI; Uint32 lastSSGCI; - GrepError::Code err; + GrepError::GE_Code err; }; class RepGetGciBufferReq { @@ -213,7 +213,7 @@ public: Uint32 lastSSGCI; Uint32 currentGCIBuffer; Uint32 nodeGrp; - GrepError::Code err; + GrepError::GE_Code err; }; class RepInsertGciBufferReq @@ -252,7 +252,7 @@ public: Uint32 nodeGrp; Uint32 tableId; Uint32 force; - GrepError::Code err; + GrepError::GE_Code err; }; class RepInsertGciBufferConf @@ -310,7 +310,7 @@ public: Uint32 lastGCI; Uint32 currentGCI; Uint32 nodeGrp; - GrepError::Code err; + GrepError::GE_Code err; }; class RepClearPSGciBufferConf @@ -367,7 +367,7 @@ public: Uint32 lastGCI; Uint32 currentGCI; Uint32 nodeGrp; - GrepError::Code err; + GrepError::GE_Code err; }; class RepClearSSGciBufferConf diff --git a/ndb/include/kernel/signaldata/SumaImpl.hpp b/ndb/include/kernel/signaldata/SumaImpl.hpp index 089132cd9aa..89ade067dcd 100644 --- a/ndb/include/kernel/signaldata/SumaImpl.hpp +++ b/ndb/include/kernel/signaldata/SumaImpl.hpp @@ -159,12 +159,12 @@ public: Uint32 subscriberRef; }; inline bool SubStartRef::isTemporary() const -{ return (errorCode & SubStartRef::Temporary) > 0; }; +{ return (errorCode & SubStartRef::Temporary) > 0; } inline void SubStartRef::setTemporary() -{ errorCode |= SubStartRef::Temporary; }; +{ errorCode |= SubStartRef::Temporary; } inline SubStartRef::ErrorCode SubStartRef::setTemporary(ErrorCode ec) { return (SubStartRef::ErrorCode) - (errorCode = ((Uint32) ec | (Uint32)SubStartRef::Temporary)); }; + (errorCode = ((Uint32) ec | (Uint32)SubStartRef::Temporary)); } class SubStartConf { /** @@ -239,12 +239,12 @@ public: }; }; inline bool SubStopRef::isTemporary() const -{ return (errorCode & SubStopRef::Temporary) > 0; }; +{ return (errorCode & SubStopRef::Temporary) > 0; } inline void SubStopRef::setTemporary() -{ errorCode |= SubStopRef::Temporary; }; +{ errorCode |= SubStopRef::Temporary; } inline SubStopRef::ErrorCode SubStopRef::setTemporary(ErrorCode ec) { return (SubStopRef::ErrorCode) - (errorCode = ((Uint32) ec | (Uint32)SubStopRef::Temporary)); }; + (errorCode = ((Uint32) ec | (Uint32)SubStopRef::Temporary)); } class SubStopConf { /** @@ -515,12 +515,12 @@ public: }; }; inline bool SubRemoveRef::isTemporary() const -{ return (err & SubRemoveRef::Temporary) > 0; }; +{ return (err & SubRemoveRef::Temporary) > 0; } inline void SubRemoveRef::setTemporary() -{ err |= SubRemoveRef::Temporary; }; +{ err |= SubRemoveRef::Temporary; } inline SubRemoveRef::ErrorCode SubRemoveRef::setTemporary(ErrorCode ec) { return (SubRemoveRef::ErrorCode) - (errorCode = ((Uint32) ec | (Uint32)SubRemoveRef::Temporary)); }; + (errorCode = ((Uint32) ec | (Uint32)SubRemoveRef::Temporary)); } class SubRemoveConf { /** diff --git a/ndb/include/kernel/signaldata/TupFrag.hpp b/ndb/include/kernel/signaldata/TupFrag.hpp index c1e861c5dff..c132b19c50a 100644 --- a/ndb/include/kernel/signaldata/TupFrag.hpp +++ b/ndb/include/kernel/signaldata/TupFrag.hpp @@ -132,9 +132,10 @@ class TupAddAttrConf { friend class Dblqh; friend class Dbtup; public: - STATIC_CONST( SignalLength = 1 ); + STATIC_CONST( SignalLength = 2 ); private: Uint32 userPtr; + Uint32 lastAttr; // bool: got last attr and closed frag op }; class TupAddAttrRef { @@ -171,9 +172,10 @@ class TuxAddAttrConf { friend class Dblqh; friend class Dbtux; public: - STATIC_CONST( SignalLength = 1 ); + STATIC_CONST( SignalLength = 2 ); private: Uint32 userPtr; + Uint32 lastAttr; // bool: got last attr and closed frag op }; class TuxAddAttrRef { diff --git a/ndb/include/kernel/signaldata/UtilLock.hpp b/ndb/include/kernel/signaldata/UtilLock.hpp index 1cac467daa0..318024fd706 100644 --- a/ndb/include/kernel/signaldata/UtilLock.hpp +++ b/ndb/include/kernel/signaldata/UtilLock.hpp @@ -39,7 +39,7 @@ public: enum RequestInfo { TryLock = 1 }; -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -63,7 +63,7 @@ class UtilLockConf { public: STATIC_CONST( SignalLength = 4 ); -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -95,7 +95,7 @@ public: LockAlreadyHeld = 4 }; -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -119,7 +119,7 @@ class UtilUnlockReq { public: STATIC_CONST( SignalLength = 4 ); -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -143,7 +143,7 @@ class UtilUnlockConf { public: STATIC_CONST( SignalLength = 3 ); -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -171,7 +171,7 @@ public: NoSuchLock = 1, NotLockOwner = 2 }; -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -200,7 +200,7 @@ public: STATIC_CONST( SignalLength = 4 ); -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -229,7 +229,7 @@ public: STATIC_CONST( SignalLength = 4 ); -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -251,7 +251,7 @@ class UtilCreateLockConf { public: STATIC_CONST( SignalLength = 3 ); -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -275,7 +275,7 @@ class UtilDestroyLockReq { public: STATIC_CONST( SignalLength = 4 ); -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -303,7 +303,7 @@ public: STATIC_CONST( SignalLength = 4 ); -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; @@ -325,7 +325,7 @@ class UtilDestroyLockConf { public: STATIC_CONST( SignalLength = 3 ); -private: +public: Uint32 senderData; Uint32 senderRef; Uint32 lockId; diff --git a/ndb/include/logger/LogHandler.hpp b/ndb/include/logger/LogHandler.hpp index ca4bd4c0668..7df6ad864e5 100644 --- a/ndb/include/logger/LogHandler.hpp +++ b/ndb/include/logger/LogHandler.hpp @@ -19,7 +19,6 @@ #include "Logger.hpp" - /** * This class is the base class for all log handlers. A log handler is * responsible for formatting and writing log messages to a specific output. @@ -68,7 +67,8 @@ public: /** * Append a log message to the output stream/file whatever. * append() will call writeHeader(), writeMessage() and writeFooter() for - * a child class and in that order. + * a child class and in that order. Append checks for repeated messages. + * append_impl() does not check for repeats. * * @param pCategory the category/name to tag the log entry with. * @param level the log level. @@ -76,6 +76,8 @@ public: */ void append(const char* pCategory, Logger::LoggerLevel level, const char* pMsg); + void append_impl(const char* pCategory, Logger::LoggerLevel level, + const char* pMsg); /** * Returns a default formatted header. It currently has the @@ -112,14 +114,6 @@ public: void setDateTimeFormat(const char* pFormat); /** - * Returns a string date and time string. - * - * @param pStr a string. - * @return a string with date and time. - */ - char* getTimeAsString(char* pStr) const; - - /** * Returns the error code. */ int getErrorCode() const; @@ -185,6 +179,15 @@ protected: virtual void writeFooter() = 0; private: + /** + * Returns a string date and time string. + * @note does not update time, uses m_now as time + * @param pStr a string. + * @return a string with date and time. + */ + char* getTimeAsString(char* pStr) const; + time_t m_now; + /** Prohibit */ LogHandler(const LogHandler&); LogHandler* operator = (const LogHandler&); @@ -192,6 +195,14 @@ private: const char* m_pDateTimeFormat; int m_errorCode; + + // for handling repeated messages + unsigned m_count_repeated_messages; + unsigned m_max_repeat_frequency; + time_t m_last_log_time; + char m_last_category[MAX_HEADER_LENGTH]; + char m_last_message[MAX_LOG_MESSAGE_SIZE]; + Logger::LoggerLevel m_last_level; }; #endif diff --git a/ndb/include/logger/Logger.hpp b/ndb/include/logger/Logger.hpp index c6145f2091a..ee762098fb6 100644 --- a/ndb/include/logger/Logger.hpp +++ b/ndb/include/logger/Logger.hpp @@ -20,6 +20,8 @@ #include <ndb_global.h> #include <BaseString.hpp> +#define MAX_LOG_MESSAGE_SIZE 1024 + class LogHandler; class LogHandlerList; @@ -101,7 +103,7 @@ public: /** The log levels. NOTE: Could not use the name LogLevel since * it caused conflicts with another class. */ - enum LoggerLevel {LL_OFF, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR, + enum LoggerLevel {LL_ON, LL_DEBUG, LL_INFO, LL_WARNING, LL_ERROR, LL_CRITICAL, LL_ALERT, LL_ALL}; /** diff --git a/ndb/include/logger/SysLogHandler.hpp b/ndb/include/logger/SysLogHandler.hpp index 4f13308d61b..0dfc1cb2d43 100644 --- a/ndb/include/logger/SysLogHandler.hpp +++ b/ndb/include/logger/SysLogHandler.hpp @@ -18,7 +18,9 @@ #define SYSLOGHANDLER_H #include "LogHandler.hpp" +#ifndef NDB_WIN32 #include <syslog.h> +#endif /** * Logs messages to syslog. The default identity is 'NDB'. @@ -62,7 +64,7 @@ public: * @param pIdentity a syslog identity. * @param facility syslog facility, defaults to LOG_USER */ - SysLogHandler(const char* pIdentity, int facility = LOG_USER); + SysLogHandler(const char* pIdentity, int facility); /** * Destructor. diff --git a/ndb/include/mgmapi/mgmapi.h b/ndb/include/mgmapi/mgmapi.h index 6dcf58b44e2..fa0774afa06 100644 --- a/ndb/include/mgmapi/mgmapi.h +++ b/ndb/include/mgmapi/mgmapi.h @@ -49,6 +49,7 @@ * @{ */ +#include <ndb_types.h> #include "mgmapi_config_parameters.h" #ifdef __cplusplus @@ -244,7 +245,9 @@ extern "C" { * Log severities (used to filter the cluster log) */ enum ndb_mgm_clusterlog_level { - NDB_MGM_CLUSTERLOG_OFF = 0, /*< Cluster log off*/ + NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL = -1, + /* must range from 0 and up, indexes into an array */ + NDB_MGM_CLUSTERLOG_ON = 0, /*< Cluster log on*/ NDB_MGM_CLUSTERLOG_DEBUG = 1, /*< Used in NDB Cluster *< developement */ @@ -264,7 +267,8 @@ extern "C" { *< corrected immediately, *< such as a corrupted system */ - NDB_MGM_CLUSTERLOG_ALL = 7 /*< All severities on*/ + /* must be next number, works as bound in loop */ + NDB_MGM_CLUSTERLOG_ALL = 7 /*< All severities */ }; /** @@ -356,11 +360,28 @@ extern "C" { /** * Create a handle to a management server * - * @return A management handle<br> - * or NULL if no management handle could be created. + * @return A management handle<br> + * or NULL if no management handle could be created. */ NdbMgmHandle ndb_mgm_create_handle(); + /** + * Set connecst string to management server + * + * @param handle Management handle + * @param connect_string Connect string to the management server, + * + * @return -1 on error. + */ + int ndb_mgm_set_connectstring(NdbMgmHandle handle, + const char *connect_string); + + int ndb_mgm_set_configuration_nodeid(NdbMgmHandle handle, int nodeid); + int ndb_mgm_get_configuration_nodeid(NdbMgmHandle handle); + int ndb_mgm_get_connected_port(NdbMgmHandle handle); + const char *ndb_mgm_get_connected_host(NdbMgmHandle handle); + const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz); + /** * Destroy a management server handle * @@ -378,11 +399,10 @@ extern "C" { * Connect to a management server * * @param handle Management handle. - * @param mgmsrv Hostname and port of the management server, - * "hostname:port". * @return -1 on error. */ - int ndb_mgm_connect(NdbMgmHandle handle, const char * mgmsrv); + int ndb_mgm_connect(NdbMgmHandle handle, int no_retries, + int retry_delay_in_seconds, int verbose); /** * Disconnect from a management server @@ -565,11 +585,13 @@ extern "C" { * * @param handle NDB management handle. * @param level A cluster log level to filter. + * @param enable set 1=enable 0=disable * @param reply Reply message. * @return -1 on error. */ int ndb_mgm_filter_clusterlog(NdbMgmHandle handle, enum ndb_mgm_clusterlog_level level, + int enable, struct ndb_mgm_reply* reply); /** @@ -605,6 +627,11 @@ extern "C" { int level, struct ndb_mgm_reply* reply); + ndb_mgm_clusterlog_level + ndb_mgm_match_clusterlog_level(const char * name); + const char * + ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level); + /** * Set log category and levels for the Node * @@ -641,11 +668,15 @@ extern "C" { * Start backup * * @param handle NDB management handle. + * @param wait_completed 0=don't wait for confirmation + 1=wait for backup started + 2=wait for backup completed * @param backup_id Backup id is returned from function. * @param reply Reply message. * @return -1 on error. */ - int ndb_mgm_start_backup(NdbMgmHandle handle, unsigned int* backup_id, + int ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed, + unsigned int* backup_id, struct ndb_mgm_reply* reply); /** @@ -709,9 +740,7 @@ extern "C" { void ndb_mgm_destroy_configuration(struct ndb_mgm_configuration *); int ndb_mgm_alloc_nodeid(NdbMgmHandle handle, - unsigned version, - unsigned *pnodeid, - int nodetype); + unsigned version, int nodetype); /** * Config iterator */ @@ -730,9 +759,11 @@ extern "C" { int ndb_mgm_get_int_parameter(const ndb_mgm_configuration_iterator*, int param, unsigned * value); int ndb_mgm_get_int64_parameter(const ndb_mgm_configuration_iterator*, - int param, unsigned long long * value); + int param, Uint64 * value); int ndb_mgm_get_string_parameter(const ndb_mgm_configuration_iterator*, int param, const char ** value); + int ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **); + int ndb_mgm_check_connection(NdbMgmHandle handle); #ifdef __cplusplus } #endif diff --git a/ndb/include/mgmapi/mgmapi_config_parameters.h b/ndb/include/mgmapi/mgmapi_config_parameters.h index 6a0cd376355..8a04ee2fe37 100644 --- a/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -110,6 +110,7 @@ #define CFG_CONNECTION_SERVER_PORT 406 #define CFG_CONNECTION_HOSTNAME_1 407 #define CFG_CONNECTION_HOSTNAME_2 408 +#define CFG_CONNECTION_GROUP 409 #define CFG_TCP_SERVER 452 #define CFG_TCP_SEND_BUFFER_SIZE 454 @@ -120,6 +121,7 @@ #define CFG_SHM_CHECKSUM 501 #define CFG_SHM_KEY 502 #define CFG_SHM_BUFFER_MEM 503 +#define CFG_SHM_SIGNUM 504 #define CFG_SCI_HOST1_ID_0 550 #define CFG_SCI_HOST1_ID_1 551 diff --git a/ndb/include/mgmcommon/ConfigRetriever.hpp b/ndb/include/mgmcommon/ConfigRetriever.hpp index 6c32255e921..be6d656e1a5 100644 --- a/ndb/include/mgmcommon/ConfigRetriever.hpp +++ b/ndb/include/mgmcommon/ConfigRetriever.hpp @@ -20,7 +20,6 @@ #include <ndb_types.h> #include <mgmapi.h> #include <BaseString.hpp> -#include <LocalConfig.hpp> /** * @class ConfigRetriever @@ -28,10 +27,11 @@ */ class ConfigRetriever { public: - ConfigRetriever(LocalConfig &local_config, Uint32 version, Uint32 nodeType); + ConfigRetriever(const char * _connect_string, + Uint32 version, Uint32 nodeType); ~ConfigRetriever(); - int do_connect(int exit_on_connect_failure= false); + int do_connect(int no_retries, int retry_delay_in_seconds, int verbose); /** * Get configuration for current node. @@ -46,12 +46,16 @@ public: */ struct ndb_mgm_configuration * getConfig(); + void resetError(); + int hasError(); const char * getErrorString(); /** * @return Node id of this node (as stated in local config or connectString) */ - Uint32 allocNodeId(); + Uint32 allocNodeId(int no_retries, int retry_delay_in_seconds); + + int setNodeId(Uint32 nodeid); /** * Get config using socket @@ -68,22 +72,27 @@ public: */ bool verifyConfig(const struct ndb_mgm_configuration *, Uint32 nodeid); - Uint32 get_mgmd_port() const {return m_mgmd_port;}; - const char *get_mgmd_host() const {return m_mgmd_host;}; + Uint32 get_mgmd_port() const; + const char *get_mgmd_host() const; + const char *get_connectstring(char *buf, int buf_sz) const; + + Uint32 get_configuration_nodeid() const; private: BaseString errorString; enum ErrorType { - CR_ERROR = 0, - CR_RETRY = 1 + CR_NO_ERROR = 0, + CR_ERROR = 1, + CR_RETRY = 2 }; ErrorType latestErrorType; void setError(ErrorType, const char * errorMsg); - struct LocalConfig& _localConfig; - Uint32 _ownNodeId; + Uint32 _ownNodeId; + /* Uint32 m_mgmd_port; const char *m_mgmd_host; + */ Uint32 m_version; Uint32 m_node_type; diff --git a/ndb/include/mgmcommon/IPCConfig.hpp b/ndb/include/mgmcommon/IPCConfig.hpp index ebe65b53b59..1e23cdf9807 100644 --- a/ndb/include/mgmcommon/IPCConfig.hpp +++ b/ndb/include/mgmcommon/IPCConfig.hpp @@ -59,7 +59,7 @@ public: void print() const { props->print(); } static Uint32 configureTransporters(Uint32 nodeId, - const class ndb_mgm_configuration &, + const struct ndb_mgm_configuration &, class TransporterRegistry &); private: diff --git a/ndb/include/ndb_global.h b/ndb/include/ndb_global.h deleted file mode 100644 index 09559f6ddff..00000000000 --- a/ndb/include/ndb_global.h +++ /dev/null @@ -1,115 +0,0 @@ - -#ifndef NDBGLOBAL_H -#define NDBGLOBAL_H - -#include <my_global.h> - -/** signal & SIG_PIPE */ -#include <my_alarm.h> - -#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) -#define NDB_WIN32 -#else -#undef NDB_WIN32 -#endif - -#ifdef _AIX -#undef _H_STRINGS -#endif -#include <m_string.h> -#include <m_ctype.h> -#include <ndb_types.h> -#include <ctype.h> -#ifdef HAVE_STDARG_H -#include <stdarg.h> -#endif -#ifdef TIME_WITH_SYS_TIME -#include <time.h> -#endif -#ifdef HAVE_FCNTL_H -#include <fcntl.h> -#endif -#include <sys/param.h> -#ifdef HAVE_SYS_STAT_H - #if defined(__cplusplus) && defined(_APP32_64BIT_OFF_T) && defined(_INCLUDE_AES_SOURCE) - #undef _INCLUDE_AES_SOURCE - #include <sys/stat.h> - #define _INCLUDE_AES_SOURCE - #else - #include <sys/stat.h> - #endif -#endif -#include <sys/resource.h> -#ifdef HAVE_SYS_WAIT_H -#include <sys/wait.h> -#endif -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -#endif - -#ifdef NDB_WIN32 -#include <winsock2.h> -#include <ws2tcpip.h> - -#define DIR_SEPARATOR "\\" -#define PATH_MAX 256 - -#pragma warning(disable: 4503 4786) -#else - -#define DIR_SEPARATOR "/" - -#endif - -static const char table_name_separator = '/'; - -#if defined(_AIX) || defined(NDB_VC98) -#define STATIC_CONST(x) enum { x } -#else -#define STATIC_CONST(x) static const Uint32 x -#endif - -#ifdef __cplusplus -#include <new> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#include <assert.h> - -/* call in main() - does not return on error */ -extern int ndb_init(void); -extern void ndb_end(int); - -#ifndef HAVE_STRDUP -extern char * strdup(const char *s); -#endif - -#ifndef HAVE_STRLCPY -extern size_t strlcpy (char *dst, const char *src, size_t dst_sz); -#endif - -#ifndef HAVE_STRLCAT -extern size_t strlcat (char *dst, const char *src, size_t dst_sz); -#endif - -#ifndef HAVE_STRCASECMP -extern int strcasecmp(const char *s1, const char *s2); -extern int strncasecmp(const char *s1, const char *s2, size_t n); -#endif - -#ifdef SCO - -#ifndef PATH_MAX -#define PATH_MAX 1024 -#endif - -#endif /* SCO */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ndb/include/ndb_global.h.in b/ndb/include/ndb_global.h.in new file mode 100644 index 00000000000..eadd5e37b9b --- /dev/null +++ b/ndb/include/ndb_global.h.in @@ -0,0 +1,162 @@ +/* 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 NDBGLOBAL_H +#define NDBGLOBAL_H + +#include <ndb_types.h> + +#define NDB_PORT "@ndb_port@" +#define NDB_TCP_BASE_PORT "@ndb_port_base@" + +#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) +#define NDB_WIN32 +#include <winsock2.h> +#define PATH_MAX 256 +#define DIR_SEPARATOR "\\" +#define MYSQLCLUSTERDIR "c:\\mysql\\mysql-cluster" +#define HAVE_STRCASECMP +#define strcasecmp _strcmpi +#pragma warning(disable: 4503 4786) +typedef unsigned __int64 Uint64; +typedef signed __int64 Int64; +#else +#undef NDB_WIN32 +#define DIR_SEPARATOR "/" +typedef unsigned long long Uint64; +typedef signed long long Int64; +#endif + +#include <my_global.h> + +typedef signed char Int8; +typedef unsigned char Uint8; +typedef signed short Int16; +typedef unsigned short Uint16; +typedef signed int Int32; +typedef unsigned int Uint32; + +typedef unsigned int UintR; + +#ifdef __SIZE_TYPE__ +typedef __SIZE_TYPE__ UintPtr; +#elif SIZEOF_CHARP == 4 +typedef Uint32 UintPtr; +#elif SIZEOF_CHARP == 8 +typedef Uint64 UintPtr; +#else +#error "Unknown size of (char *)" +#endif + +#if ! (SIZEOF_CHAR == 1) +#error "Invalid define for Uint8" +#endif + +#if ! (SIZEOF_INT == 4) +#error "Invalid define for Uint32" +#endif + +#if ! (SIZEOF_LONG_LONG == 8) +#error "Invalid define for Uint64" +#endif + +#include <my_alarm.h> + +#ifdef _AIX +#undef _H_STRINGS +#endif +#include <m_string.h> +#include <m_ctype.h> +#include <ctype.h> + +#ifdef HAVE_STDARG_H +#include <stdarg.h> +#endif + +#ifdef TIME_WITH_SYS_TIME +#include <time.h> +#endif + +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif + +#ifdef HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif + +#ifdef HAVE_SYS_STAT_H + #if defined(__cplusplus) && defined(_APP32_64BIT_OFF_T) && defined(_INCLUDE_AES_SOURCE) + #undef _INCLUDE_AES_SOURCE + #include <sys/stat.h> + #define _INCLUDE_AES_SOURCE + #else + #include <sys/stat.h> + #endif +#endif + +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif + +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif + +#ifdef HAVE_SYS_MMAN_H +#include <sys/mman.h> +#endif + +#ifndef HAVE_STRDUP +extern char * strdup(const char *s); +#endif + +#ifndef HAVE_STRCASECMP +extern int strcasecmp(const char *s1, const char *s2); +extern int strncasecmp(const char *s1, const char *s2, size_t n); +#endif + +static const char table_name_separator = '/'; + +#if defined(_AIX) || defined(WIN32) || defined(NDB_VC98) +#define STATIC_CONST(x) enum { x } +#else +#define STATIC_CONST(x) static const Uint32 x +#endif + +#ifdef __cplusplus +inline void* operator new(size_t, void* __p) { return __p; } +inline void* operator new[](size_t, void* __p) { return __p; } +extern "C" { +#endif + +#include <assert.h> + +#ifdef __cplusplus +} +#endif + +#include "ndb_init.h" + +#ifdef SCO + +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +#endif /* SCO */ + +#endif diff --git a/ndb/include/ndb_init.h b/ndb/include/ndb_init.h new file mode 100644 index 00000000000..0ff53e6a2af --- /dev/null +++ b/ndb/include/ndb_init.h @@ -0,0 +1,32 @@ +/* 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_INIT_H +#define NDB_INIT_H + +#ifdef __cplusplus +extern "C" { +#endif +/* call in main() - does not return on error */ +extern int ndb_init(void); +extern void ndb_end(int); +#define NDB_INIT(prog_name) {my_progname=(prog_name); ndb_init();} +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ndb/include/ndb_types.h b/ndb/include/ndb_types.h index a2988dbae78..6cf9bb40d7f 100644 --- a/ndb/include/ndb_types.h +++ b/ndb/include/ndb_types.h @@ -21,34 +21,6 @@ #ifndef NDB_TYPES_H #define NDB_TYPES_H -typedef char Int8; -typedef unsigned char Uint8; -typedef short Int16; -typedef unsigned short Uint16; -typedef int Int32; -typedef unsigned int Uint32; - -typedef unsigned int UintR; - -#ifdef __SIZE_TYPE__ -typedef __SIZE_TYPE__ UintPtr; -#else -#include <ndb_global.h> -#ifdef HAVE_STDINT_H -#include <stdint.h> -#endif -#ifdef HAVE_INTTYPES_H -#include <inttypes.h> -#endif -typedef uintptr_t UintPtr; -#endif - -#if defined(WIN32) || defined(NDB_WIN32) -typedef unsigned __int64 Uint64; -typedef __int64 Int64; -#else -typedef unsigned long long Uint64; -typedef long long Int64; -#endif +#include "ndb_global.h" #endif diff --git a/ndb/include/ndb_version.h b/ndb/include/ndb_version.h.in index 56362020ebf..d7f43eae40a 100644 --- a/ndb/include/ndb_version.h +++ b/ndb/include/ndb_version.h.in @@ -20,14 +20,25 @@ #include <ndb_global.h> #include <version.h> +/* NDB build version */ +#define NDB_VERSION_BUILD @NDB_VERSION_BUILD@ + +/* NDB major version */ +#define NDB_VERSION_MAJOR @NDB_VERSION_MAJOR@ + +/* NDB minor version */ +#define NDB_VERSION_MINOR @NDB_VERSION_MINOR@ + +/* NDB status version */ +#define NDB_VERSION_STATUS "@NDB_VERSION_STATUS@" + + #define MAKE_VERSION(A,B,C) (((A) << 16) | ((B) << 8) | ((C) << 0)) #define NDB_VERSION_D MAKE_VERSION(NDB_VERSION_MAJOR, NDB_VERSION_MINOR, NDB_VERSION_BUILD) #define NDB_VERSION_STRING (getVersionString(NDB_VERSION, NDB_VERSION_STATUS)) -#define NDB_VERSION_TAG_STRING "$Name: $" - #define NDB_VERSION ndbGetOwnVersion() /** diff --git a/ndb/include/ndbapi/Ndb.hpp b/ndb/include/ndbapi/Ndb.hpp index 5ec09269695..766409d64e2 100644 --- a/ndb/include/ndbapi/Ndb.hpp +++ b/ndb/include/ndbapi/Ndb.hpp @@ -901,23 +901,6 @@ typedef void (* NdbEventCallback)(NdbEventOperation*, Ndb*, void*); NDB_MAX_SCHEMA_NAME_SIZE + \ NDB_MAX_TAB_NAME_SIZE*2 -#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL -class NdbWaiter { -public: - NdbWaiter(); - ~NdbWaiter(); - - void wait(int waitTime); - void nodeFail(Uint32 node); - void signal(Uint32 state); - - Uint32 m_node; - Uint32 m_state; - void * m_mutex; - struct NdbCondition * m_condition; -}; -#endif - /** * @class Ndb * @brief Represents the NDB kernel and is the main class of the NDB API. @@ -1199,39 +1182,6 @@ public: const char * keyData = 0, Uint32 keyLen = 0); -#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL - /** - * This method is a modification of Ndb::startTransaction, - * in which we use only the first two chars of keyData to - * select transaction coordinator. - * This is referred to as a distribution group. - * There are two ways to use the method: - * - In the first, the two characters are used directly as - * the distribution key, and - * - in the second the distribution is calculated as: - * (10 * (char[0] - 0x30) + (char[1] - 0x30)). - * Thus, in the second way, the two ASCII digits '78' - * will provide the distribution key = 78. - * - * @note Transaction priorities are not yet supported. - * - * @param aPrio Priority of the transaction.<br> - * Priority 0 is the highest priority and is used for short transactions - * with requirements on low delay.<br> - * Priority 1 is a medium priority for short transactions.<br> - * Priority 2 is a medium priority for long transactions.<br> - * Priority 3 is a low priority for long transactions. - * @param keyData is a string of which the two first characters - * is used to compute which fragement the data is stored in. - * @param type is the type of distribution group.<br> - * 0 means direct usage of the two characters, and<br> - * 1 means the ASCII digit variant. - * @return NdbConnection, or NULL if it failed. - */ - NdbConnection* startTransactionDGroup(Uint32 aPrio, - const char * keyData, int type); -#endif - /** * When a transactions is completed, the transaction has to be closed. * @@ -1586,9 +1536,6 @@ private: /****************************************************************************** * These are the private variables in this class. *****************************************************************************/ - NdbObjectIdMap* theNdbObjectIdMap; - Ndb_cluster_connection *m_ndb_cluster_connection; - NdbConnection** thePreparedTransactionsArray; NdbConnection** theSentTransactionsArray; NdbConnection** theCompletedTransactionsArray; @@ -1602,8 +1549,6 @@ private: Uint32 theNextConnectNode; - NdbWaiter theWaiter; - bool fullyQualifiedNames; // Ndb database name. @@ -1637,10 +1582,6 @@ private: Uint32 theMyRef; // My block reference Uint32 theNode; // The node number of our node - Uint32 theNoOfDBnodes; // The number of DB nodes - Uint32 * theDBnodes; // The node number of the DB nodes - Uint8 *the_release_ind;// 1 indicates to release all connections to node - Uint64 the_last_check_time; Uint64 theFirstTransId; @@ -1663,39 +1604,6 @@ private: InitConfigError } theInitState; - // Ensure good distribution of connects - Uint32 theCurrentConnectIndex; - Uint32 theCurrentConnectCounter; - - /** - * Computes fragement id for primary key - * - * Note that keydata has to be "shaped" as it is being sent in KEYINFO - */ - Uint32 computeFragmentId(const char * keyData, Uint32 keyLen); - Uint32 getFragmentId(Uint32 hashValue); - - /** - * Make a guess to which node is the primary for the fragment - */ - Uint32 guessPrimaryNode(Uint32 fragmentId); - - /** - * Structure containing values for guessing primary node - */ - struct StartTransactionNodeSelectionData { - StartTransactionNodeSelectionData(): - fragment2PrimaryNodeMap(0) {}; - Uint32 kValue; - Uint32 hashValueMask; - Uint32 hashpointerValue; - Uint32 noOfFragments; - Uint32 * fragment2PrimaryNodeMap; - - void init(Uint32 noOfNodes, Uint32 nodeIds[]); - void release(); - } startTransactionNodeSelectionData; - NdbApiSignal* theCommitAckSignal; diff --git a/ndb/include/ndbapi/NdbApi.hpp b/ndb/include/ndbapi/NdbApi.hpp index add733cccd7..ae7025f560a 100644 --- a/ndb/include/ndbapi/NdbApi.hpp +++ b/ndb/include/ndbapi/NdbApi.hpp @@ -17,6 +17,8 @@ #ifndef NdbApi_H #define NdbApi_H +#include "ndb_init.h" +#include "ndb_cluster_connection.hpp" #include "ndbapi_limits.h" #include "Ndb.hpp" #include "NdbConnection.hpp" diff --git a/ndb/include/ndbapi/NdbBlob.hpp b/ndb/include/ndbapi/NdbBlob.hpp index 5df61a0806c..b145c69b04b 100644 --- a/ndb/include/ndbapi/NdbBlob.hpp +++ b/ndb/include/ndbapi/NdbBlob.hpp @@ -36,7 +36,7 @@ class NdbColumnImpl; * Blob data is stored in 2 places: * * - "header" and "inline bytes" stored in the blob attribute - * - "blob parts" stored in a separate table NDB$BLOB_<t>_<v>_<c> + * - "blob parts" stored in a separate table NDB$BLOB_<tid>_<cid> * * Inline and part sizes can be set via NdbDictionary::Column methods * when the table is created. @@ -74,23 +74,21 @@ class NdbColumnImpl; * NdbBlob methods return -1 on error and 0 on success, and use output * parameters when necessary. * - * Notes: - * - table and its blob part tables are not created atomically - * - scan must use the "new" interface NdbScanOperation - * - to update a blob in a read op requires exclusive tuple lock - * - update op in scan must do its own getBlobHandle - * - delete creates implicit, not-accessible blob handles - * - NdbOperation::writeTuple does not support blobs - * - there is no support for an asynchronous interface + * Operation types: + * - insertTuple must use setValue if blob column is non-nullable + * - readTuple with exclusive lock can also update existing value + * - updateTuple can overwrite with setValue or update existing value + * - writeTuple always overwrites and must use setValue if non-nullable + * - deleteTuple creates implicit non-accessible blob handles + * - scan with exclusive lock can also update existing value + * - scan "lock takeover" update op must do its own getBlobHandle * * Bugs / limitations: - * - scan must use exclusive locking for now - * - * Todo: - * - add scan method hold-read-lock + return-keyinfo - * - check keyinfo length when setting keys - * - check allowed blob ops vs locking mode - * - overload control (too many pending ops) + * - lock mode upgrade should be handled automatically + * - lock mode vs allowed operation is not checked + * - too many pending blob ops can blow up i/o buffers + * - table and its blob part tables are not created atomically + * - there is no support for an asynchronous interface */ class NdbBlob { public: @@ -173,46 +171,23 @@ public: */ int readData(void* data, Uint32& bytes); /** - * Read at given position. Does not use or update current position. - */ - int readData(Uint64 pos, void* data, Uint32& bytes); - /** * Write at current position and set new position to first byte after * the data written. A write past blob end extends the blob value. */ int writeData(const void* data, Uint32 bytes); /** - * Write at given position. Does not use or update current position. - */ - int writeData(Uint64 pos, const void* data, Uint32 bytes); - /** * Return the blob column. */ const NdbDictionary::Column* getColumn(); /** * Get blob parts table name. Useful only to test programs. */ - STATIC_CONST( BlobTableNameSize = 40 ); static int getBlobTableName(char* btname, Ndb* anNdb, const char* tableName, const char* columnName); /** * Return error object. The error may be blob specific (below) or may * be copied from a failed implicit operation. */ const NdbError& getNdbError() const; - // "Invalid blob attributes or invalid blob parts table" - STATIC_CONST( ErrTable = 4263 ); - // "Invalid usage of blob attribute" - STATIC_CONST( ErrUsage = 4264 ); - // "Method is not valid in current blob state" - STATIC_CONST( ErrState = 4265 ); - // "Invalid blob seek position" - STATIC_CONST( ErrSeek = 4266 ); - // "Corrupted blob value" - STATIC_CONST( ErrCorrupt = 4267 ); - // "Error in blob head update forced rollback of transaction" - STATIC_CONST( ErrAbort = 4268 ); - // "Unknown blob error" - STATIC_CONST( ErrUnknown = 4269 ); /** * Return info about all blobs in this operation. */ @@ -266,14 +241,17 @@ private: Buf(); ~Buf(); void alloc(unsigned n); + void copyfrom(const Buf& src); }; Buf theKeyBuf; Buf theAccessKeyBuf; Buf theHeadInlineBuf; + Buf theHeadInlineCopyBuf; // for writeTuple Buf thePartBuf; Head* theHead; char* theInlineData; NdbRecAttr* theHeadInlineRecAttr; + NdbOperation* theHeadInlineReadOp; bool theHeadInlineUpdateFlag; // length and read/write position int theNullFlag; @@ -294,6 +272,7 @@ private: bool isReadOp(); bool isInsertOp(); bool isUpdateOp(); + bool isWriteOp(); bool isDeleteOp(); bool isScanOp(); // computations @@ -309,12 +288,13 @@ private: void getHeadFromRecAttr(); int setHeadInlineValue(NdbOperation* anOp); // data operations - int readDataPrivate(Uint64 pos, char* buf, Uint32& bytes); - int writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes); + int readDataPrivate(char* buf, Uint32& bytes); + int writeDataPrivate(const char* buf, Uint32 bytes); int readParts(char* buf, Uint32 part, Uint32 count); int insertParts(const char* buf, Uint32 part, Uint32 count); int updateParts(const char* buf, Uint32 part, Uint32 count); int deleteParts(Uint32 part, Uint32 count); + int deletePartsUnknown(Uint32 part); // pending ops int executePendingBlobReads(); int executePendingBlobWrites(); diff --git a/ndb/include/ndbapi/NdbConnection.hpp b/ndb/include/ndbapi/NdbConnection.hpp index 92b940e96f7..53830dd93c5 100644 --- a/ndb/include/ndbapi/NdbConnection.hpp +++ b/ndb/include/ndbapi/NdbConnection.hpp @@ -50,7 +50,7 @@ enum AbortOption { TryCommit = 0, ///< <i>Missing explanation</i> #endif AbortOnError = 0, ///< Abort transaction on failed operation - IgnoreError = 2 ///< Transaction continues on failed operation + AO_IgnoreError = 2 ///< Transaction continues on failed operation }; typedef AbortOption CommitType; @@ -526,7 +526,7 @@ private: int sendCOMMIT(); // Send a TC_COMMITREQ signal; void setGCI(int GCI); // Set the global checkpoint identity - int OpCompleteFailure(Uint8 abortoption); + int OpCompleteFailure(Uint8 abortoption, bool setFailure = true); int OpCompleteSuccess(); void CompletedOperations(); // Move active ops to list of completed @@ -552,7 +552,7 @@ private: void setOperationErrorCode(int anErrorCode); // Indicate something went wrong in the definition phase - void setOperationErrorCodeAbort(int anErrorCode); + void setOperationErrorCodeAbort(int anErrorCode, int abortOption = -1); int checkMagicNumber(); // Verify correct object NdbOperation* getNdbOperation(const class NdbTableImpl* aTable, @@ -607,8 +607,8 @@ private: NdbOperation* theLastExecOpInList; // Last executing operation in list. - NdbOperation* theCompletedFirstOp; // First operation in completed - // operation list. + NdbOperation* theCompletedFirstOp; // First & last operation in completed + NdbOperation* theCompletedLastOp; // operation list. Uint32 theNoOfOpSent; // How many operations have been sent Uint32 theNoOfOpCompleted; // How many operations have completed @@ -687,6 +687,8 @@ private: void remove_list(NdbOperation*& head, NdbOperation*); void define_scan_op(NdbIndexScanOperation*); + + friend class HugoOperations; }; inline diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 51a6895648f..6aa675a2319 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -141,9 +141,9 @@ public: enum FragmentType { FragUndefined = 0, ///< Fragmentation type undefined or default FragSingle = 1, ///< Only one fragment - FragAllSmall = 2, ///< One fragment per node group - FragAllMedium = 3, ///< Default value. Two fragments per node group. - FragAllLarge = 4 ///< Eight fragments per node group. + FragAllSmall = 2, ///< One fragment per node, default + FragAllMedium = 3, ///< two fragments per node + FragAllLarge = 4 ///< Four fragments per node. }; }; @@ -179,15 +179,19 @@ public: Bigunsigned, ///< 64 Bit. 8 byte signed integer, can be used in array Float, ///< 32-bit float. 4 bytes float, can be used in array Double, ///< 64-bit float. 8 byte float, can be used in array - Decimal, ///< Precision, Scale are applicable + Olddecimal, ///< MySQL < 5.0 signed decimal, Precision, Scale Char, ///< Len. A fixed array of 1-byte chars Varchar, ///< Max len Binary, ///< Len Varbinary, ///< Max len Datetime, ///< Precision down to 1 sec (sizeof(Datetime) == 8 bytes ) - Timespec, ///< Precision down to 1 nsec(sizeof(Datetime) == 12 bytes ) + Date, ///< Precision down to 1 day(sizeof(Date) == 4 bytes ) Blob, ///< Binary large object (see NdbBlob) - Text ///< Text blob + Text, ///< Text blob + Time = 25, ///< Time without date + Year = 26, ///< Year 1901-2155 (1 byte) + Timestamp = 27, ///< Unix time + Olddecimalunsigned = 28 }; /** @@ -273,25 +277,25 @@ public: /** * Set precision of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ void setPrecision(int); /** * Get precision of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ int getPrecision() const; /** * Set scale of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ void setScale(int); /** * Get scale of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ int getScale() const; @@ -369,7 +373,7 @@ public: */ bool getDistributionKey() const; /** @} *******************************************************************/ - + #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL void setTupleKey(bool); bool getTupleKey() const; @@ -490,6 +494,18 @@ public: * Get column definition via index in table. * @return null if none existing name */ + Column* getColumn(const int attributeId); + + /** + * Get column definition via name. + * @return null if none existing name + */ + Column* getColumn(const char * name); + + /** + * Get column definition via index in table. + * @return null if none existing name + */ const Column* getColumn(const int attributeId) const; /** @} *******************************************************************/ @@ -698,7 +714,7 @@ public: /** * Get a specific column in the index */ - const NdbDictionary::Column * getColumn(unsigned no) const ; + const Column * getColumn(unsigned no) const ; /** * Get a specific column name in the index @@ -970,13 +986,6 @@ public: */ const Table * getTable(const char * name); - /** - * Get table with given name for alteration. - * @param name Name of table to alter - * @return table if successful. NULL if undefined - */ - Table getTableForAlteration(const char * name); - #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * Invalidate cached table object diff --git a/ndb/include/ndbapi/NdbIndexOperation.hpp b/ndb/include/ndbapi/NdbIndexOperation.hpp index 7612fe54d1b..1472f1b249e 100644 --- a/ndb/include/ndbapi/NdbIndexOperation.hpp +++ b/ndb/include/ndbapi/NdbIndexOperation.hpp @@ -49,6 +49,9 @@ public: * @{ */ + /** insert is not allowed */ + int insertTuple(); + /** * Define the NdbIndexOperation to be a standard operation of type readTuple. * When calling NdbConnection::execute, this operation @@ -193,6 +196,7 @@ private: // Private attributes const NdbIndexImpl* m_theIndex; + const NdbTableImpl* m_thePrimaryTable; Uint32 m_theIndexDefined[NDB_MAX_ATTRIBUTES_IN_INDEX][3]; Uint32 m_theIndexLen; // Length of the index in words Uint32 m_theNoOfIndexDefined; // The number of index attributes diff --git a/ndb/include/ndbapi/NdbIndexScanOperation.hpp b/ndb/include/ndbapi/NdbIndexScanOperation.hpp index 66b3fc9d43b..a3388f62f58 100644 --- a/ndb/include/ndbapi/NdbIndexScanOperation.hpp +++ b/ndb/include/ndbapi/NdbIndexScanOperation.hpp @@ -113,7 +113,7 @@ public: * Reset bounds and put operation in list that will be * sent on next execute */ - int reset_bounds(); + int reset_bounds(bool forceSend = false); bool getSorted() const { return m_ordered; } private: @@ -127,8 +127,8 @@ private: virtual NdbRecAttr* getValue_impl(const NdbColumnImpl*, char*); void fix_get_values(); - int next_result_ordered(bool fetchAllowed); - int send_next_scan_ordered(Uint32 idx); + int next_result_ordered(bool fetchAllowed, bool forceSend = false); + int send_next_scan_ordered(Uint32 idx, bool forceSend = false); int compare(Uint32 key, Uint32 cols, const NdbReceiver*, const NdbReceiver*); Uint32 m_sort_columns; diff --git a/ndb/include/ndbapi/NdbOperation.hpp b/ndb/include/ndbapi/NdbOperation.hpp index 8e0294e41e6..46d4ddab0f5 100644 --- a/ndb/include/ndbapi/NdbOperation.hpp +++ b/ndb/include/ndbapi/NdbOperation.hpp @@ -918,6 +918,13 @@ protected: // Blobs in this operation NdbBlob* theBlobList; + /* + * Abort option per operation, used by blobs. Default -1. If set, + * overrides abort option on connection level. If set to IgnoreError, + * does not cause execute() to return failure. This is different from + * IgnoreError on connection level. + */ + Int8 m_abortOption; }; #ifdef NDB_NO_DROPPED_SIGNAL @@ -1160,5 +1167,3 @@ NdbOperation::setValue(Uint32 anAttrId, double aPar) } #endif - - diff --git a/ndb/include/ndbapi/NdbRecAttr.hpp b/ndb/include/ndbapi/NdbRecAttr.hpp index da03df13027..05635a99385 100644 --- a/ndb/include/ndbapi/NdbRecAttr.hpp +++ b/ndb/include/ndbapi/NdbRecAttr.hpp @@ -301,13 +301,6 @@ NdbRecAttr::arraySize() const } inline -Int64 -NdbRecAttr::int64_value() const -{ - return *(Int64*)theRef; -} - -inline Int32 NdbRecAttr::int32_value() const { @@ -329,13 +322,6 @@ NdbRecAttr::char_value() const } inline -Uint64 -NdbRecAttr::u_64_value() const -{ - return *(Uint64*)theRef; -} - -inline Uint32 NdbRecAttr::u_32_value() const { @@ -357,20 +343,6 @@ NdbRecAttr::u_char_value() const } inline -float -NdbRecAttr::float_value() const -{ - return *(float*)theRef; -} - -inline -double -NdbRecAttr::double_value() const -{ - return *(double*)theRef; -} - -inline void NdbRecAttr::release() { diff --git a/ndb/include/ndbapi/NdbReceiver.hpp b/ndb/include/ndbapi/NdbReceiver.hpp index b95313db274..af624f69bd3 100644 --- a/ndb/include/ndbapi/NdbReceiver.hpp +++ b/ndb/include/ndbapi/NdbReceiver.hpp @@ -19,7 +19,6 @@ #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL // Not part of public interface #include <ndb_types.h> -#include <ndb_global.h> class Ndb; class NdbConnection; @@ -131,7 +130,9 @@ int NdbReceiver::execTCOPCONF(Uint32 len){ Uint32 tmp = m_received_result_length; m_expected_result_length = len; +#ifdef assert assert(!(tmp && !len)); +#endif return ((bool)len ^ (bool)tmp ? 0 : 1); } diff --git a/ndb/include/ndbapi/NdbResultSet.hpp b/ndb/include/ndbapi/NdbResultSet.hpp index 478daf8aad2..dc0288a380c 100644 --- a/ndb/include/ndbapi/NdbResultSet.hpp +++ b/ndb/include/ndbapi/NdbResultSet.hpp @@ -89,17 +89,17 @@ public: * - 1: if there are no more tuples to scan. * - 2: if there are no more cached records in NdbApi */ - int nextResult(bool fetchAllowed = true); + int nextResult(bool fetchAllowed = true, bool forceSend = false); /** * Close result set (scan) */ - void close(); + void close(bool forceSend = false); /** * Restart */ - int restart(); + int restart(bool forceSend = false); /** * Transfer scan operation to an updating transaction. Use this function diff --git a/ndb/include/ndbapi/NdbScanOperation.hpp b/ndb/include/ndbapi/NdbScanOperation.hpp index 2e4d173ac75..f25f9405033 100644 --- a/ndb/include/ndbapi/NdbScanOperation.hpp +++ b/ndb/include/ndbapi/NdbScanOperation.hpp @@ -90,11 +90,11 @@ protected: NdbScanOperation(Ndb* aNdb); virtual ~NdbScanOperation(); - int nextResult(bool fetchAllowed = true); + int nextResult(bool fetchAllowed = true, bool forceSend = false); virtual void release(); - void closeScan(); - int close_impl(class TransporterFacade*); + void closeScan(bool forceSend = false); + int close_impl(class TransporterFacade*, bool forceSend = false); // Overloaded methods from NdbCursorOperation int executeCursor(int ProcessorId); @@ -103,6 +103,7 @@ protected: int init(const NdbTableImpl* tab, NdbConnection* myConnection); int prepareSend(Uint32 TC_ConnectPtr, Uint64 TransactionId); int doSend(int ProcessorId); + void checkForceSend(bool forceSend); virtual void setErrorCode(int aErrorCode); virtual void setErrorCodeAbort(int aErrorCode); @@ -127,18 +128,27 @@ protected: NdbReceiver** m_receivers; // All receivers Uint32* m_prepared_receivers; // These are to be sent - + + /** + * owned by API/user thread + */ Uint32 m_current_api_receiver; Uint32 m_api_receivers_count; NdbReceiver** m_api_receivers; // These are currently used by api + /** + * owned by receiver thread + */ Uint32 m_conf_receivers_count; // NOTE needs mutex to access NdbReceiver** m_conf_receivers; // receive thread puts them here + /** + * owned by receiver thread + */ Uint32 m_sent_receivers_count; // NOTE needs mutex to access NdbReceiver** m_sent_receivers; // receive thread puts them here - int send_next_scan(Uint32 cnt, bool close); + int send_next_scan(Uint32 cnt, bool close, bool forceSend = false); void receiver_delivered(NdbReceiver*); void receiver_completed(NdbReceiver*); void execCLOSE_SCAN_REP(); @@ -148,7 +158,7 @@ protected: Uint32 m_ordered; - int restart(); + int restart(bool forceSend = false); }; inline diff --git a/ndb/include/ndbapi/ndb_cluster_connection.hpp b/ndb/include/ndbapi/ndb_cluster_connection.hpp index f8e6f25ce73..0e559700716 100644 --- a/ndb/include/ndbapi/ndb_cluster_connection.hpp +++ b/ndb/include/ndbapi/ndb_cluster_connection.hpp @@ -18,30 +18,79 @@ #ifndef CLUSTER_CONNECTION_HPP #define CLUSTER_CONNECTION_HPP -class TransporterFacade; -class LocalConfig; -class ConfigRetriever; -class NdbThread; - -extern "C" { - void* run_ndb_cluster_connection_connect_thread(void*); -} - +/** + * @class Ndb_cluster_connection + * @brief Represents a connection to a cluster of storage nodes + * + * Always start your application program by creating a + * Ndb_cluster_connection object. Your application should contain + * only one Ndb_cluster_connection. Your application connects to + * a cluster management server when method connect() is called. + * With the method wait_until_ready() it is possible to wait + * for the connection to one or several storage nodes. + */ class Ndb_cluster_connection { public: + /** + * Create a connection to a cluster of storage nodes + * + * @param specify the connectstring for where to find the + * management server + */ Ndb_cluster_connection(const char * connect_string = 0); ~Ndb_cluster_connection(); - int connect(int reconnect= 0); + + /** + * Connect to a cluster management server + * + * @param no_retries specifies the number of retries to perform + * if the connect fails, negative number results in infinite + * number of retries + * @param retry_delay_in_seconds specifies how often retries should + * be performed + * @param verbose specifies if the method should print progess + * + * @return 0 if success, + * 1 if retriable error, + * -1 if non-retriable error + */ + int connect(int no_retries=0, int retry_delay_in_seconds=1, int verbose=0); + +#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL int start_connect_thread(int (*connect_callback)(void)= 0); +#endif + + /** + * Wait until one or several storage nodes are connected + * + * @param time_out_for_first_alive number of seconds to wait until + * first alive node is detected + * @param timeout_after_first_alive number of seconds to wait after + * first alive node is detected + * + * @return 0 all nodes alive, + * > 0 at least one node alive, + * < 0 error + */ + int wait_until_ready(int timeout_for_first_alive, + int timeout_after_first_alive); + +#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL + const char *get_connectstring(char *buf, int buf_sz) const; + int get_connected_port() const; + const char *get_connected_host() const; + + void set_optimized_node_selection(int val); + + unsigned no_db_nodes(); +#endif + private: - friend void* run_ndb_cluster_connection_connect_thread(void*); - void connect_thread(); - char *m_connect_string; - TransporterFacade *m_facade; - LocalConfig *m_local_config; - ConfigRetriever *m_config_retriever; - NdbThread *m_connect_thread; - int (*m_connect_callback)(void); + friend class Ndb; + friend class NdbImpl; + friend class Ndb_cluster_connection_impl; + class Ndb_cluster_connection_impl & m_impl; + Ndb_cluster_connection(Ndb_cluster_connection_impl&); }; #endif diff --git a/ndb/src/common/editline/unix.h b/ndb/include/ndbapi/ndb_opt_defaults.h index 37f461b471d..63b673ed60d 100644 --- a/ndb/src/common/editline/unix.h +++ b/ndb/include/ndbapi/ndb_opt_defaults.h @@ -14,12 +14,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Revision: 1.3 $ -** -** Editline system header file for Unix. -*/ +#ifndef NDB_OPT_DEFAULTS_H +#define NDB_OPT_DEFAULTS_H -#define CRLF "\r\n" +#ifdef SIGRTMIN +#define OPT_NDB_SHM_SIGNUM_DEFAULT SIGRTMIN+2 +#else +#define OPT_NDB_SHM_SIGNUM_DEFAULT 0 +#endif +#define OPT_NDB_SHM_DEFAULT 0 -#include <ndb_global.h> -#include <dirent.h> +#endif diff --git a/ndb/include/ndbapi/ndbapi_limits.h b/ndb/include/ndbapi/ndbapi_limits.h index 1cf2d9b342d..d1cb135b39d 100644 --- a/ndb/include/ndbapi/ndbapi_limits.h +++ b/ndb/include/ndbapi/ndbapi_limits.h @@ -22,12 +22,13 @@ #define NDB_MAX_DATABASE_NAME_SIZE 128 #define NDB_MAX_SCHEMA_NAME_SIZE 128 #define NDB_MAX_TAB_NAME_SIZE 128 -#define NDB_MAX_ATTRIBUTES_IN_TABLE 91 +#define NDB_MAX_ATTR_NAME_SIZE 32 +#define NDB_MAX_ATTRIBUTES_IN_TABLE 128 -#define NDB_MAX_TUPLE_SIZE_IN_WORDS 1023 +#define NDB_MAX_TUPLE_SIZE_IN_WORDS 2013 #define NDB_MAX_KEYSIZE_IN_WORDS 1023 -#define NDB_MAX_KEY_SIZE NDB_MAX_KEYSIZE_IN_WORDS*sizeof(Uint32) -#define NDB_MAX_TUPLE_SIZE NDB_MAX_TUPLE_SIZE_IN_WORDS*sizeof(uint32) +#define NDB_MAX_KEY_SIZE (NDB_MAX_KEYSIZE_IN_WORDS*4) +#define NDB_MAX_TUPLE_SIZE (NDB_MAX_TUPLE_SIZE_IN_WORDS*4) #define NDB_MAX_ACTIVE_EVENTS 100 #endif diff --git a/ndb/include/ndbapi/ndberror.h b/ndb/include/ndbapi/ndberror.h index 5c2d85b82a6..ceb1881a4cc 100644 --- a/ndb/include/ndbapi/ndberror.h +++ b/ndb/include/ndbapi/ndberror.h @@ -46,7 +46,8 @@ typedef enum ndberror_cl_internal_error = 12, ndberror_cl_function_not_implemented = 13, ndberror_cl_unknown_error_code = 14, - ndberror_cl_node_shutdown = 15 + ndberror_cl_node_shutdown = 15, + ndberror_cl_configuration = 16 } ndberror_classification_enum; diff --git a/ndb/include/mgmcommon/NdbConfig.h b/ndb/include/portlib/NdbConfig.h index 1bca825ab8d..1bca825ab8d 100644 --- a/ndb/include/mgmcommon/NdbConfig.h +++ b/ndb/include/portlib/NdbConfig.h diff --git a/ndb/include/portlib/NdbTCP.h b/ndb/include/portlib/NdbTCP.h index 4dc8435eef1..8138a2ef354 100644 --- a/ndb/include/portlib/NdbTCP.h +++ b/ndb/include/portlib/NdbTCP.h @@ -40,7 +40,7 @@ typedef int socklen_t; #define InetErrno (* inet_errno()) -#elif NDB_WIN32 +#elif defined NDB_WIN32 /** * Include files needed diff --git a/ndb/include/portlib/NdbThread.h b/ndb/include/portlib/NdbThread.h index 212f7de9384..e86deee4354 100644 --- a/ndb/include/portlib/NdbThread.h +++ b/ndb/include/portlib/NdbThread.h @@ -76,7 +76,7 @@ int NdbThread_WaitFor(struct NdbThread* p_wait_thread, void** status); * * * status: exit code */ -void NdbThread_Exit(int status); +void NdbThread_Exit(void *status); /** * Set thread concurrency level diff --git a/ndb/include/portlib/PortDefs.h b/ndb/include/portlib/PortDefs.h index b61bb627e65..a115c60cfe1 100644 --- a/ndb/include/portlib/PortDefs.h +++ b/ndb/include/portlib/PortDefs.h @@ -22,55 +22,12 @@ $Id: PortDefs.h,v 1.5 2003/10/07 07:59:59 mikael Exp $ */ -#ifdef NDB_WIN32 -#include <time.h> - - -struct tms -{ - time_t tms_utime; /* user time */ - time_t tms_stime; /* system time */ - time_t tms_cutime; /* user time of children */ - time_t tms_cstime; /* system time of children */ -}; - -struct timespec -{ - long tv_sec; /* Seconds */ - long tv_nsec; /* Nanoseconds */ -}; - -#define strcasecmp(a,b) _strcmpi(a,b) - -/* Exports a WIN32 getopt function */ -extern int optind; -extern char *optarg; -int getopt(int, char **, char *opts); -#endif /* NDB_WIN32 */ #ifdef NDB_ALPHA #ifdef NDB_GCC /* only for NDB_ALPHA */ extern int gnuShouldNotUseRPCC(); #define RPCC() gnuShouldNotUseRPCC(); #else -#ifdef NDB_WIN32 -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - u_int64 __asm(char *, ...); - double __dasm(char *, ...); - float __fasm(char *, ...); - void _AcquireSpinLock(long *); - void _ReleaseSpinLock(long *); - int __ADD_ATOMIC_LONG2(void *, int); -#ifdef __cplusplus -}; -#endif /* __cplusplus */ -#pragma intrinsic (__asm, __dasm, __fasm) -#pragma intrinsic(_ReleaseSpinLock, _AcquireSpinLock) -#pragma intrinsic(__ADD_ATOMIC_LONG2) -#endif /* NDB_WIN32 */ - #define RPCC() ((int)__asm(" rpcc v0;")) #define MB() __asm(" mb;"); #define WMB() __asm(" wmb;"); diff --git a/ndb/include/transporter/TransporterDefinitions.hpp b/ndb/include/transporter/TransporterDefinitions.hpp index a8da8068552..d4763ba4c37 100644 --- a/ndb/include/transporter/TransporterDefinitions.hpp +++ b/ndb/include/transporter/TransporterDefinitions.hpp @@ -68,6 +68,8 @@ struct TCP_TransporterConfiguration { */ struct SHM_TransporterConfiguration { Uint32 port; + const char *remoteHostName; + const char *localHostName; NodeId remoteNodeId; NodeId localNodeId; bool checksum; @@ -75,6 +77,7 @@ struct SHM_TransporterConfiguration { Uint32 shmKey; Uint32 shmSize; + int signum; }; /** diff --git a/ndb/include/transporter/TransporterRegistry.hpp b/ndb/include/transporter/TransporterRegistry.hpp index ac6291f9e57..7487d6b1e80 100644 --- a/ndb/include/transporter/TransporterRegistry.hpp +++ b/ndb/include/transporter/TransporterRegistry.hpp @@ -87,6 +87,7 @@ public: */ class TransporterRegistry { friend class OSE_Receiver; + friend class SHM_Transporter; friend class Transporter; friend class TransporterService; public: @@ -98,7 +99,12 @@ public: unsigned sizeOfLongSignalMemory = 100); bool init(NodeId localNodeId); - + + /** + * after a connect from client, perform connection using correct transporter + */ + bool connect_server(NDB_SOCKET_TYPE sockfd); + /** * Remove all transporters */ @@ -224,7 +230,7 @@ public: const char *m_interface; }; Vector<Transporter_interface> m_transporter_interface; - void add_transporter_interface(const char *interface, unsigned short port); + void add_transporter_interface(const char *interf, unsigned short port); protected: private: @@ -312,6 +318,8 @@ private: Uint32 poll_TCP(Uint32 timeOutMillis); Uint32 poll_SCI(Uint32 timeOutMillis); Uint32 poll_SHM(Uint32 timeOutMillis); + + int m_shm_own_pid; }; #endif // Define of TransporterRegistry_H diff --git a/ndb/include/util/BaseString.hpp b/ndb/include/util/BaseString.hpp index 066a24f294e..02a6a3b3e66 100644 --- a/ndb/include/util/BaseString.hpp +++ b/ndb/include/util/BaseString.hpp @@ -48,10 +48,10 @@ public: bool empty() const; /** @brief Convert to uppercase */ - void ndb_toupper(); + BaseString& ndb_toupper(); /** @brief Convert to lowercase */ - void ndb_tolower(); + BaseString& ndb_tolower(); /** @brief Assigns from a char * */ BaseString& assign(const char* s); @@ -206,16 +206,18 @@ BaseString::empty() const return m_len == 0; } -inline void +inline BaseString& BaseString::ndb_toupper() { for(unsigned i = 0; i < length(); i++) m_chr[i] = toupper(m_chr[i]); + return *this; } -inline void +inline BaseString& BaseString::ndb_tolower() { for(unsigned i = 0; i < length(); i++) m_chr[i] = tolower(m_chr[i]); + return *this; } inline bool diff --git a/ndb/include/util/Bitmask.hpp b/ndb/include/util/Bitmask.hpp index bb217adab5f..19aa604e4a1 100644 --- a/ndb/include/util/Bitmask.hpp +++ b/ndb/include/util/Bitmask.hpp @@ -105,6 +105,11 @@ public: static void bitXOR(unsigned size, Uint32 data[], const Uint32 data2[]); /** + * bitXORC - Bitwise (x ^ ~y) into first operand. + */ + static void bitXORC(unsigned size, Uint32 data[], const Uint32 data2[]); + + /** * contains - Check if all bits set in data2 are set in data */ static bool contains(unsigned size, Uint32 data[], const Uint32 data2[]); @@ -261,6 +266,14 @@ BitmaskImpl::bitXOR(unsigned size, Uint32 data[], const Uint32 data2[]) } } +inline void +BitmaskImpl::bitXORC(unsigned size, Uint32 data[], const Uint32 data2[]) +{ + for (unsigned i = 0; i < size; i++) { + data[i] ^= ~data2[i]; + } +} + inline bool BitmaskImpl::contains(unsigned size, Uint32 data[], const Uint32 data2[]) { @@ -452,6 +465,12 @@ public: BitmaskPOD<size>& bitXOR(const BitmaskPOD<size>& mask2); /** + * bitXORC - Bitwise (x ^ ~y) into first operand. + */ + static void bitXORC(Uint32 data[], const Uint32 data2[]); + BitmaskPOD<size>& bitXORC(const BitmaskPOD<size>& mask2); + + /** * contains - Check if all bits set in data2 (that) are also set in data (this) */ static bool contains(Uint32 data[], const Uint32 data2[]); @@ -713,6 +732,21 @@ BitmaskPOD<size>::bitXOR(const BitmaskPOD<size>& mask2) } template <unsigned size> +inline void +BitmaskPOD<size>::bitXORC(Uint32 data[], const Uint32 data2[]) +{ + BitmaskImpl::bitXORC(size,data, data2); +} + +template <unsigned size> +inline BitmaskPOD<size>& +BitmaskPOD<size>::bitXORC(const BitmaskPOD<size>& mask2) +{ + BitmaskPOD<size>::bitXORC(rep.data, mask2.rep.data); + return *this; +} + +template <unsigned size> char * BitmaskPOD<size>::getText(const Uint32 data[], char* buf) { diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp index 3062d1e4e1b..5b27bd4e0c4 100644 --- a/ndb/include/util/NdbSqlUtil.hpp +++ b/ndb/include/util/NdbSqlUtil.hpp @@ -75,15 +75,19 @@ public: Bigunsigned, // 64 Bit Float, // 32-bit float Double, // 64-bit float - Decimal, // Precision, Scale + Olddecimal, // Precision, Scale Char, // Len Varchar, // Max len Binary, // Len Varbinary, // Max len Datetime, // Precision down to 1 sec (size 8 bytes) - Timespec, // Precision down to 1 nsec (size 12 bytes) + Date, // Precision down to 1 day (size 4 bytes) Blob, // Blob - Text // Text blob + Text, // Text blob + Time = 25, // Time without date + Year = 26, // Year (size 1 byte) + Timestamp = 27, // Unix seconds (uint32) + Olddecimalunsigned = 28 }; Enum m_typeId; Cmp* m_cmp; // comparison method @@ -106,6 +110,11 @@ public: static bool usable_in_hash_index(Uint32 typeId, const void* cs); static bool usable_in_ordered_index(Uint32 typeId, const void* cs); + /** + * Compare decimal numbers. + */ + static int cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n); + private: /** * List of all types. Must match Type::Enum. @@ -126,15 +135,19 @@ private: static Cmp cmpBigunsigned; static Cmp cmpFloat; static Cmp cmpDouble; - static Cmp cmpDecimal; + static Cmp cmpOlddecimal; static Cmp cmpChar; static Cmp cmpVarchar; static Cmp cmpBinary; static Cmp cmpVarbinary; static Cmp cmpDatetime; - static Cmp cmpTimespec; + static Cmp cmpDate; static Cmp cmpBlob; static Cmp cmpText; + static Cmp cmpTime; + static Cmp cmpYear; + static Cmp cmpTimestamp; + static Cmp cmpOlddecimalunsigned; }; #endif diff --git a/ndb/include/util/Parser.hpp b/ndb/include/util/Parser.hpp index 65cf24db633..c117498e1ba 100644 --- a/ndb/include/util/Parser.hpp +++ b/ndb/include/util/Parser.hpp @@ -23,7 +23,7 @@ #include "NdbOut.hpp" class ParserImpl; -template<class T> class ParserRow; +template<class T> struct ParserRow; //#define PARSER_DEBUG #ifdef PARSER_DEBUG @@ -130,11 +130,11 @@ public: * The void* equivalent implementation */ class ParserImpl { +public: class Dummy {}; typedef ParserRow<Dummy> DummyRow; typedef Parser<Dummy>::Context Context; - template<class T> friend class Parser; -private: + ParserImpl(const DummyRow rows[], class InputStream & in, bool b_cmd, bool b_empty, bool b_iarg); diff --git a/ndb/include/util/SimpleProperties.hpp b/ndb/include/util/SimpleProperties.hpp index d5ebb16bb09..356f3406f38 100644 --- a/ndb/include/util/SimpleProperties.hpp +++ b/ndb/include/util/SimpleProperties.hpp @@ -38,20 +38,20 @@ public: /** * Value types */ - enum ValueType { + enum ValueType { Uint32Value = 0, StringValue = 1, BinaryValue = 2, InvalidValue = 3 - }; - + }; + /** * Struct for defining mapping to be used with unpack */ struct SP2StructMapping { Uint16 Key; Uint32 Offset; - SimpleProperties::ValueType Type; + ValueType Type; Uint32 minValue; Uint32 maxValue; Uint32 Length_Offset; // Offset used for looking up length of @@ -233,7 +233,7 @@ private: */ class SimplePropertiesSectionReader : public SimpleProperties::Reader { public: - SimplePropertiesSectionReader(class SegmentedSectionPtr &, + SimplePropertiesSectionReader(struct SegmentedSectionPtr &, class SectionSegmentPool &); virtual void reset(); @@ -248,8 +248,8 @@ private: Uint32 m_pos; Uint32 m_len; class SectionSegmentPool & m_pool; - class SectionSegment * m_head; - class SectionSegment * m_currentSegment; + struct SectionSegment * m_head; + struct SectionSegment * m_currentSegment; }; inline @@ -275,15 +275,15 @@ public: /** * This "unlinks" the writer from the memory */ - void getPtr(class SegmentedSectionPtr & dst); + void getPtr(struct SegmentedSectionPtr & dst); private: Int32 m_pos; Uint32 m_sz; class SectionSegmentPool & m_pool; - class SectionSegment * m_head; + struct SectionSegment * m_head; Uint32 m_prevPtrI; // Prev to m_currentSegment - class SectionSegment * m_currentSegment; + struct SectionSegment * m_currentSegment; }; #endif diff --git a/ndb/include/util/SocketServer.hpp b/ndb/include/util/SocketServer.hpp index 3860b9ca84b..9d8af204391 100644 --- a/ndb/include/util/SocketServer.hpp +++ b/ndb/include/util/SocketServer.hpp @@ -37,7 +37,7 @@ public: public: virtual ~Session() {} virtual void runSession(){} - virtual void stopSession(){} + virtual void stopSession(){ m_stop = true; } protected: friend class SocketServer; friend void* sessionThread_C(void*); @@ -98,6 +98,8 @@ public: */ void stopSessions(bool wait = false); + void foreachSession(void (*f)(Session*, void*), void *data); + private: struct SessionInstance { Service * m_service; diff --git a/ndb/include/util/ndb_opts.h b/ndb/include/util/ndb_opts.h new file mode 100644 index 00000000000..aa7a02f58ae --- /dev/null +++ b/ndb/include/util/ndb_opts.h @@ -0,0 +1,117 @@ +/* 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_OPTS_H +#define _NDB_OPTS_H + +#include <ndb_global.h> +#include <my_sys.h> +#include <my_getopt.h> +#include <mysql_version.h> +#include <ndb_version.h> +#include <ndb_opt_defaults.h> + +#define NDB_STD_OPTS_VARS \ +const char *opt_connect_str= 0;\ +my_bool opt_ndb_optimized_node_selection + +my_bool opt_ndb_shm; + +#define OPT_NDB_CONNECTSTRING 'c' + +#define NDB_STD_OPTS_COMMON \ + { "usage", '?', "Display this help and exit.", \ + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ + { "help", '?', "Display this help and exit.", \ + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ + { "version", 'V', "Output version information and exit.", 0, 0, 0, \ + GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ + { "ndb-connectstring", OPT_NDB_CONNECTSTRING, \ + "Set connect string for connecting to ndb_mgmd. " \ + "Syntax: \"[nodeid=<id>;][host=]<hostname>[:<port>]\". " \ + "Overides specifying entries in NDB_CONNECTSTRING and Ndb.cfg", \ + (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, \ + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ + { "ndb-shm", OPT_NDB_SHM,\ + "Allow optimizing using shared memory connections when available",\ + (gptr*) &opt_ndb_shm, (gptr*) &opt_ndb_shm, 0,\ + GET_BOOL, NO_ARG, OPT_NDB_SHM_DEFAULT, 0, 0, 0, 0, 0 },\ + {"ndb-optimized-node-selection", OPT_NDB_OPTIMIZED_NODE_SELECTION,\ + "Select nodes for transactions in a more optimal way",\ + (gptr*) &opt_ndb_optimized_node_selection,\ + (gptr*) &opt_ndb_optimized_node_selection, 0,\ + GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},\ + { "connect-string", OPT_NDB_CONNECTSTRING, "same as --ndb-connectstring",\ + (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0,\ + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 } + +#ifndef DBUG_OFF +#define NDB_STD_OPTS(prog_name) \ + { "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", \ + 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, \ + NDB_STD_OPTS_COMMON +#else +#define NDB_STD_OPTS(prog_name) NDB_STD_OPTS_COMMON +#endif + +static void ndb_std_print_version() +{ + printf("MySQL distrib %s, for %s (%s)\n", + MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); +} + +static void usage(); + +enum ndb_std_options { + OPT_NDB_SHM= 256, + OPT_NDB_SHM_SIGNUM, + OPT_NDB_OPTIMIZED_NODE_SELECTION, + NDB_STD_OPTIONS_LAST /* should always be last in this enum */ +}; + +static my_bool +ndb_std_get_one_option(int optid, + const struct my_option *opt __attribute__((unused)), + const char *argument) +{ + switch (optid) { + case '#': + if (argument) + { + DBUG_PUSH(argument); + } + break; + case 'V': + ndb_std_print_version(); + exit(0); + case '?': + usage(); + exit(0); + case OPT_NDB_SHM: + if (opt_ndb_shm) + { +#ifndef NDB_SHM_TRANSPORTER + printf("Warning: binary not compiled with shared memory support,\n" + "Tcp connections will now be used instead\n"); + opt_ndb_shm= 0; +#endif + } + break; + } + return 0; +} + +#endif /*_NDB_OPTS_H */ diff --git a/ndb/src/Makefile.am b/ndb/src/Makefile.am index bed43438e91..eb1cf1c6543 100644 --- a/ndb/src/Makefile.am +++ b/ndb/src/Makefile.am @@ -11,8 +11,23 @@ libndbclient_la_LIBADD = \ common/transporter/libtransporter.la \ common/debugger/libtrace.la \ common/debugger/signaldata/libsignaldataprint.la \ - common/mgmcommon/libmgmsrvcommon.la \ mgmapi/libmgmapi.la \ + common/mgmcommon/libmgmsrvcommon.la \ common/logger/liblogger.la \ common/portlib/libportlib.la \ common/util/libgeneral.la + +windoze-dsp: libndbclient.dsp + +libndbclient.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(ndblib_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ dummy.cpp + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(libndbclient_la_LIBADD) + @touch dummy.cpp diff --git a/ndb/src/common/Makefile.am b/ndb/src/common/Makefile.am index 7fcf2cab636..0059f3fb210 100644 --- a/ndb/src/common/Makefile.am +++ b/ndb/src/common/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = portlib debugger util logger transporter mgmcommon editline +SUBDIRS = portlib debugger util logger transporter mgmcommon noinst_LTLIBRARIES = libcommon.la @@ -11,3 +11,5 @@ libcommon_la_LIBADD = \ portlib/libportlib.la \ logger/liblogger.la \ util/libgeneral.la + +windoze-dsp: diff --git a/ndb/src/common/Makefile_old b/ndb/src/common/Makefile_old deleted file mode 100644 index ebde75bf3ec..00000000000 --- a/ndb/src/common/Makefile_old +++ /dev/null @@ -1,15 +0,0 @@ -include .defs.mk - -LIB_DIRS := \ - portlib \ - debugger \ - util \ - logger - -ifneq ($(USE_EDITLINE), N) -LIB_DIRS += editline -endif - -DIRS := transporter mgmcommon - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/common/debugger/EventLogger.cpp b/ndb/src/common/debugger/EventLogger.cpp index 8a09be9a0a7..97945394690 100644 --- a/ndb/src/common/debugger/EventLogger.cpp +++ b/ndb/src/common/debugger/EventLogger.cpp @@ -421,6 +421,11 @@ EventLogger::getText(char * m_text, size_t m_text_len, "%sArbitration check lost - less than 1/2 nodes left", theNodeId); break; + case ArbitCode::WinNodes: + BaseString::snprintf(m_text, m_text_len, + "%sArbitration check won - all node groups and more than 1/2 nodes left", + theNodeId); + break; case ArbitCode::WinGroups: BaseString::snprintf(m_text, m_text_len, "%sArbitration check won - node group majority", @@ -1028,7 +1033,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, "Grep::SSCoord:Error code: %d Error message: %s" " (subId=%d,SubKey=%d)", err, - GrepError::getErrorDesc((GrepError::Code)err), + GrepError::getErrorDesc((GrepError::GE_Code)err), subId, subKey); break; @@ -1045,7 +1050,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepSS_SubStartMetaRef: @@ -1061,7 +1066,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepSS_SubStartDataRef: @@ -1076,7 +1081,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepSS_SubSyncMetaRef: @@ -1091,7 +1096,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepSS_SubSyncDataRef: @@ -1108,7 +1113,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subKey, gci, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepSS_SubRemoveRef: @@ -1123,7 +1128,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err) + GrepError::getErrorDesc((GrepError::GE_Code)err) ); break; } @@ -1137,7 +1142,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, "Grep::PSCoord: Error code: %d Error Message: %s" " (subId=%d,SubKey=%d)", err, - GrepError::getErrorDesc((GrepError::Code)err), + GrepError::getErrorDesc((GrepError::GE_Code)err), subId, subKey); break; @@ -1154,7 +1159,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepPS_SubStartMetaRef: @@ -1170,7 +1175,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepPS_SubStartDataRef: @@ -1185,7 +1190,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepPS_SubSyncMetaRef: @@ -1200,7 +1205,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepPS_SubSyncDataRef: @@ -1217,7 +1222,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subKey, gci, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::GrepPS_SubRemoveRef: @@ -1232,7 +1237,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, subId, subKey, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } case GrepEvent::Rep_Disconnect: @@ -1244,7 +1249,7 @@ EventLogger::getText(char * m_text, size_t m_text_len, " Error code: %d Error Message: %s", nodeId, err, - GrepError::getErrorDesc((GrepError::Code)err)); + GrepError::getErrorDesc((GrepError::GE_Code)err)); break; } @@ -1275,10 +1280,10 @@ EventLogger::getText(char * m_text, size_t m_text_len, case EventReport::BackupCompleted: BaseString::snprintf(m_text, m_text_len, - "%sBackup %d started from node %d completed\n" - " StartGCP: %d StopGCP: %d\n" - " #Records: %d #LogRecords: %d\n" - " Data: %d bytes Log: %d bytes", + "%sBackup %u started from node %u completed\n" + " StartGCP: %u StopGCP: %u\n" + " #Records: %u #LogRecords: %u\n" + " Data: %u bytes Log: %u bytes", theNodeId, theData[2], refToNode(theData[1]), theData[3], theData[4], theData[6], theData[8], theData[5], theData[7]); @@ -1337,27 +1342,41 @@ operator<<(NdbOut& out, const LogLevel & ll) return out; } -void -EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId, - const LogLevel* ll) +int +EventLoggerBase::event_lookup(int eventType, + LogLevel::EventCategory &cat, + Uint32 &threshold, + Logger::LoggerLevel &severity) { - Uint32 threshold = 0; - Logger::LoggerLevel severity = Logger::LL_WARNING; - LogLevel::EventCategory cat= LogLevel::llInvalid; - for(unsigned i = 0; i<EventLoggerBase::matrixSize; i++){ if(EventLoggerBase::matrix[i].eventType == eventType){ cat = EventLoggerBase::matrix[i].eventCategory; threshold = EventLoggerBase::matrix[i].threshold; severity = EventLoggerBase::matrix[i].severity; - break; + return 0; } } + return 1; +} + +void +EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId, + const LogLevel* ll) +{ + Uint32 threshold = 0; + Logger::LoggerLevel severity = Logger::LL_WARNING; + LogLevel::EventCategory cat= LogLevel::llInvalid; + + DBUG_ENTER("EventLogger::log"); + DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId)); - if (cat == LogLevel::llInvalid) - return; + if (EventLoggerBase::event_lookup(eventType,cat,threshold,severity)) + DBUG_VOID_RETURN; Uint32 set = ll?ll->getLogLevel(cat) : m_logLevel.getLogLevel(cat); + DBUG_PRINT("info",("threshold=%d, set=%d", threshold, set)); + if (ll) + DBUG_PRINT("info",("m_logLevel.getLogLevel=%d", m_logLevel.getLogLevel(cat))); if (threshold <= set){ switch (severity){ case Logger::LL_ALERT: @@ -1396,6 +1415,7 @@ EventLogger::log(int eventType, const Uint32* theData, NodeId nodeId, break; } } // if (.. + DBUG_VOID_RETURN; } int diff --git a/ndb/src/common/debugger/GrepError.cpp b/ndb/src/common/debugger/GrepError.cpp index ec0c26a5855..20aeaa6dd77 100644 --- a/ndb/src/common/debugger/GrepError.cpp +++ b/ndb/src/common/debugger/GrepError.cpp @@ -21,7 +21,7 @@ */ const GrepError::ErrorDescription GrepError::errorDescriptions[] = { - { GrepError::NO_ERROR, + { GrepError::GE_NO_ERROR, "No error" }, { GrepError::SUBSCRIPTION_ID_NOMEM, "Not enough resources to allocate the subscription" }, @@ -119,7 +119,7 @@ GrepError::noOfErrorDescs = sizeof(GrepError::errorDescriptions) / * gets the corresponding error message to an err code */ const char * -GrepError::getErrorDesc(GrepError::Code err) { +GrepError::getErrorDesc(GrepError::GE_Code err) { for(Uint32 i = 0; i<noOfErrorDescs; i++){ if(err == errorDescriptions[i].errCode){ diff --git a/ndb/src/common/debugger/Makefile.am b/ndb/src/common/debugger/Makefile.am index d0fb30717cd..e25a11c9bee 100644 --- a/ndb/src/common/debugger/Makefile.am +++ b/ndb/src/common/debugger/Makefile.am @@ -9,3 +9,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libtrace.dsp + +libtrace.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libtrace_la_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/common/debugger/Makefile_old b/ndb/src/common/debugger/Makefile_old deleted file mode 100644 index ac3a4475a54..00000000000 --- a/ndb/src/common/debugger/Makefile_old +++ /dev/null @@ -1,11 +0,0 @@ -include .defs.mk - -TYPE := kernel -DIRS := signaldata - -PIC_ARCHIVE := Y -ARCHIVE_TARGET := trace - -SOURCES = SignalLoggerManager.cpp DebuggerNames.cpp BlockNames.cpp LogLevel.cpp EventLogger.cpp GrepError.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/common/debugger/signaldata/DictTabInfo.cpp b/ndb/src/common/debugger/signaldata/DictTabInfo.cpp index 7e7bf87e2db..c6165532ddb 100644 --- a/ndb/src/common/debugger/signaldata/DictTabInfo.cpp +++ b/ndb/src/common/debugger/signaldata/DictTabInfo.cpp @@ -152,4 +152,4 @@ DictTabInfo::Attribute::init(){ AttributeExtLength = 0, AttributeAutoIncrement = false; memset(AttributeDefaultValue, 0, sizeof(AttributeDefaultValue));//AttributeDefaultValue[0] = 0; -}; +} diff --git a/ndb/src/common/debugger/signaldata/FsCloseReq.cpp b/ndb/src/common/debugger/signaldata/FsCloseReq.cpp index 143250b7db1..df9f3cc9fbc 100644 --- a/ndb/src/common/debugger/signaldata/FsCloseReq.cpp +++ b/ndb/src/common/debugger/signaldata/FsCloseReq.cpp @@ -31,7 +31,7 @@ printFSCLOSEREQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiv sig->userReference); fprintf(output, " Flags: H\'%.8x, ", sig->fileFlag); - if (sig->getRemoveFileFlag(sig->fileFlag) == true) + if (sig->getRemoveFileFlag(sig->fileFlag)) fprintf(output, "Remove file"); else fprintf(output, "Don't remove file"); diff --git a/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp b/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp index 9b32fab87ba..a9f240d3cb4 100644 --- a/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp +++ b/ndb/src/common/debugger/signaldata/FsReadWriteReq.cpp @@ -31,7 +31,7 @@ printFSREADWRITEREQ(FILE * output, const Uint32 * theData, fprintf(output, " UserReference: H\'%.8x", sig->userReference); fprintf(output, " Operation flag: H\'%.8x (", sig->operationFlag); - if (sig->getSyncFlag(sig->operationFlag) == true) + if (sig->getSyncFlag(sig->operationFlag)) fprintf(output, "Sync,"); else fprintf(output, "No sync,"); diff --git a/ndb/src/common/debugger/signaldata/Makefile.am b/ndb/src/common/debugger/signaldata/Makefile.am index c855c5f8a18..9146d552568 100644 --- a/ndb/src/common/debugger/signaldata/Makefile.am +++ b/ndb/src/common/debugger/signaldata/Makefile.am @@ -32,3 +32,16 @@ include $(top_srcdir)/ndb/config/type_ndbapi.mk.am # Don't update the files from bitkeeper %::SCCS/s.% +windoze-dsp: libsignaldataprint.dsp + +libsignaldataprint.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libsignaldataprint_la_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/common/debugger/signaldata/Makefile_old b/ndb/src/common/debugger/signaldata/Makefile_old deleted file mode 100644 index bd00667b482..00000000000 --- a/ndb/src/common/debugger/signaldata/Makefile_old +++ /dev/null @@ -1,33 +0,0 @@ -include .defs.mk - -TYPE := ndbapi - -PIC_ARCHIVE := Y -ARCHIVE_TARGET := signaldataprint - -SOURCES = TcKeyReq.cpp TcKeyConf.cpp TcKeyRef.cpp \ - TcRollbackRep.cpp \ - TupKey.cpp TupCommit.cpp LqhKey.cpp \ - FsOpenReq.cpp FsCloseReq.cpp FsRef.cpp FsConf.cpp FsReadWriteReq.cpp\ - SignalDataPrint.cpp SignalNames.cpp \ - ContinueB.cpp DihContinueB.cpp NdbfsContinueB.cpp \ - CloseComReqConf.cpp PackedSignal.cpp PrepFailReqRef.cpp \ - GCPSave.cpp DictTabInfo.cpp \ - AlterTable.cpp AlterTab.cpp \ - CreateTrig.cpp AlterTrig.cpp DropTrig.cpp \ - FireTrigOrd.cpp TrigAttrInfo.cpp \ - CreateIndx.cpp AlterIndx.cpp DropIndx.cpp TcIndx.cpp \ - IndxKeyInfo.cpp IndxAttrInfo.cpp \ - FsAppendReq.cpp ScanTab.cpp \ - BackupImpl.cpp BackupSignalData.cpp \ - UtilSequence.cpp UtilPrepare.cpp UtilDelete.cpp UtilExecute.cpp \ - LqhFrag.cpp DropTab.cpp PrepDropTab.cpp LCP.cpp MasterLCP.cpp \ - CopyGCI.cpp SystemError.cpp StartRec.cpp NFCompleteRep.cpp \ - FailRep.cpp DisconnectRep.cpp SignalDroppedRep.cpp \ - SumaImpl.cpp NdbSttor.cpp CreateFragmentation.cpp \ - CntrStart.cpp ReadNodesConf.cpp \ - UtilLock.cpp TuxMaint.cpp TupAccess.cpp AccLock.cpp \ - LqhTrans.cpp - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/src/common/debugger/signaldata/NFCompleteRep.cpp b/ndb/src/common/debugger/signaldata/NFCompleteRep.cpp index 20f7ea99871..f2d6f2f104a 100644 --- a/ndb/src/common/debugger/signaldata/NFCompleteRep.cpp +++ b/ndb/src/common/debugger/signaldata/NFCompleteRep.cpp @@ -41,4 +41,4 @@ printNF_COMPLETE_REP(FILE * output, sig->from); return true; -}; +} diff --git a/ndb/src/common/debugger/signaldata/ScanTab.cpp b/ndb/src/common/debugger/signaldata/ScanTab.cpp index 72a4d9f94b9..0755ee0a856 100644 --- a/ndb/src/common/debugger/signaldata/ScanTab.cpp +++ b/ndb/src/common/debugger/signaldata/ScanTab.cpp @@ -30,13 +30,14 @@ printSCANTABREQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiv fprintf(output, " apiConnectPtr: H\'%.8x", sig->apiConnectPtr); fprintf(output, " requestInfo: H\'%.8x:\n", requestInfo); - fprintf(output, " Parallellism: %u, Batch: %u LockMode: %u, Keyinfo: %u Holdlock: %u, RangeScan: %u\n", + fprintf(output, " Parallellism: %u, Batch: %u LockMode: %u, Keyinfo: %u Holdlock: %u, RangeScan: %u ReadCommitted: %u\n", sig->getParallelism(requestInfo), sig->getScanBatch(requestInfo), sig->getLockMode(requestInfo), + sig->getKeyinfoFlag(requestInfo), sig->getHoldLockFlag(requestInfo), sig->getRangeScanFlag(requestInfo), - sig->getKeyinfoFlag(requestInfo)); + sig->getReadCommittedFlag(requestInfo)); Uint32 keyLen = (sig->attrLenKeyLen >> 16); Uint32 attrLen = (sig->attrLenKeyLen & 0xFFFF); diff --git a/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp b/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp index 3314f0bd097..a4cee38e06f 100644 --- a/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp +++ b/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp @@ -16,65 +16,9 @@ -#include "GlobalSignalNumbers.h" -#include "signaldata/SignalDataPrint.hpp" -#include "signaldata/TcKeyReq.hpp" -#include "signaldata/TcKeyConf.hpp" -#include "signaldata/TcKeyRef.hpp" -#include "signaldata/LqhKey.hpp" -#include "signaldata/TupKey.hpp" -#include "signaldata/TupCommit.hpp" -#include "signaldata/FsOpenReq.hpp" -#include "signaldata/FsCloseReq.hpp" -#include "signaldata/FsReadWriteReq.hpp" -#include "signaldata/FsRef.hpp" -#include "signaldata/FsConf.hpp" -#include "signaldata/CloseComReqConf.hpp" -#include "signaldata/PackedSignal.hpp" -#include "signaldata/PrepFailReqRef.hpp" -#include "signaldata/DictTabInfo.hpp" -#include "signaldata/AlterTable.hpp" -#include "signaldata/AlterTab.hpp" -#include "signaldata/CreateTrig.hpp" -#include "signaldata/AlterTrig.hpp" -#include "signaldata/DropTrig.hpp" -#include "signaldata/FireTrigOrd.hpp" -#include "signaldata/TrigAttrInfo.hpp" -#include "signaldata/CreateIndx.hpp" -#include "signaldata/AlterIndx.hpp" -#include "signaldata/DropIndx.hpp" -#include "signaldata/TcIndx.hpp" -#include "signaldata/IndxKeyInfo.hpp" -#include "signaldata/IndxAttrInfo.hpp" -#include <signaldata/FsAppendReq.hpp> -#include <signaldata/BackupSignalData.hpp> -#include <signaldata/BackupImpl.hpp> -#include <signaldata/UtilSequence.hpp> -#include <signaldata/UtilPrepare.hpp> -#include <signaldata/UtilExecute.hpp> -#include <signaldata/ScanTab.hpp> -#include <signaldata/ScanFrag.hpp> -#include <signaldata/LqhFrag.hpp> -#include <signaldata/LqhTransConf.hpp> -#include <signaldata/DropTab.hpp> -#include <signaldata/PrepDropTab.hpp> -#include <signaldata/LCP.hpp> -#include <signaldata/MasterLCP.hpp> -#include <signaldata/CopyGCIReq.hpp> -#include <signaldata/SystemError.hpp> -#include <signaldata/StartRec.hpp> -#include <signaldata/NFCompleteRep.hpp> -#include <signaldata/SignalDroppedRep.hpp> -#include <signaldata/FailRep.hpp> -#include <signaldata/DisconnectRep.hpp> -#include <signaldata/SumaImpl.hpp> -#include <signaldata/NdbSttor.hpp> -#include <signaldata/CreateFragmentation.hpp> -#include <signaldata/UtilLock.hpp> -#include <signaldata/CntrStart.hpp> -#include <signaldata/ReadNodesConf.hpp> -#include <signaldata/TuxMaint.hpp> -#include <signaldata/AccLock.hpp> +#include <GlobalSignalNumbers.h> +#include <signaldata/SignalData.hpp> +#include <signaldata/SignalDataPrint.hpp> /** * This is the register @@ -254,9 +198,11 @@ SignalDataPrintFunctions[] = { ,{ 0, 0 } }; -template class Bitmask<1>; -template class Bitmask<2>; -template class Bitmask<4>; +#include <Bitmask.hpp> + template struct BitmaskPOD<1>; template struct BitmaskPOD<2>; template struct BitmaskPOD<4>; +template class Bitmask<1>; +template class Bitmask<2>; +template class Bitmask<4>; diff --git a/ndb/src/common/editline/MANIFEST b/ndb/src/common/editline/MANIFEST deleted file mode 100644 index dc8b4b36f88..00000000000 --- a/ndb/src/common/editline/MANIFEST +++ /dev/null @@ -1,15 +0,0 @@ -File Name Description --------------------------------------------------------- -README Release notes and copyright -MANIFEST This shipping list -Make.os9 OS-9 makefile -Makefile Unix makefile -complete.c Filename completion routines -editline.3 Manual page for editline library -editline.c Line-editing routines -editline_internal.h Internal library header file -os9.h OS-9-specific declarations -sysos9.c OS-9-specific routines -sysunix.c Unix-specific routines -testit.c Test driver -unix.h Unix-specific declarations diff --git a/ndb/src/common/editline/Makefile.am b/ndb/src/common/editline/Makefile.am deleted file mode 100644 index 4f53bdc6326..00000000000 --- a/ndb/src/common/editline/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ - -noinst_LIBRARIES = libeditline.a - -libeditline_a_SOURCES = complete.c editline.c sysunix.c - -INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/ndb/include -DEFS = -DANSI_ARROWS -DHAVE_TCGETATTR -DSYS_UNIX - -# Don't update the files from bitkeeper -%::SCCS/s.% diff --git a/ndb/src/common/editline/Makefile_old b/ndb/src/common/editline/Makefile_old deleted file mode 100644 index 800df8f0f31..00000000000 --- a/ndb/src/common/editline/Makefile_old +++ /dev/null @@ -1,18 +0,0 @@ -include .defs.mk - -TYPE := - -ARCHIVE_TARGET := editline - -CFLAGS += -DANSI_ARROWS -DHAVE_TCGETATTR -DSYS_UNIX - -ifeq ($(NDB_OS), WIN32) -SOURCES = editline_win32.c -else -SOURCES = complete.c editline.c sysunix.c -endif - -DIRS := test - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/src/common/editline/README b/ndb/src/common/editline/README deleted file mode 100644 index 537c7bd8611..00000000000 --- a/ndb/src/common/editline/README +++ /dev/null @@ -1,53 +0,0 @@ --- -NOTE: This version has been modified by Ericsson/Alzato. Please -see the cvs changelog for more details. --- - -$Revision: 1.2 $ - -This is a line-editing library. It can be linked into almost any -program to provide command-line editing and recall. - -It is call-compatible with the FSF readline library, but it is a -fraction of the size (and offers fewer features). It does not use -standard I/O. It is distributed under a "C News-like" copyright. - -Configuration is done in the Makefile. Type "make testit" to get -a small slow shell for testing. - -This contains some changes since the posting to comp.sources.misc: - - Bugfix for completion on absolute pathnames. - - Better handling of M-n versus showing raw 8bit chars. - - Better signal handling. - - Now supports termios/termio/sgttyb ioctl's. - - Add M-m command to toggle how 8bit data is displayed. -The following changes, made since the last public release, come from -J.G. Vons <vons@cesar.crbca1.sinet.slb.com>: - - History-searching no longer redraws the line wrong - - Added ESC-ESC as synonym for ESC-? - - SIGQUIT (normally ^\) now sends a signal, not indicating EOF. - - Fixed some typo's and unclear wording in the manpage. - - Fixed completion when all entries shared a common prefix. - - Fixed some meta-char line-redrawing bugs. - -Enjoy, - Rich $alz - <rsalz@osf.org> - - Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved. - - This software is not subject to any license of the American Telephone - and Telegraph Company or of the Regents of the University of California. - - Permission is granted to anyone to use this software for any purpose on - any computer system, and to alter it and redistribute it freely, subject - to the following restrictions: - 1. The authors are not responsible for the consequences of use of this - software, no matter how awful, even if they arise from flaws in it. - 2. The origin of this software must not be misrepresented, either by - explicit claim or by omission. Since few users ever read sources, - credits must appear in the documentation. - 3. Altered versions must be plainly marked as such, and must not be - misrepresented as being the original software. Since few users - ever read sources, credits must appear in the documentation. - 4. This notice may not be removed or altered. diff --git a/ndb/src/common/editline/complete.c b/ndb/src/common/editline/complete.c deleted file mode 100644 index d1f8b1d3ff4..00000000000 --- a/ndb/src/common/editline/complete.c +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; 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 */ - -/* -*- c-basic-offset: 4; -*- -** $Revision: 1.8 $ -** -** History and file completion functions for editline library. -*/ -#include "editline_internal.h" - - -/* -** strcmp-like sorting predicate for qsort. -*/ -static int -compare(const void *p1, const void *p2) -{ - const char **v1; - const char **v2; - - v1 = (const char **)p1; - v2 = (const char **)p2; - return strcmp(*v1, *v2); -} - -/* -** Fill in *avp with an array of names that match file, up to its length. -** Ignore . and .. . -*/ -static int -FindMatches(char *dir, char *file, char ***avp) -{ - char **av; - char **new; - char *p; - DIR *dp; - struct dirent *ep; - size_t ac; - size_t len; - - if ((dp = opendir(dir)) == NULL) - return 0; - - av = NULL; - ac = 0; - len = strlen(file); - while ((ep = readdir(dp)) != NULL) { - p = ep->d_name; - if (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0'))) - continue; - if (len && strncmp(p, file, len) != 0) - continue; - - if ((ac % MEM_INC) == 0) { - if ((new = malloc(sizeof(char*) * (ac + MEM_INC))) == NULL) - break; - if (ac) { - memcpy(new, av, ac * sizeof (char **)); - free(av); - } - *avp = av = new; - } - - if ((av[ac] = strdup(p)) == NULL) { - if (ac == 0) - free(av); - break; - } - ac++; - } - - /* Clean up and return. */ - (void)closedir(dp); - if (ac) - qsort(av, ac, sizeof (char **), compare); - return ac; -} - -/* -** Split a pathname into allocated directory and trailing filename parts. -*/ -static int -SplitPath(char *path, char **dirpart, char ** filepart) -{ - static char DOT[] = "."; - char *dpart; - char *fpart; - - if ((fpart = strrchr(path, '/')) == NULL) { - if ((dpart = strdup(DOT)) == NULL) - return -1; - if ((fpart = strdup(path)) == NULL) { - free(dpart); - return -1; - } - } - else { - if ((dpart = strdup(path)) == NULL) - return -1; - dpart[fpart - path + 1] = '\0'; - if ((fpart = strdup(++fpart)) == NULL) { - free(dpart); - return -1; - } - } - *dirpart = dpart; - *filepart = fpart; - return 0; -} - -/* -** Attempt to complete the pathname, returning an allocated copy. -** Fill in *unique if we completed it, or set it to 0 if ambiguous. -*/ -char * -rl_complete(char *pathname,int *unique) -{ - char **av; - char *dir; - char *file; - char *new; - char *p; - size_t ac; - size_t end; - size_t i; - size_t j; - size_t len; - size_t new_len; - size_t p_len; - - if (SplitPath(pathname, &dir, &file) < 0) - return NULL; - if ((ac = FindMatches(dir, file, &av)) == 0) { - free(dir); - free(file); - return NULL; - } - - p = NULL; - len = strlen(file); - if (ac == 1) { - /* Exactly one match -- finish it off. */ - *unique = 1; - j = strlen(av[0]) - len + 2; - p_len = sizeof(char) * (j + 1); - if ((p = malloc(p_len)) != NULL) { - memcpy(p, av[0] + len, j); - new_len = sizeof(char) * (strlen(dir) + strlen(av[0]) + 2); - new = malloc(new_len); - if(new != NULL) { - snprintf(new, new_len, "%s/%s", dir, av[0]); - rl_add_slash(new, p, p_len); - free(new); - } - } - } - else { - /* Find largest matching substring. */ - for (*unique = 0, i = len, end = strlen(av[0]); i < end; i++) - for (j = 1; j < ac; j++) - if (av[0][i] != av[j][i]) - goto breakout; -breakout: - if (i > len) { - j = i - len + 1; - if ((p = malloc(sizeof(char) * j)) != NULL) { - memcpy(p, av[0] + len, j); - p[j - 1] = '\0'; - } - } - } - - /* Clean up and return. */ - free(dir); - free(file); - for (i = 0; i < ac; i++) - free(av[i]); - free(av); - return p; -} - -/* -** Return all possible completions. -*/ -int -rl_list_possib(char *pathname, char ***avp) -{ - char *dir; - char *file; - int ac; - - if (SplitPath(pathname, &dir, &file) < 0) - return 0; - ac = FindMatches(dir, file, avp); - free(dir); - free(file); - return ac; -} diff --git a/ndb/src/common/editline/editline.3 b/ndb/src/common/editline/editline.3 deleted file mode 100644 index 159cc7f87bb..00000000000 --- a/ndb/src/common/editline/editline.3 +++ /dev/null @@ -1,178 +0,0 @@ -.\" $Revision: 1.1 $ -.TH EDITLINE 3 -.SH NAME -editline \- command-line editing library with history -.SH SYNOPSIS -.nf -.B "char *" -.B "readline(prompt)" -.B " char *prompt;" - -.B "void" -.B "add_history(line)" -.B " char *line;" -.fi -.SH DESCRIPTION -.I Editline -is a library that provides an line-editing interface with text recall. -It is intended to be compatible with the -.I readline -library provided by the Free Software Foundation, but much smaller. -The bulk of this manual page describes the user interface. -.PP -The -.I readline -routine returns a line of text with the trailing newline removed. -The data is returned in a buffer allocated with -.IR malloc (3), -so the space should be released with -.IR free (3) -when the calling program is done with it. -Before accepting input from the user, the specified -.I prompt -is displayed on the terminal. -.PP -The -.I add_history -routine makes a copy of the specified -.I line -and adds it to the internal history list. -.SS "User Interface" -A program that uses this library provides a simple emacs-like editing -interface to its users. -A line may be edited before it is sent to the calling program by typing either -control characters or escape sequences. -A control character, shown as a caret followed by a letter, is typed by -holding down the ``control'' key while the letter is typed. -For example, ``^A'' is a control-A. -An escape sequence is entered by typing the ``escape'' key followed by one or -more characters. -The escape key is abbreviated as ``ESC''. -Note that unlike control keys, case matters in escape sequences; ``ESC\ F'' -is not the same as ``ESC\ f''. -.PP -An editing command may be typed anywhere on the line, not just at the -beginning. -In addition, a return may also be typed anywhere on the line, not just at -the end. -.PP -Most editing commands may be given a repeat count, -.IR n , -where -.I n -is a number. -To enter a repeat count, type the escape key, the number, and then -the command to execute. -For example, ``ESC\ 4\ ^f'' moves forward four characters. -If a command may be given a repeat count then the text ``[n]'' is given at the -end of its description. -.PP -The following control characters are accepted: -.RS -.nf -.ta \w'ESC DEL 'u -^A Move to the beginning of the line -^B Move left (backwards) [n] -^D Delete character [n] -^E Move to end of line -^F Move right (forwards) [n] -^G Ring the bell -^H Delete character before cursor (backspace key) [n] -^I Complete filename (tab key); see below -^J Done with line (return key) -^K Kill to end of line (or column [n]) -^L Redisplay line -^M Done with line (alternate return key) -^N Get next line from history [n] -^P Get previous line from history [n] -^R Search backward (forward if [n]) through history for text; -\& prefixing the string with a caret (^) forces it to -\& match only at the beginning of a history line -^T Transpose characters -^V Insert next character, even if it is an edit command -^W Wipe to the mark -^X^X Exchange current location and mark -^Y Yank back last killed text -^[ Start an escape sequence (escape key) -^]c Move forward to next character ``c'' -^? Delete character before cursor (delete key) [n] -.fi -.RE -.PP -The following escape sequences are provided. -.RS -.nf -.ta \w'ESC DEL 'u -ESC\ ^H Delete previous word (backspace key) [n] -ESC\ DEL Delete previous word (delete key) [n] -ESC\ ESC Show possible completions; see below -ESC\ SP Set the mark (space key); see ^X^X and ^Y above -ESC\ . Get the last (or [n]'th) word from previous line -ESC\ ? Show possible completions; see below -ESC\ < Move to start of history -ESC\ > Move to end of history -ESC\ b Move backward a word [n] -ESC\ d Delete word under cursor [n] -ESC\ f Move forward a word [n] -ESC\ l Make word lowercase [n] -ESC\ m Toggle if 8bit chars display as themselves or with -\& an ``M\-'' prefix -ESC\ u Make word uppercase [n] -ESC\ y Yank back last killed text -ESC\ w Make area up to mark yankable -ESC\ nn Set repeat count to the number nn -ESC\ C Read from environment variable ``_C_'', where C is -\& an uppercase letter -.fi -.RE -.PP -The -.I editline -library has a small macro facility. -If you type the escape key followed by an uppercase letter, -.IR C , -then the contents of the environment variable -.I _C_ -are read in as if you had typed them at the keyboard. -For example, if the variable -.I _L_ -contains the following: -.RS -^A^Kecho '^V^[[H^V^[[2J'^M -.RE -Then typing ``ESC L'' will move to the beginning of the line, kill the -entire line, enter the echo command needed to clear the terminal (if your -terminal is like a VT-100), and send the line back to the shell. -.PP -The -.I editline -library also does filename completion. -Suppose the root directory has the following files in it: -.RS -.nf -.ta \w'core 'u -bin vmunix -core vmunix.old -.fi -.RE -If you type ``rm\ /v'' and then the tab key. -.I Editline -will then finish off as much of the name as possible by adding ``munix''. -Because the name is not unique, it will then beep. -If you type the escape key followed by either a question mark or another -escape, it will display the two choices. -If you then type a period and a tab, the library will finish off the filename -for you: -.RS -.nf -.RI "rm /v[TAB]" munix ".[TAB]" old -.fi -.RE -The tab key is shown by ``[TAB]'' and the automatically-entered text -is shown in italics. -.SH "BUGS AND LIMITATIONS" -Cannot handle lines more than 80 columns. -.SH AUTHORS -Simmule R. Turner <uunet.uu.net!capitol!sysgo!simmy> -and Rich $alz <rsalz@osf.org>. -Original manual page by DaviD W. Sanderson <dws@ssec.wisc.edu>. diff --git a/ndb/src/common/editline/editline.c b/ndb/src/common/editline/editline.c deleted file mode 100644 index 1e4c1ecba76..00000000000 --- a/ndb/src/common/editline/editline.c +++ /dev/null @@ -1,1514 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; 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 */ - -/* -*- c-basic-offset: 4; -*- -** $Revision: 1.6 $ -** -** Main editing routines for editline library. -*/ -#include <ndb_global.h> - -#include "editline_internal.h" -#include <signal.h> - -/* -** Manifest constants. -*/ -#define SCREEN_WIDTH 80 -#define SCREEN_ROWS 24 -#define NO_ARG (-1) -#define DEL 127 -#define TAB '\t' -#define CTL(x) ((x) & 0x1F) -#define ISCTL(x) ((x) && (x) < ' ') -#define UNCTL(x) ((x) + 64) -#define META(x) ((x) | 0x80) -#define ISMETA(x) ((x) & 0x80) -#define UNMETA(x) ((x) & 0x7F) -#define MAPSIZE 32 -#define METAMAPSIZE 16 -#if !defined(HIST_SIZE) -#define HIST_SIZE 20 -#endif /* !defined(HIST_SIZE) */ - -/* -** Command status codes. -*/ -typedef enum _STATUS { - CSdone, CSeof, CSmove, CSdispatch, CSstay, CSsignal -} STATUS; - -/* -** The type of case-changing to perform. -*/ -typedef enum _CASE { - TOupper, TOlower -} CASE; - -/* -** Key to command mapping. -*/ -typedef struct _KEYMAP { - char Key; - char Active; - STATUS (*Function)(); -} KEYMAP; - -/* -** Command history structure. -*/ -typedef struct _HISTORY { - int Size; - int Pos; - char *Lines[HIST_SIZE]; -} HISTORY; - -/* -** Globals. -*/ -int rl_eof; -int rl_erase; -int rl_intr; -int rl_kill; -int rl_quit; -#if defined(DO_SIGTSTP) -int rl_susp; -#endif /* defined(DO_SIGTSTP) */ - -static char NIL[] = ""; -static const char *Input = NIL; -static char *Line; -static const char *Prompt; -static char *Yanked; -static char *Screen; -static char NEWLINE[]= CRLF; -static HISTORY H; -static int Repeat; -static int End; -static int Mark; -static int OldPoint; -static int Point; -static int PushBack; -static int Pushed; -static int Signal; -static KEYMAP Map[MAPSIZE]; -static KEYMAP MetaMap[METAMAPSIZE]; -static size_t Length; -static size_t ScreenCount; -static size_t ScreenSize; -static char *backspace; -static int TTYwidth; -static int TTYrows; - -/* Display print 8-bit chars as `M-x' or as the actual 8-bit char? */ -int rl_meta_chars = 1; - -/* -** Declarations. -*/ -static char *editinput(); - -#if defined(USE_TERMCAP) -extern char *getenv(); -extern char *tgetstr(); -extern int tgetent(); -extern int tgetnum(); -#endif /* defined(USE_TERMCAP) */ - -/* -** TTY input/output functions. -*/ - -static void -TTYflush() -{ - if (ScreenCount) { - (void)write(1, Screen, ScreenCount); - ScreenCount = 0; - } -} - -static void -TTYput(const char c) -{ - Screen[ScreenCount] = c; - if (++ScreenCount >= ScreenSize - 1) { - ScreenSize += SCREEN_INC; - Screen = realloc(Screen, sizeof(char) * ScreenSize); - /* XXX what to do if realloc failes? */ - } -} - -static void -TTYputs(const char *p) -{ - while (*p) - TTYput(*p++); -} - -static void -TTYshow(char c) -{ - if (c == DEL) { - TTYput('^'); - TTYput('?'); - } - else if (c == TAB) { - /* XXX */ - } - else if (ISCTL(c)) { - TTYput('^'); - TTYput(UNCTL(c)); - } - else if (rl_meta_chars && ISMETA(c)) { - TTYput('M'); - TTYput('-'); - TTYput(UNMETA(c)); - } - else - TTYput(c); -} - -static void -TTYstring(char *p) -{ - while (*p) - TTYshow(*p++); -} - -static int -TTYget() -{ - char c; - - TTYflush(); - if (Pushed) { - Pushed = 0; - return PushBack; - } - if (*Input) - return *Input++; - return read(0, &c, (size_t)1) == 1 ? c : EOF; -} - -#define TTYback() (backspace ? TTYputs((const char *)backspace) : TTYput('\b')) - -static void -TTYbackn(int n) -{ - while (--n >= 0) - TTYback(); -} - -static void -TTYinfo() -{ - static int init; -#if defined(USE_TERMCAP) - char *term; - char buff[2048]; - char *bp; - char *p; -#endif /* defined(USE_TERMCAP) */ -#if defined(TIOCGWINSZ) - struct winsize W; -#endif /* defined(TIOCGWINSZ) */ - - if (init) { -#if defined(TIOCGWINSZ) - /* Perhaps we got resized. */ - if (ioctl(0, TIOCGWINSZ, &W) >= 0 - && W.ws_col > 0 && W.ws_row > 0) { - TTYwidth = (int)W.ws_col; - TTYrows = (int)W.ws_row; - } -#endif /* defined(TIOCGWINSZ) */ - return; - } - init++; - - TTYwidth = TTYrows = 0; -#if defined(USE_TERMCAP) - bp = &buff[0]; - if ((term = getenv("TERM")) == NULL) - term = "dumb"; - if (tgetent(buff, term) < 0) { - TTYwidth = SCREEN_WIDTH; - TTYrows = SCREEN_ROWS; - return; - } - p = tgetstr("le", &bp); - backspace = p ? strdup(p) : NULL; - TTYwidth = tgetnum("co"); - TTYrows = tgetnum("li"); -#endif /* defined(USE_TERMCAP) */ - -#if defined(TIOCGWINSZ) - if (ioctl(0, TIOCGWINSZ, &W) >= 0) { - TTYwidth = (int)W.ws_col; - TTYrows = (int)W.ws_row; - } -#endif /* defined(TIOCGWINSZ) */ - - if (TTYwidth <= 0 || TTYrows <= 0) { - TTYwidth = SCREEN_WIDTH; - TTYrows = SCREEN_ROWS; - } -} - - -/* -** Print an array of words in columns. -*/ -static void -columns(int ac, char **av) -{ - char *p; - int i; - int j; - int k; - int len; - int skip; - int longest; - int cols; - - /* Find longest name, determine column count from that. */ - for (longest = 0, i = 0; i < ac; i++) - if ((j = strlen((char *)av[i])) > longest) - longest = j; - cols = TTYwidth / (longest + 3); - - TTYputs((const char *)NEWLINE); - for (skip = ac / cols + 1, i = 0; i < skip; i++) { - for (j = i; j < ac; j += skip) { - for (p = av[j], len = strlen((char *)p), k = len; --k >= 0; p++) - TTYput(*p); - if (j + skip < ac) - while (++len < longest + 3) - TTYput(' '); - } - TTYputs((const char *)NEWLINE); - } -} - -static void -reposition() -{ - int i; - char *p; - - TTYput('\r'); - TTYputs((const char *)Prompt); - for (i = Point, p = Line; --i >= 0; p++) - TTYshow(*p); -} - -static void -left(STATUS Change) -{ - char c; - - TTYback(); - if (Point) { - c = Line[Point - 1]; - if (c == TAB) { - /* XXX */ - } - else if (ISCTL(c)) - TTYback(); - else if (rl_meta_chars && ISMETA(c)) { - TTYback(); - TTYback(); - } - } - if (Change == CSmove) - Point--; -} - -static void -right(STATUS Change) -{ - TTYshow(Line[Point]); - if (Change == CSmove) - Point++; -} - -static STATUS -ring_bell() -{ - TTYput('\07'); - TTYflush(); - return CSstay; -} - -static STATUS -do_macro(int c) -{ - char name[4]; - - name[0] = '_'; - name[1] = c; - name[2] = '_'; - name[3] = '\0'; - - if ((Input = (char *)getenv((char *)name)) == NULL) { - Input = NIL; - return ring_bell(); - } - return CSstay; -} - -static STATUS -do_forward(STATUS move) -{ - int i; - char *p; - - i = 0; - do { - p = &Line[Point]; - for ( ; Point < End && (*p == ' ' || !isalnum((int)*p)); Point++, p++) - if (move == CSmove) - right(CSstay); - - for (; Point < End && isalnum((int)*p); Point++, p++) - if (move == CSmove) - right(CSstay); - - if (Point == End) - break; - } while (++i < Repeat); - - return CSstay; -} - -static STATUS -do_case(CASE type) -{ - int i; - int end; - int count; - char *p; - - (void)do_forward(CSstay); - if (OldPoint != Point) { - if ((count = Point - OldPoint) < 0) - count = -count; - Point = OldPoint; - if ((end = Point + count) > End) - end = End; - for (i = Point, p = &Line[i]; i < end; i++, p++) { - if (type == TOupper) { - if (islower((int)*p)) - *p = toupper((int)*p); - } - else if (isupper((int)*p)) - *p = tolower((int)*p); - right(CSmove); - } - } - return CSstay; -} - -static STATUS -case_down_word() -{ - return do_case(TOlower); -} - -static STATUS -case_up_word() -{ - return do_case(TOupper); -} - -static void -ceol() -{ - int extras; - int i; - char *p; - - for (extras = 0, i = Point, p = &Line[i]; i <= End; i++, p++) { - TTYput(' '); - if (*p == TAB) { - /* XXX */ - } - else if (ISCTL(*p)) { - TTYput(' '); - extras++; - } - else if (rl_meta_chars && ISMETA(*p)) { - TTYput(' '); - TTYput(' '); - extras += 2; - } - } - - for (i += extras; i > Point; i--) - TTYback(); -} - -static void -clear_line() -{ - Point = -strlen(Prompt); - TTYput('\r'); - ceol(); - Point = 0; - End = 0; - Line[0] = '\0'; -} - -static STATUS -insert_string(char *p) -{ - size_t len; - int i; - char *new; - char *q; - - len = strlen((char *)p); - if (End + len >= Length) { - if ((new = malloc(sizeof(char) * (Length + len + MEM_INC))) == NULL) - return CSstay; - if (Length) { - memcpy(new, Line, Length); - free(Line); - } - Line = new; - Length += len + MEM_INC; - } - - for (q = &Line[Point], i = End - Point; --i >= 0; ) - q[len + i] = q[i]; - memcpy(&Line[Point], p, len); - End += len; - Line[End] = '\0'; - TTYstring(&Line[Point]); - Point += len; - - return Point == End ? CSstay : CSmove; -} - -static STATUS -redisplay() -{ - TTYputs((const char *)NEWLINE); - TTYputs((const char *)Prompt); - TTYstring(Line); - return CSmove; -} - -static STATUS -redisplay_no_nl() -{ - TTYput('\r'); - TTYputs((const char *)Prompt); - TTYstring(Line); - return CSmove; -} - -static STATUS -toggle_meta_mode() -{ - rl_meta_chars = !rl_meta_chars; - return redisplay(); -} - - -static char * -next_hist() -{ - return H.Pos >= H.Size - 1 ? NULL : H.Lines[++H.Pos]; -} - -static char * -prev_hist() -{ - return H.Pos == 0 ? NULL : H.Lines[--H.Pos]; -} - -static STATUS -do_insert_hist(char *p) -{ - if (p == NULL) - return ring_bell(); - Point = 0; - reposition(); - ceol(); - End = 0; - return insert_string(p); -} - -static STATUS -do_hist(char *(*move)()) -{ - char *p; - int i; - - i = 0; - do { - if ((p = (*move)()) == NULL) - return ring_bell(); - } while (++i < Repeat); - return do_insert_hist(p); -} - -static STATUS -h_next() -{ - return do_hist(next_hist); -} - -static STATUS -h_prev() -{ - return do_hist(prev_hist); -} - -static STATUS -h_first() -{ - return do_insert_hist(H.Lines[H.Pos = 0]); -} - -static STATUS -h_last() -{ - return do_insert_hist(H.Lines[H.Pos = H.Size - 1]); -} - -/* -** Return zero if pat appears as a substring in text. -*/ -static int -substrcmp(char *text, char *pat,int len) -{ - char c; - - if ((c = *pat) == '\0') - return *text == '\0'; - for ( ; *text; text++) - if (*text == c && strncmp(text, pat, len) == 0) - return 0; - return 1; -} - -static char * -search_hist(char *search,char *(*move)()) -{ - static char *old_search; - int len; - int pos; - int (*match)(); - char *pat; - - /* Save or get remembered search pattern. */ - if (search && *search) { - if (old_search) - free(old_search); - old_search = strdup(search); - } - else { - if (old_search == NULL || *old_search == '\0') - return NULL; - search = old_search; - } - - /* Set up pattern-finder. */ - if (*search == '^') { - match = strncmp; - pat = (char *)(search + 1); - } - else { - match = substrcmp; - pat = (char *)search; - } - len = strlen(pat); - - for (pos = H.Pos; (*move)() != NULL; ) - if ((*match)((char *)H.Lines[H.Pos], pat, len) == 0) - return H.Lines[H.Pos]; - H.Pos = pos; - return NULL; -} - -static STATUS -h_search() -{ - static int Searching; - const char *old_prompt; - char *(*move)(); - char *p; - - if (Searching) - return ring_bell(); - Searching = 1; - - clear_line(); - old_prompt = Prompt; - Prompt = "Search: "; - TTYputs((const char *)Prompt); - move = Repeat == NO_ARG ? prev_hist : next_hist; - p = editinput(); - Searching = 0; - if (p == NULL && Signal > 0) { - Signal = 0; - clear_line(); - Prompt = old_prompt; - return redisplay_no_nl(); - } - p = search_hist(p, move); - clear_line(); - Prompt = old_prompt; - if (p == NULL) { - (void)ring_bell(); - return redisplay_no_nl(); - } - return do_insert_hist(p); -} - -static STATUS -fd_char() -{ - int i; - - i = 0; - do { - if (Point >= End) - break; - right(CSmove); - } while (++i < Repeat); - return CSstay; -} - -static void -save_yank(int begin, int i) -{ - if (Yanked) { - free(Yanked); - Yanked = NULL; - } - - if (i < 1) - return; - - if ((Yanked = malloc(sizeof(char) * (i + 1))) != NULL) { - memcpy(Yanked, &Line[begin], i); - Yanked[i] = '\0'; - } -} - -static STATUS -delete_string(int count) -{ - int i; - char *p; - - if (count <= 0 || End == Point) - return ring_bell(); - - if (count == 1 && Point == End - 1) { - /* Optimize common case of delete at end of line. */ - End--; - p = &Line[Point]; - i = 1; - TTYput(' '); - if (*p == TAB) { - /* XXX */ - } - else if (ISCTL(*p)) { - i = 2; - TTYput(' '); - } - else if (rl_meta_chars && ISMETA(*p)) { - i = 3; - TTYput(' '); - TTYput(' '); - } - TTYbackn(i); - *p = '\0'; - return CSmove; - } - if (Point + count > End && (count = End - Point) <= 0) - return CSstay; - - if (count > 1) - save_yank(Point, count); - - ceol(); - for (p = &Line[Point], i = End - (Point + count) + 1; --i >= 0; p++) - p[0] = p[count]; - End -= count; - TTYstring(&Line[Point]); - return CSmove; -} - -static STATUS -bk_char() -{ - int i; - - i = 0; - do { - if (Point == 0) - break; - left(CSmove); - } while (++i < Repeat); - - return CSstay; -} - -static STATUS -bk_del_char() -{ - int i; - - i = 0; - do { - if (Point == 0) - break; - left(CSmove); - } while (++i < Repeat); - - return delete_string(i); -} - -static STATUS -kill_line() -{ - int i; - - if (Repeat != NO_ARG) { - if (Repeat < Point) { - i = Point; - Point = Repeat; - reposition(); - (void)delete_string(i - Point); - } - else if (Repeat > Point) { - right(CSmove); - (void)delete_string(Repeat - Point - 1); - } - return CSmove; - } - - save_yank(Point, End - Point); - ceol(); - Line[Point] = '\0'; - End = Point; - return CSstay; -} - -static STATUS -insert_char(int c) -{ - STATUS s; - char buff[2]; - char *p; - char *q; - int i; - - if (Repeat == NO_ARG || Repeat < 2) { - buff[0] = c; - buff[1] = '\0'; - return insert_string(buff); - } - - if ((p = malloc(sizeof(char) * (Repeat + 1))) == NULL) - return CSstay; - for (i = Repeat, q = p; --i >= 0; ) - *q++ = c; - *q = '\0'; - Repeat = 0; - s = insert_string(p); - free(p); - return s; -} - -static STATUS -meta() -{ - int c; - KEYMAP *kp; - - if ((c = TTYget()) == EOF) - return CSeof; -#if defined(ANSI_ARROWS) - /* Also include VT-100 arrows. */ - if (c == '[' || c == 'O') - switch ((int)(c = TTYget())) { - default: return ring_bell(); - case EOF: return CSeof; - case 'A': return h_prev(); - case 'B': return h_next(); - case 'C': return fd_char(); - case 'D': return bk_char(); - } -#endif /* defined(ANSI_ARROWS) */ - - if (isdigit(c)) { - for (Repeat = c - '0'; (c = TTYget()) != EOF && isdigit(c); ) - Repeat = Repeat * 10 + c - '0'; - Pushed = 1; - PushBack = c; - return CSstay; - } - - if (isupper(c)) - return do_macro(c); - for (OldPoint = Point, kp = MetaMap; kp < &MetaMap[METAMAPSIZE]; kp++) - if (kp->Key == c && kp->Active) - return (*kp->Function)(); - - return ring_bell(); -} - -static STATUS -emacs(int c) -{ - STATUS s; - KEYMAP *kp; - -#if 0 - /* This test makes it impossible to enter eight-bit characters when - * meta-char mode is enabled. */ - if (rl_meta_chars && ISMETA(c)) { - Pushed = 1; - PushBack = UNMETA(c); - return meta(); - } -#endif /* 0 */ - for (kp = Map; kp < &Map[MAPSIZE]; kp++) - if (kp->Key == c && kp->Active) - break; - s = kp < &Map[MAPSIZE] ? (*kp->Function)() : insert_char((int)c); - if (!Pushed) - /* No pushback means no repeat count; hacky, but true. */ - Repeat = NO_ARG; - return s; -} - -static STATUS -TTYspecial(int c) -{ - if (rl_meta_chars && ISMETA(c)) - return CSdispatch; - - if (c == rl_erase || c == DEL) - return bk_del_char(); - if (c == rl_kill) { - if (Point != 0) { - Point = 0; - reposition(); - } - Repeat = NO_ARG; - return kill_line(); - } - if (c == rl_eof && Point == 0 && End == 0) - return CSeof; - if (c == rl_intr) { - Signal = SIGINT; - return CSsignal; - } - if (c == rl_quit) { - Signal = SIGQUIT; - return CSsignal; - } -#if defined(DO_SIGTSTP) - if (c == rl_susp) { - Signal = SIGTSTP; - return CSsignal; - } -#endif /* defined(DO_SIGTSTP) */ - - return CSdispatch; -} - -static char * -editinput() -{ - int c; - - Repeat = NO_ARG; - OldPoint = Point = Mark = End = 0; - Line[0] = '\0'; - - Signal = -1; - while ((c = TTYget()) != EOF) - switch (TTYspecial(c)) { - case CSdone: - return Line; - case CSeof: - return NULL; - case CSsignal: - return (char *)""; - case CSmove: - reposition(); - break; - case CSdispatch: - switch (emacs(c)) { - case CSdone: - return Line; - case CSeof: - return NULL; - case CSsignal: - return (char *)""; - case CSmove: - reposition(); - break; - case CSdispatch: - case CSstay: - break; - } - break; - case CSstay: - break; - } - return NULL; -} - -static void -hist_add(char *p) -{ - int i; - - if ((p = strdup(p)) == NULL) - return; - if (H.Size < HIST_SIZE) - H.Lines[H.Size++] = p; - else { - free(H.Lines[0]); - for (i = 0; i < HIST_SIZE - 1; i++) - H.Lines[i] = H.Lines[i + 1]; - H.Lines[i] = p; - } - H.Pos = H.Size - 1; -} - -static char * -read_redirected() -{ - int size; - char *p; - char *line; - char *end; - - for (size = MEM_INC, p = line = malloc(sizeof(char) * size), end = p + size; ; p++) { - if (p == end) { - size += MEM_INC; - p = line = realloc(line, size); - end = p + size; - } - if (read(0, p, 1) <= 0) { - /* Ignore "incomplete" lines at EOF, just like we do for a tty. */ - free(line); - return NULL; - } - if (*p == '\n') - break; - } - *p = '\0'; - return line; -} - -/* -** For compatibility with FSF readline. -*/ -/* ARGSUSED0 */ -void -rl_reset_terminal(char *p) -{ - (void)p; /* Suppress warning */ -} - -void -rl_initialize() -{ -} - -int -rl_insert(int count, int c) -{ - if (count > 0) { - Repeat = count; - (void)insert_char(c); - (void)redisplay_no_nl(); - } - return 0; -} - -int (*rl_event_hook)(); - -int -rl_key_action(int c, char flag) -{ - KEYMAP *kp; - int size; - - (void)flag; /* Suppress warning */ - - if (ISMETA(c)) { - kp = MetaMap; - size = METAMAPSIZE; - } - else { - kp = Map; - size = MAPSIZE; - } - for ( ; --size >= 0; kp++) - if (kp->Key == c) { - kp->Active = c ? 1 : 0; - return 1; - } - return -1; -} - -char * -readline(const char *prompt) -{ - char *line; - int s; - - if (!isatty(0)) { - TTYflush(); - return read_redirected(); - } - - if (Line == NULL) { - Length = MEM_INC; - if ((Line = malloc(sizeof(char) * Length)) == NULL) - return NULL; - } - - TTYinfo(); - rl_ttyset(0); - hist_add(NIL); - ScreenSize = SCREEN_INC; - Screen = malloc(sizeof(char) * ScreenSize); - Prompt = prompt ? prompt : (char *)NIL; - TTYputs((const char *)Prompt); - if ((line = editinput()) != NULL) { - line = strdup(line); - TTYputs((const char *)NEWLINE); - TTYflush(); - } - rl_ttyset(1); - free(Screen); - free(H.Lines[--H.Size]); - if (Signal > 0) { - s = Signal; - Signal = 0; - (void)kill(getpid(), s); - } - return (char *)line; -} - -void -add_history(char *p) -{ - if (p == NULL || *p == '\0') - return; - -#if defined(UNIQUE_HISTORY) - if (H.Size && strcmp(p, H.Lines[H.Size - 1]) == 0) - return; -#endif /* defined(UNIQUE_HISTORY) */ - hist_add((char *)p); -} - - -static STATUS -beg_line() -{ - if (Point) { - Point = 0; - return CSmove; - } - return CSstay; -} - -static STATUS -del_char() -{ - return delete_string(Repeat == NO_ARG ? 1 : Repeat); -} - -static STATUS -end_line() -{ - if (Point != End) { - Point = End; - return CSmove; - } - return CSstay; -} - -/* -** Return allocated copy of word under cursor, moving cursor after the -** word. -*/ -static char * -find_word() -{ - static char SEPS[] = "\"#;&|^$=`'{}()<>\n\t "; - char *p; - char *new; - size_t len; - - /* Move forward to end of word. */ - p = &Line[Point]; - for ( ; Point < End && strchr(SEPS, (char)*p) == NULL; Point++, p++) - right(CSstay); - - /* Back up to beginning of word. */ - for (p = &Line[Point]; p > Line && strchr(SEPS, (char)p[-1]) == NULL; p--) - continue; - len = Point - (p - Line) + 1; - if ((new = malloc(sizeof(char) * len)) == NULL) - return NULL; - memcpy(new, p, len); - new[len - 1] = '\0'; - return new; -} - -static STATUS -c_complete() -{ - char *p; - char *word; - int unique; - - word = find_word(); - p = (char *)rl_complete((char *)word, &unique); - if (word) - free(word); - if (p && *p) { - (void)insert_string(p); - if (!unique) - (void)ring_bell(); - free(p); - return redisplay_no_nl(); - } - return ring_bell(); -} - -static STATUS -c_possible() -{ - char **av; - char *word; - int ac; - - word = find_word(); - ac = rl_list_possib((char *)word, (char ***)&av); - if (word) - free(word); - if (ac) { - columns(ac, av); - while (--ac >= 0) - free(av[ac]); - free(av); - return redisplay_no_nl(); - } - return ring_bell(); -} - -static STATUS -accept_line() -{ - Line[End] = '\0'; - return CSdone; -} - -static STATUS -transpose() -{ - char c; - - if (Point) { - if (Point == End) - left(CSmove); - c = Line[Point - 1]; - left(CSstay); - Line[Point - 1] = Line[Point]; - TTYshow(Line[Point - 1]); - Line[Point++] = c; - TTYshow(c); - } - return CSstay; -} - -static STATUS -quote() -{ - int c; - - return (c = TTYget()) == EOF ? CSeof : insert_char((int)c); -} - -static STATUS -wipe() -{ - int i; - - if (Mark > End) - return ring_bell(); - - if (Point > Mark) { - i = Point; - Point = Mark; - Mark = i; - reposition(); - } - - return delete_string(Mark - Point); -} - -static STATUS -mk_set() -{ - Mark = Point; - return CSstay; -} - -static STATUS -exchange() -{ - int c; - - if ((c = TTYget()) != CTL('X')) - return c == EOF ? CSeof : ring_bell(); - - if ((c = Mark) <= End) { - Mark = Point; - Point = c; - return CSmove; - } - return CSstay; -} - -static STATUS -yank() -{ - if (Yanked && *Yanked) - return insert_string(Yanked); - return CSstay; -} - -static STATUS -copy_region() -{ - if (Mark > End) - return ring_bell(); - - if (Point > Mark) - save_yank(Mark, Point - Mark); - else - save_yank(Point, Mark - Point); - - return CSstay; -} - -static STATUS -move_to_char() -{ - int c; - int i; - char *p; - - if ((c = TTYget()) == EOF) - return CSeof; - for (i = Point + 1, p = &Line[i]; i < End; i++, p++) - if (*p == c) { - Point = i; - return CSmove; - } - return CSstay; -} - -static STATUS -fd_word() -{ - return do_forward(CSmove); -} - -static STATUS -fd_kill_word() -{ - int i; - - (void)do_forward(CSstay); - if (OldPoint != Point) { - i = Point - OldPoint; - Point = OldPoint; - return delete_string(i); - } - return CSstay; -} - -static STATUS -bk_word() -{ - int i; - char *p; - - i = 0; - do { - for (p = &Line[Point]; p > Line && !isalnum((int)p[-1]); p--) - left(CSmove); - - for (; p > Line && p[-1] != ' ' && isalnum((int)p[-1]); p--) - left(CSmove); - - if (Point == 0) - break; - } while (++i < Repeat); - - return CSstay; -} - -static STATUS -bk_kill_word() -{ - (void)bk_word(); - if (OldPoint != Point) - return delete_string(OldPoint - Point); - return CSstay; -} - -static int -argify(char *line, char ***avp) -{ - char *c; - char **p; - char **new; - int ac; - int i; - - i = MEM_INC; - if ((*avp = p = malloc(sizeof(char*) * i))== NULL) - return 0; - - for (c = line; isspace((int)*c); c++) - continue; - if (*c == '\n' || *c == '\0') - return 0; - - for (ac = 0, p[ac++] = c; *c && *c != '\n'; ) { - if (isspace((int)*c)) { - *c++ = '\0'; - if (*c && *c != '\n') { - if (ac + 1 == i) { - new = malloc(sizeof(char*) * (i + MEM_INC)); - if (new == NULL) { - p[ac] = NULL; - return ac; - } - memcpy(new, p, i * sizeof (char **)); - i += MEM_INC; - free(p); - *avp = p = new; - } - p[ac++] = c; - } - } - else - c++; - } - *c = '\0'; - p[ac] = NULL; - return ac; -} - -static STATUS -last_argument() -{ - char **av; - char *p; - STATUS s; - int ac; - - if (H.Size == 1 || (p = H.Lines[H.Size - 2]) == NULL) - return ring_bell(); - - if ((p = strdup(p)) == NULL) - return CSstay; - ac = argify(p, &av); - - if (Repeat != NO_ARG) - s = Repeat < ac ? insert_string(av[Repeat]) : ring_bell(); - else - s = ac ? insert_string(av[ac - 1]) : CSstay; - - if (ac) - free(av); - free(p); - return s; -} - -static KEYMAP Map[MAPSIZE] = { - { CTL('@'), 1, ring_bell }, - { CTL('A'), 1, beg_line }, - { CTL('B'), 1, bk_char }, - { CTL('D'), 1, del_char }, - { CTL('E'), 1, end_line }, - { CTL('F'), 1, fd_char }, - { CTL('G'), 1, ring_bell }, - { CTL('H'), 1, bk_del_char }, - { CTL('I'), 1, c_complete }, - { CTL('J'), 1, accept_line }, - { CTL('K'), 1, kill_line }, - { CTL('L'), 1, redisplay }, - { CTL('M'), 1, accept_line }, - { CTL('N'), 1, h_next }, - { CTL('O'), 1, ring_bell }, - { CTL('P'), 1, h_prev }, - { CTL('Q'), 1, ring_bell }, - { CTL('R'), 1, h_search }, - { CTL('S'), 1, ring_bell }, - { CTL('T'), 1, transpose }, - { CTL('U'), 1, ring_bell }, - { CTL('V'), 1, quote }, - { CTL('W'), 1, wipe }, - { CTL('X'), 1, exchange }, - { CTL('Y'), 1, yank }, - { CTL('Z'), 1, ring_bell }, - { CTL('['), 1, meta }, - { CTL(']'), 1, move_to_char }, - { CTL('^'), 1, ring_bell }, - { CTL('_'), 1, ring_bell }, -}; - -static KEYMAP MetaMap[16]= { - { CTL('H'), 1, bk_kill_word }, - { CTL('['), 1, c_possible }, - { DEL, 1, bk_kill_word }, - { ' ', 1, mk_set }, - { '.', 1, last_argument }, - { '<', 1, h_first }, - { '>', 1, h_last }, - { '?', 1, c_possible }, - { 'b', 1, bk_word }, - { 'd', 1, fd_kill_word }, - { 'f', 1, fd_word }, - { 'l', 1, case_down_word }, - { 'm', 1, toggle_meta_mode}, - { 'u', 1, case_up_word }, - { 'y', 1, yank }, - { 'w', 1, copy_region }, -}; diff --git a/ndb/src/common/editline/sysunix.c b/ndb/src/common/editline/sysunix.c deleted file mode 100644 index 000bca78dfc..00000000000 --- a/ndb/src/common/editline/sysunix.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; 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 */ - -/* $Revision: 1.4 $ -** -** Unix system-dependant routines for editline library. -*/ -#include "editline_internal.h" - -#if defined(HAVE_TCGETATTR) -#include <termios.h> - -void -rl_ttyset(int Reset) -{ - static struct termios old; - struct termios new; - - if (Reset == 0) { - if (tcgetattr(0, &old) < 0) perror("tcgetattr"); - rl_erase = old.c_cc[VERASE]; - rl_kill = old.c_cc[VKILL]; - rl_eof = old.c_cc[VEOF]; - rl_intr = old.c_cc[VINTR]; - rl_quit = old.c_cc[VQUIT]; -#if defined(DO_SIGTSTP) - rl_susp = old.c_cc[VSUSP]; -#endif /* defined(DO_SIGTSTP) */ - - new = old; - new.c_lflag &= ~(ECHO | ICANON | ISIG); - new.c_iflag &= ~(ISTRIP | INPCK); - new.c_cc[VMIN] = 1; - new.c_cc[VTIME] = 0; - if (tcsetattr(0, TCSADRAIN, &new) < 0) perror("tcsetattr"); - } - else - (void)tcsetattr(0, TCSADRAIN, &old); -} - -#else -#if defined(HAVE_TERMIO) -#include <termio.h> - -void -rl_ttyset(int Reset) -{ - static struct termio old; - struct termio new; - - if (Reset == 0) { - (void)ioctl(0, TCGETA, &old); - rl_erase = old.c_cc[VERASE]; - rl_kill = old.c_cc[VKILL]; - rl_eof = old.c_cc[VEOF]; - rl_intr = old.c_cc[VINTR]; - rl_quit = old.c_cc[VQUIT]; -#if defined(DO_SIGTSTP) - rl_susp = old.c_cc[VSUSP]; -#endif /* defined(DO_SIGTSTP) */ - - new = old; - new.c_lflag &= ~(ECHO | ICANON | ISIG); - new.c_iflag &= ~(ISTRIP | INPCK); - new.c_cc[VMIN] = 1; - new.c_cc[VTIME] = 0; - (void)ioctl(0, TCSETAW, &new); - } - else - (void)ioctl(0, TCSETAW, &old); -} - -#else -#include <sgtty.h> - -void -rl_ttyset(int Reset) -{ - static struct sgttyb old_sgttyb; - static struct tchars old_tchars; - struct sgttyb new_sgttyb; - struct tchars new_tchars; -#if defined(DO_SIGTSTP) - struct ltchars old_ltchars; -#endif /* defined(DO_SIGTSTP) */ - - if (Reset == 0) { - (void)ioctl(0, TIOCGETP, &old_sgttyb); - rl_erase = old_sgttyb.sg_erase; - rl_kill = old_sgttyb.sg_kill; - - (void)ioctl(0, TIOCGETC, &old_tchars); - rl_eof = old_tchars.t_eofc; - rl_intr = old_tchars.t_intrc; - rl_quit = old_tchars.t_quitc; - -#if defined(DO_SIGTSTP) - (void)ioctl(0, TIOCGLTC, &old_ltchars); - rl_susp = old_ltchars.t_suspc; -#endif /* defined(DO_SIGTSTP) */ - - new_sgttyb = old_sgttyb; - new_sgttyb.sg_flags &= ~ECHO; - new_sgttyb.sg_flags |= RAW; -#if defined(PASS8) - new_sgttyb.sg_flags |= PASS8; -#endif /* defined(PASS8) */ - (void)ioctl(0, TIOCSETP, &new_sgttyb); - - new_tchars = old_tchars; - new_tchars.t_intrc = -1; - new_tchars.t_quitc = -1; - (void)ioctl(0, TIOCSETC, &new_tchars); - } - else { - (void)ioctl(0, TIOCSETP, &old_sgttyb); - (void)ioctl(0, TIOCSETC, &old_tchars); - } -} -#endif /* defined(HAVE_TERMIO) */ -#endif /* defined(HAVE_TCGETATTR) */ - -void -rl_add_slash(char *path, char *p, size_t p_len) -{ - struct stat Sb; - - if (stat(path, &Sb) >= 0) - (void)strlcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ", p_len); -} diff --git a/ndb/src/common/editline/test/Makefile b/ndb/src/common/editline/test/Makefile deleted file mode 100644 index 20229d0aa62..00000000000 --- a/ndb/src/common/editline/test/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -include .defs.mk - -TYPE := util - -BIN_TARGET := editline_test -BIN_TARGET_ARCHIVES := editline - -SOURCES = testit.c - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/common/editline/test/testit.c b/ndb/src/common/editline/test/testit.c deleted file mode 100644 index 4058f8ae660..00000000000 --- a/ndb/src/common/editline/test/testit.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; 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 */ - -/* -*- c-basic-offset: 4; -*- -** $Revision: 1.5 $ -** -** A "micro-shell" to test editline library. -** If given any arguments, commands aren't executed. -*/ -#include <ndb_global.h> -#include <editline/editline.h> - -int -main(int argc, char **argv) -{ - char *prompt; - char *p; - int doit; - - (void)argv; /* Suppress warning */ - - doit = argc == 1; - if ((prompt = getenv("TESTPROMPT")) == NULL) - prompt = "testit> "; - - while ((p = readline(prompt)) != NULL) { - (void)printf("\t\t\t|%s|\n", p); - if (doit) { - if (strncmp(p, "cd ", 3) == 0) { - if (chdir(&p[3]) < 0) - perror(&p[3]); - } else { - if (system(p) != 0) - perror(p); - } - } - add_history(p); - free(p); - } - - return 0; -} diff --git a/ndb/src/common/logger/FileLogHandler.cpp b/ndb/src/common/logger/FileLogHandler.cpp index 29172ff93ad..8678b999b6f 100644 --- a/ndb/src/common/logger/FileLogHandler.cpp +++ b/ndb/src/common/logger/FileLogHandler.cpp @@ -198,7 +198,7 @@ FileLogHandler::setFilename(const BaseString &filename) { m_pLogFile = new File_class(filename.c_str(), "a+"); open(); return true; -}; +} bool FileLogHandler::setMaxSize(const BaseString &size) { @@ -206,15 +206,15 @@ FileLogHandler::setMaxSize(const BaseString &size) { long val = strtol(size.c_str(), &end, 0); /* XXX */ if(size.c_str() == end) return false; - if(strncasecmp("M", end, 1) == 0) + if(end[0] == 'M') val *= 1024*1024; - if(strncasecmp("k", end, 1) == 0) + if(end[0] == 'k') val *= 1024; m_maxFileSize = val; return true; -}; +} bool FileLogHandler::setMaxFiles(const BaseString &files) { @@ -225,7 +225,7 @@ FileLogHandler::setMaxFiles(const BaseString &files) { m_maxNoFiles = val; return true; -}; +} bool FileLogHandler::checkParams() { diff --git a/ndb/src/common/logger/LogHandler.cpp b/ndb/src/common/logger/LogHandler.cpp index 4fab957fc50..ec4137297f1 100644 --- a/ndb/src/common/logger/LogHandler.cpp +++ b/ndb/src/common/logger/LogHandler.cpp @@ -24,7 +24,13 @@ LogHandler::LogHandler() : m_pDateTimeFormat("%d-%.2d-%.2d %.2d:%.2d:%.2d"), m_errorCode(0) -{ +{ + m_max_repeat_frequency= 3; // repeat messages maximum every 3 seconds + m_count_repeated_messages= 0; + m_last_category[0]= 0; + m_last_message[0]= 0; + m_last_log_time= 0; + m_now= 0; } LogHandler::~LogHandler() @@ -34,11 +40,53 @@ LogHandler::~LogHandler() void LogHandler::append(const char* pCategory, Logger::LoggerLevel level, const char* pMsg) -{ +{ + time_t now; + now= ::time((time_t*)NULL); + + if (level != m_last_level || + strcmp(pCategory, m_last_category) || + strcmp(pMsg, m_last_message)) + { + if (m_count_repeated_messages > 0) // print that message + append_impl(m_last_category, m_last_level, m_last_message); + + m_last_level= level; + strncpy(m_last_category, pCategory, sizeof(m_last_category)); + strncpy(m_last_message, pMsg, sizeof(m_last_message)); + } + else // repeated message + { + if (now < m_last_log_time+m_max_repeat_frequency) + { + m_count_repeated_messages++; + m_now= now; + return; + } + } + + m_now= now; + + append_impl(pCategory, level, pMsg); + m_last_log_time= now; +} + +void +LogHandler::append_impl(const char* pCategory, Logger::LoggerLevel level, + const char* pMsg) +{ writeHeader(pCategory, level); - writeMessage(pMsg); + if (m_count_repeated_messages <= 1) + writeMessage(pMsg); + else + { + BaseString str(pMsg); + str.appfmt(" - Repeated %d times", m_count_repeated_messages); + writeMessage(str.c_str()); + } + m_count_repeated_messages= 0; writeFooter(); -} +} const char* LogHandler::getDefaultHeader(char* pStr, const char* pCategory, @@ -76,12 +124,10 @@ char* LogHandler::getTimeAsString(char* pStr) const { struct tm* tm_now; - time_t now; - now = ::time((time_t*)NULL); #ifdef NDB_WIN32 - tm_now = localtime(&now); + tm_now = localtime(&m_now); #else - tm_now = ::localtime(&now); //uses the "current" timezone + tm_now = ::localtime(&m_now); //uses the "current" timezone #endif BaseString::snprintf(pStr, MAX_DATE_TIME_HEADER_LENGTH, @@ -117,10 +163,9 @@ LogHandler::parseParams(const BaseString &_params) { _params.split(v_args, ","); for(size_t i=0; i < v_args.size(); i++) { Vector<BaseString> v_param_value; - - v_args[i].split(v_param_value, "=", 2); - if(v_param_value.size() == 2 && - !setParam(v_param_value[0], v_param_value[1])) + if(v_args[i].split(v_param_value, "=", 2) != 2) + ret = false; + else if (!setParam(v_param_value[0], v_param_value[1])) ret = false; } diff --git a/ndb/src/common/logger/LogHandlerList.hpp b/ndb/src/common/logger/LogHandlerList.hpp index 7c001a28a76..21344023560 100644 --- a/ndb/src/common/logger/LogHandlerList.hpp +++ b/ndb/src/common/logger/LogHandlerList.hpp @@ -18,6 +18,7 @@ #define LOGHANDLERLIST_H class LogHandler; +#include <ndb_global.h> /** * Provides a simple linked list of log handlers. diff --git a/ndb/src/common/logger/Logger.cpp b/ndb/src/common/logger/Logger.cpp index 00a2fae67bc..7f18f5bd3ec 100644 --- a/ndb/src/common/logger/Logger.cpp +++ b/ndb/src/common/logger/Logger.cpp @@ -30,7 +30,7 @@ // // PUBLIC // -const char* Logger::LoggerLevelNames[] = { "OFF ", +const char* Logger::LoggerLevelNames[] = { "ON ", "DEBUG ", "INFO ", "WARNING ", @@ -46,7 +46,9 @@ Logger::Logger() : m_pSyslogHandler(NULL) { m_pHandlerList = new LogHandlerList(); - m_logLevels[LL_INFO] = true; + disable(LL_ALL); + enable(LL_ON); + enable(LL_INFO); } Logger::~Logger() @@ -169,10 +171,13 @@ Logger::addHandler(const BaseString &logstring) { size_t i; Vector<BaseString> logdest; Vector<LogHandler *>loghandlers; + DBUG_ENTER("Logger::addHandler"); logstring.split(logdest, ";"); for(i = 0; i < logdest.size(); i++) { + DBUG_PRINT("info",("adding: %s",logdest[i].c_str())); + Vector<BaseString> v_type_args; logdest[i].split(v_type_args, ":", 2); @@ -183,24 +188,28 @@ Logger::addHandler(const BaseString &logstring) { LogHandler *handler = NULL; - if(type == "SYSLOG") { +#ifndef NDB_WIN32 + if(type == "SYSLOG") + { handler = new SysLogHandler(); - } else if(type == "FILE") + } else +#endif + if(type == "FILE") handler = new FileLogHandler(); else if(type == "CONSOLE") handler = new ConsoleLogHandler(); - + if(handler == NULL) - return false; + DBUG_RETURN(false); if(!handler->parseParams(params)) - return false; + DBUG_RETURN(false); loghandlers.push_back(handler); } for(i = 0; i < loghandlers.size(); i++) addHandler(loghandlers[i]); - return true; /* @todo handle errors */ + DBUG_RETURN(true); /* @todo handle errors */ } bool @@ -224,6 +233,13 @@ Logger::removeAllHandlers() bool Logger::isEnable(LoggerLevel logLevel) const { + if (logLevel == LL_ALL) + { + for (unsigned i = 1; i < MAX_LOG_LEVELS; i++) + if (!m_logLevels[i]) + return false; + return true; + } return m_logLevels[logLevel]; } @@ -232,7 +248,7 @@ Logger::enable(LoggerLevel logLevel) { if (logLevel == LL_ALL) { - for (unsigned i = 1; i < MAX_LOG_LEVELS; i++) + for (unsigned i = 0; i < MAX_LOG_LEVELS; i++) { m_logLevels[i] = true; } @@ -334,16 +350,16 @@ Logger::debug(const char* pMsg, ...) const void Logger::log(LoggerLevel logLevel, const char* pMsg, va_list ap) const { - if (m_logLevels[LL_OFF] == false && m_logLevels[logLevel]) + if (m_logLevels[LL_ON] && m_logLevels[logLevel]) { LogHandler* pHandler = NULL; while ( (pHandler = m_pHandlerList->next()) != NULL) { - char buf[1024]; + char buf[MAX_LOG_MESSAGE_SIZE]; BaseString::vsnprintf(buf, sizeof(buf), pMsg, ap); pHandler->append(m_pCategory, logLevel, buf); } - } + } } // diff --git a/ndb/src/common/logger/Makefile.am b/ndb/src/common/logger/Makefile.am index 0a48214c37c..0af21f9fbde 100644 --- a/ndb/src/common/logger/Makefile.am +++ b/ndb/src/common/logger/Makefile.am @@ -1,11 +1,25 @@ noinst_LTLIBRARIES = liblogger.la -liblogger_la_SOURCES = Logger.cpp LogHandlerList.cpp LogHandler.cpp \ - ConsoleLogHandler.cpp FileLogHandler.cpp SysLogHandler.cpp +SOURCE_WIN = Logger.cpp LogHandlerList.cpp LogHandler.cpp \ + ConsoleLogHandler.cpp FileLogHandler.cpp +liblogger_la_SOURCES = $(SOURCE_WIN) SysLogHandler.cpp include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am # Don't update the files from bitkeeper %::SCCS/s.% +windoze-dsp: liblogger.dsp + +liblogger.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(SOURCE_WIN) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/common/logger/Makefile_old b/ndb/src/common/logger/Makefile_old deleted file mode 100644 index 994eb86ba35..00000000000 --- a/ndb/src/common/logger/Makefile_old +++ /dev/null @@ -1,27 +0,0 @@ -include .defs.mk - -TYPE := ndbapi - -PIC_ARCHIVE := Y -ARCHIVE_TARGET := logger - -DIRS := loggertest - -SOURCES := Logger.cpp LogHandlerList.cpp LogHandler.cpp \ - ConsoleLogHandler.cpp FileLogHandler.cpp - -ifeq ($(NDB_OS), OSE) -NO_SYSLOG := Y -endif - -ifeq ($(NDB_OS), WIN32) -NO_SYSLOG := Y -endif - -ifneq ($(NO_SYSLOG), Y) -SOURCES += SysLogHandler.cpp -endif - -include $(NDB_TOP)/Epilogue.mk - - diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index d8417ac146a..fd04ad393eb 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -20,7 +20,6 @@ #include <ConfigRetriever.hpp> #include <SocketServer.hpp> -#include "LocalConfig.hpp" #include <NdbSleep.h> #include <NdbOut.hpp> @@ -45,90 +44,67 @@ //**************************************************************************** //**************************************************************************** -ConfigRetriever::ConfigRetriever(LocalConfig &local_config, +ConfigRetriever::ConfigRetriever(const char * _connect_string, Uint32 version, Uint32 node_type) - : _localConfig(local_config) { - m_handle= 0; m_version = version; m_node_type = node_type; - _ownNodeId = _localConfig._ownNodeId; -} + _ownNodeId= 0; + + m_handle= ndb_mgm_create_handle(); + + if (m_handle == 0) { + setError(CR_ERROR, "Unable to allocate mgm handle"); + return; + } -ConfigRetriever::~ConfigRetriever(){ + if (ndb_mgm_set_connectstring(m_handle, _connect_string)) + { + setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); + return; + } + resetError(); +} +ConfigRetriever::~ConfigRetriever() +{ if (m_handle) { ndb_mgm_disconnect(m_handle); ndb_mgm_destroy_handle(&m_handle); } } +Uint32 +ConfigRetriever::get_configuration_nodeid() const +{ + return ndb_mgm_get_configuration_nodeid(m_handle); +} + +Uint32 ConfigRetriever::get_mgmd_port() const +{ + return ndb_mgm_get_connected_port(m_handle); +} + +const char *ConfigRetriever::get_mgmd_host() const +{ + return ndb_mgm_get_connected_host(m_handle); +} + +const char *ConfigRetriever::get_connectstring(char *buf, int buf_sz) const +{ + return ndb_mgm_get_connectstring(m_handle, buf, buf_sz); +} //**************************************************************************** //**************************************************************************** int -ConfigRetriever::do_connect(int exit_on_connect_failure){ - - m_mgmd_port= 0; - m_mgmd_host= 0; - - if(!m_handle) - m_handle= ndb_mgm_create_handle(); - - if (m_handle == 0) { - setError(CR_ERROR, "Unable to allocate mgm handle"); - return -1; - } - - int retry = 1; - int retry_max = 12; // Max number of retry attempts - int retry_interval= 5; // Seconds between each retry - while(retry < retry_max){ - Uint32 type = CR_ERROR; - BaseString tmp; - for (unsigned int i = 0; i<_localConfig.ids.size(); i++){ - MgmtSrvrId * m = &_localConfig.ids[i]; - DBUG_PRINT("info",("trying %s:%d", - m->name.c_str(), - m->port)); - switch(m->type){ - case MgmId_TCP: - tmp.assfmt("%s:%d", m->name.c_str(), m->port); - if (ndb_mgm_connect(m_handle, tmp.c_str()) == 0) { - m_mgmd_port= m->port; - m_mgmd_host= m->name.c_str(); - DBUG_PRINT("info",("connected to ndb_mgmd at %s:%d", - m_mgmd_host, - m_mgmd_port)); - return 0; - } - setError(CR_RETRY, ndb_mgm_get_latest_error_desc(m_handle)); - case MgmId_File: - break; - } - } - if(latestErrorType == CR_RETRY){ - DBUG_PRINT("info",("CR_RETRY")); - if (exit_on_connect_failure) - return 1; - REPORT_WARNING("Failed to retrieve cluster configuration"); - ndbout << "(Cause of failure: " << getErrorString() << ")" << endl; - ndbout << "Attempt " << retry << " of " << retry_max << ". " - << "Trying again in "<< retry_interval <<" seconds..." - << endl << endl; - NdbSleep_SecSleep(retry_interval); - } else { - break; - } - retry++; - } - - ndb_mgm_destroy_handle(&m_handle); - m_handle= 0; - m_mgmd_port= 0; - m_mgmd_host= 0; - return -1; +ConfigRetriever::do_connect(int no_retries, + int retry_delay_in_seconds, int verbose) +{ + return + (ndb_mgm_connect(m_handle,no_retries,retry_delay_in_seconds,verbose)==0) ? + 0 : -1; } //**************************************************************************** @@ -140,22 +116,9 @@ ConfigRetriever::getConfig() { struct ndb_mgm_configuration * p = 0; - if(m_handle != 0){ + if(m_handle != 0) p = getConfig(m_handle); - } else { - for (unsigned int i = 0; i<_localConfig.ids.size(); i++){ - MgmtSrvrId * m = &_localConfig.ids[i]; - switch(m->type){ - case MgmId_File: - p = getConfig(m->name.c_str()); - break; - case MgmId_TCP: - break; - } - if(p) - break; - } - } + if(p == 0) return 0; @@ -178,9 +141,10 @@ ConfigRetriever::getConfig(NdbMgmHandle m_handle){ return conf; } - + ndb_mgm_configuration * ConfigRetriever::getConfig(const char * filename){ +#ifndef NDB_WIN32 struct stat sbuf; const int res = stat(filename, &sbuf); @@ -217,8 +181,10 @@ ConfigRetriever::getConfig(const char * filename){ return 0; } delete [] buf2; - return (ndb_mgm_configuration*)cvf.m_cfg; +#else + return 0; +#endif } void @@ -227,6 +193,16 @@ ConfigRetriever::setError(ErrorType et, const char * s){ latestErrorType = et; } +void +ConfigRetriever::resetError(){ + setError(CR_NO_ERROR,0); +} + +int +ConfigRetriever::hasError() +{ + return latestErrorType != CR_NO_ERROR; +} const char * ConfigRetriever::getErrorString(){ @@ -238,7 +214,8 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32 char buf[255]; ndb_mgm_configuration_iterator * it; - it = ndb_mgm_create_configuration_iterator((struct ndb_mgm_configuration *)conf, CFG_SECTION_NODE); + it = ndb_mgm_create_configuration_iterator((struct ndb_mgm_configuration *)conf, + CFG_SECTION_NODE); if(it == 0){ BaseString::snprintf(buf, 255, "Unable to create config iterator"); @@ -284,8 +261,14 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32 } if(_type != m_node_type){ - BaseString::snprintf(buf, 255, "Supplied node type(%d) and config node type(%d) " - " don't match", m_node_type, _type); + const char *type_s, *alias_s, *type_s2, *alias_s2; + alias_s= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)m_node_type, + &type_s); + alias_s2= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)_type, + &type_s2); + BaseString::snprintf(buf, 255, "This node type %s(%s) and config " + "node type %s(%s) don't match for nodeid %d", + alias_s, type_s, alias_s2, type_s2, nodeid); setError(CR_ERROR, buf); return false; } @@ -333,17 +316,30 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32 return true; } +int +ConfigRetriever::setNodeId(Uint32 nodeid) +{ + return ndb_mgm_set_configuration_nodeid(m_handle, nodeid); +} + Uint32 -ConfigRetriever::allocNodeId(){ - unsigned nodeid= _ownNodeId; - - if(m_handle != 0){ - int res= ndb_mgm_alloc_nodeid(m_handle, m_version, &nodeid, m_node_type); - if(res != 0) { - setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); - return 0; +ConfigRetriever::allocNodeId(int no_retries, int retry_delay_in_seconds) +{ + _ownNodeId= 0; + if(m_handle != 0) + { + while (1) + { + int res= ndb_mgm_alloc_nodeid(m_handle, m_version, m_node_type); + if(res >= 0) + return _ownNodeId= (Uint32)res; + if (no_retries == 0) + break; + no_retries--; + NdbSleep_SecSleep(retry_delay_in_seconds); } - } - - return _ownNodeId= nodeid; + setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); + } else + setError(CR_ERROR, "management server handle not initialized"); + return 0; } diff --git a/ndb/src/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp index 780504d2c62..86791490863 100644 --- a/ndb/src/common/mgmcommon/IPCConfig.cpp +++ b/ndb/src/common/mgmcommon/IPCConfig.cpp @@ -14,7 +14,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "IPCConfig.hpp" +#include <ndb_global.h> +#include <ndb_opt_defaults.h> +#include <IPCConfig.hpp> #include <NdbOut.hpp> #include <NdbHost.h> @@ -381,8 +383,15 @@ IPCConfig::configureTransporters(Uint32 nodeId, if(iter.get(CFG_SHM_KEY, &conf.shmKey)) break; if(iter.get(CFG_SHM_BUFFER_MEM, &conf.shmSize)) break; - + { + Uint32 tmp; + if(iter.get(CFG_SHM_SIGNUM, &tmp)) break; + conf.signum= tmp; + } + conf.port= server_port; + conf.localHostName = localHostName; + conf.remoteHostName = remoteHostName; if(!tr.createTransporter(&conf)){ DBUG_PRINT("error", ("Failed to create SHM Transporter from %d to %d", diff --git a/ndb/src/common/mgmcommon/Makefile.am b/ndb/src/common/mgmcommon/Makefile.am index ed6a526eb47..104bf0b29f2 100644 --- a/ndb/src/common/mgmcommon/Makefile.am +++ b/ndb/src/common/mgmcommon/Makefile.am @@ -1,17 +1,28 @@ noinst_LTLIBRARIES = libmgmsrvcommon.la libmgmsrvcommon_la_SOURCES = \ - LocalConfig.cpp \ ConfigRetriever.cpp \ - IPCConfig.cpp NdbConfig.c + IPCConfig.cpp INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmapi -I$(top_srcdir)/ndb/src/mgmsrv -DEFS_LOC = -DNDB_BASE_PORT="\"@ndb_port_base@\"" - include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am include $(top_srcdir)/ndb/config/type_mgmapiclient.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libmgmsrvcommon.dsp + +libmgmsrvcommon.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libmgmsrvcommon_la_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/common/mgmcommon/Makefile_old b/ndb/src/common/mgmcommon/Makefile_old deleted file mode 100644 index c7bfda7e3bf..00000000000 --- a/ndb/src/common/mgmcommon/Makefile_old +++ /dev/null @@ -1,29 +0,0 @@ -include .defs.mk - -TYPE := ndbapi mgmapiclient - -PIC_ARCHIVE := Y -ARCHIVE_TARGET := mgmsrvcommon - -# Removed temporary -DIRS := printConfig - -SOURCES = \ - LocalConfig.cpp \ - Config.cpp \ - ConfigInfo.cpp \ - ConfigRetriever.cpp \ - InitConfigFileParser.cpp \ - IPCConfig.cpp - -SOURCES.c = NdbConfig.c - -CFLAGS_IPCConfig.cpp := -I$(call fixpath,$(NDB_TOP)/src/mgmapi) - -include $(NDB_TOP)/Epilogue.mk - - - - - - diff --git a/ndb/src/common/portlib/Makefile.am b/ndb/src/common/portlib/Makefile.am index 6f3a3fe01a9..99138a7414e 100644 --- a/ndb/src/common/portlib/Makefile.am +++ b/ndb/src/common/portlib/Makefile.am @@ -5,7 +5,8 @@ noinst_LTLIBRARIES = libportlib.la libportlib_la_SOURCES = \ NdbCondition.c NdbMutex.c NdbSleep.c NdbTick.c \ NdbEnv.c NdbThread.c NdbHost.c NdbTCP.cpp \ - NdbDaemon.c NdbMem.c + NdbDaemon.c NdbMem.c \ + NdbConfig.c include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_util.mk.am @@ -16,3 +17,27 @@ PortLibTest_SOURCES = NdbPortLibTest.cpp munmaptest_SOURCES = munmaptest.cpp # Don't update the files from bitkeeper +WIN_src = win32/NdbCondition.c \ + win32/NdbDaemon.c \ + win32/NdbEnv.c \ + win32/NdbHost.c \ + win32/NdbMem.c \ + win32/NdbMutex.c \ + win32/NdbSleep.c \ + win32/NdbTCP.c \ + win32/NdbThread.c \ + win32/NdbTick.c + +windoze-dsp: libportlib.dsp + +libportlib.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(WIN_src) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/common/portlib/Makefile_old b/ndb/src/common/portlib/Makefile_old deleted file mode 100644 index 48f4929a839..00000000000 --- a/ndb/src/common/portlib/Makefile_old +++ /dev/null @@ -1,21 +0,0 @@ -include .defs.mk - -DIRS := - -ifeq ($(NDB_OS), SOFTOSE) -DIRS += ose -else -ifeq ($(NDB_OS), OSE) -DIRS += ose -else -ifeq ($(NDB_OS), WIN32) -DIRS += win32 -else -DIRS += unix -endif -endif -endif - - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/src/common/mgmcommon/NdbConfig.c b/ndb/src/common/portlib/NdbConfig.c index e92f8fa8392..b275143646f 100644 --- a/ndb/src/common/mgmcommon/NdbConfig.c +++ b/ndb/src/common/portlib/NdbConfig.c @@ -18,6 +18,7 @@ #include <NdbConfig.h> #include <NdbEnv.h> #include <NdbMem.h> +#include <basestring_vsnprintf.h> static const char *datadir_path= 0; @@ -48,7 +49,7 @@ NdbConfig_AllocHomePath(int _len) const char *path= NdbConfig_get_path(&path_len); int len= _len+path_len; char *buf= NdbMem_Allocate(len); - snprintf(buf, len, "%s%s", path, DIR_SEPARATOR); + basestring_snprintf(buf, len, "%s%s", path, DIR_SEPARATOR); return buf; } @@ -67,19 +68,19 @@ NdbConfig_NdbCfgName(int with_ndb_home){ len= strlen(buf); } else buf= NdbMem_Allocate(128); - snprintf(buf+len, 128, "Ndb.cfg"); + basestring_snprintf(buf+len, 128, "Ndb.cfg"); return buf; } static char *get_prefix_buf(int len, int node_id) { - char tmp_buf[sizeof("ndb_pid#########")+1]; + char tmp_buf[sizeof("ndb_pid#############")+1]; char *buf; if (node_id > 0) - snprintf(tmp_buf, sizeof(tmp_buf), "ndb_%u", node_id); + basestring_snprintf(tmp_buf, sizeof(tmp_buf), "ndb_%u", node_id); else - snprintf(tmp_buf, sizeof(tmp_buf), "ndb_pid%u", getpid()); + basestring_snprintf(tmp_buf, sizeof(tmp_buf), "ndb_pid%u", getpid()); tmp_buf[sizeof(tmp_buf)-1]= 0; buf= NdbConfig_AllocHomePath(len+strlen(tmp_buf)); @@ -91,7 +92,7 @@ char* NdbConfig_ErrorFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_error.log"); + basestring_snprintf(buf+len, 128, "_error.log"); return buf; } @@ -99,7 +100,7 @@ char* NdbConfig_ClusterLogFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_cluster.log"); + basestring_snprintf(buf+len, 128, "_cluster.log"); return buf; } @@ -107,7 +108,7 @@ char* NdbConfig_SignalLogFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_signal.log"); + basestring_snprintf(buf+len, 128, "_signal.log"); return buf; } @@ -115,7 +116,7 @@ char* NdbConfig_TraceFileName(int node_id, int file_no){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_trace.log.%u", file_no); + basestring_snprintf(buf+len, 128, "_trace.log.%u", file_no); return buf; } @@ -123,7 +124,7 @@ char* NdbConfig_NextTraceFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_trace.log.next"); + basestring_snprintf(buf+len, 128, "_trace.log.next"); return buf; } @@ -131,7 +132,7 @@ char* NdbConfig_PidFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, ".pid"); + basestring_snprintf(buf+len, 128, ".pid"); return buf; } @@ -139,6 +140,6 @@ char* NdbConfig_StdoutFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_out.log"); + basestring_snprintf(buf+len, 128, "_out.log"); return buf; } diff --git a/ndb/src/common/portlib/NdbDaemon.c b/ndb/src/common/portlib/NdbDaemon.c index c73b5927ff4..3f1c1998501 100644 --- a/ndb/src/common/portlib/NdbDaemon.c +++ b/ndb/src/common/portlib/NdbDaemon.c @@ -55,18 +55,21 @@ NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags) "%s: lseek failed: %s", lockfile, strerror(errno)); return -1; } +#ifdef F_TLOCK /* Test for lock before becoming daemon */ - if (lockf(lockfd, F_TEST, 0) == -1) { - if (errno == EACCES || errno == EAGAIN) { /* results may vary */ + if (lockf(lockfd, F_TLOCK, 0) == -1) + { + if (errno == EACCES || errno == EAGAIN) { /* results may vary */ snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize, - "%s: already locked by pid=%ld", lockfile, NdbDaemon_DaemonPid); + "%s: already locked by pid=%ld", lockfile, NdbDaemon_DaemonPid); return -1; } NdbDaemon_ErrorCode = errno; snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize, - "%s: lock test failed: %s", lockfile, strerror(errno)); + "%s: lock test failed: %s", lockfile, strerror(errno)); return -1; } +#endif /* Test open log file before becoming daemon */ if (logfile != NULL) { logfd = open(logfile, O_CREAT|O_WRONLY|O_APPEND, 0644); @@ -77,6 +80,15 @@ NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags) return -1; } } +#ifdef F_TLOCK + if (lockf(lockfd, F_ULOCK, 0) == -1) + { + snprintf(NdbDaemon_ErrorText, NdbDaemon_ErrorSize, + "%s: fail to unlock", lockfile); + return -1; + } +#endif + /* Fork */ n = fork(); if (n == -1) { diff --git a/ndb/src/common/portlib/NdbPortLibTest.cpp b/ndb/src/common/portlib/NdbPortLibTest.cpp index 55b9ccec5f2..d7892411851 100644 --- a/ndb/src/common/portlib/NdbPortLibTest.cpp +++ b/ndb/src/common/portlib/NdbPortLibTest.cpp @@ -54,10 +54,7 @@ extern "C" void* thread1func(void* arg) if (arg1 != 7) fail("TEST1", "Wrong arg"); - NdbThread_Exit(returnvalue); - - return NULL; - + return returnvalue; } // test 2 variables and funcs @@ -80,10 +77,7 @@ extern "C" void* test2func(void* arg) fail("TEST2", "Failed to unlock mutex"); int returnvalue = arg1; - NdbThread_Exit(returnvalue); - - return NULL; - + return returnvalue; } @@ -129,8 +123,7 @@ extern "C" void* testfunc(void* arg) } while(tmpVar<100); - NdbThread_Exit(0); - return NULL; + return 0; } extern "C" void* testTryLockfunc(void* arg) @@ -169,8 +162,7 @@ extern "C" void* testTryLockfunc(void* arg) } while(tmpVar<100); - NdbThread_Exit(0); - return NULL; + return 0; } diff --git a/ndb/src/common/portlib/NdbTCP.cpp b/ndb/src/common/portlib/NdbTCP.cpp index 35b0c8c21e4..a63f5a7ba27 100644 --- a/ndb/src/common/portlib/NdbTCP.cpp +++ b/ndb/src/common/portlib/NdbTCP.cpp @@ -22,7 +22,7 @@ extern "C" int Ndb_getInAddr(struct in_addr * dst, const char *address) { - DBUG_ENTER("Ndb_getInAddr"); + // DBUG_ENTER("Ndb_getInAddr"); { int tmp_errno; struct hostent tmp_hostent, *hp; @@ -33,7 +33,7 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) { { memcpy(dst, hp->h_addr, min(sizeof(*dst), (size_t) hp->h_length)); my_gethostbyname_r_free(); - DBUG_RETURN(0); + return 0; //DBUG_RETURN(0); } my_gethostbyname_r_free(); } @@ -47,11 +47,11 @@ Ndb_getInAddr(struct in_addr * dst, const char *address) { #endif ) { - DBUG_RETURN(0); + return 0; //DBUG_RETURN(0); } - DBUG_PRINT("error",("inet_addr(%s) - %d - %s", - address, errno, strerror(errno))); - DBUG_RETURN(-1); + // DBUG_PRINT("error",("inet_addr(%s) - %d - %s", + // address, errno, strerror(errno))); + return -1; //DBUG_RETURN(-1); } #if 0 diff --git a/ndb/src/common/portlib/NdbThread.c b/ndb/src/common/portlib/NdbThread.c index 69e39994a9c..aaee9b45069 100644 --- a/ndb/src/common/portlib/NdbThread.c +++ b/ndb/src/common/portlib/NdbThread.c @@ -17,19 +17,51 @@ #include <ndb_global.h> #include <NdbThread.h> -#include <pthread.h> +#include <my_pthread.h> #include <NdbMem.h> #define MAX_THREAD_NAME 16 /*#define USE_PTHREAD_EXTRAS*/ +#ifdef NDB_SHM_TRANSPORTER +int g_ndb_shm_signum= 0; +#endif + struct NdbThread { pthread_t thread; char thread_name[MAX_THREAD_NAME]; + NDB_THREAD_FUNC * func; + void * object; }; +static +void* +ndb_thread_wrapper(void* _ss){ + my_thread_init(); + { + DBUG_ENTER("ndb_thread_wrapper"); +#ifdef NDB_SHM_TRANSPORTER + if (g_ndb_shm_signum) + { + sigset_t mask; + DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum)); + sigemptyset(&mask); + sigaddset(&mask, g_ndb_shm_signum); + pthread_sigmask(SIG_BLOCK, &mask, 0); + } +#endif + { + void *ret; + struct NdbThread * ss = (struct NdbThread *)_ss; + ret= (* ss->func)(ss->object); + NdbThread_Exit(ret); + } + /* will never be reached */ + DBUG_RETURN(0); + } +} struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func, @@ -54,7 +86,11 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func, strnmov(tmpThread->thread_name,p_thread_name,sizeof(tmpThread->thread_name)); pthread_attr_init(&thread_attr); +#if (SIZEOF_CHARP == 8) + pthread_attr_setstacksize(&thread_attr, 2*thread_stack_size); +#else pthread_attr_setstacksize(&thread_attr, thread_stack_size); +#endif #ifdef USE_PTHREAD_EXTRAS /* Guard stack overflow with a 2k databuffer */ pthread_attr_setguardsize(&thread_attr, 2048); @@ -63,10 +99,12 @@ struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func, #ifdef PTHREAD_CREATE_JOINABLE /* needed on SCO */ pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE); #endif + tmpThread->func= p_thread_func; + tmpThread->object= p_thread_arg; result = pthread_create(&tmpThread->thread, &thread_attr, - p_thread_func, - p_thread_arg); + ndb_thread_wrapper, + tmpThread); assert(result==0); pthread_attr_destroy(&thread_attr); @@ -99,9 +137,10 @@ int NdbThread_WaitFor(struct NdbThread* p_wait_thread, void** status) } -void NdbThread_Exit(int status) +void NdbThread_Exit(void *status) { - pthread_exit(&status); + my_thread_end(); + pthread_exit(status); } diff --git a/ndb/src/common/portlib/old_dirs/unix/Makefile_old b/ndb/src/common/portlib/old_dirs/unix/Makefile_old deleted file mode 100644 index 452196d9f08..00000000000 --- a/ndb/src/common/portlib/old_dirs/unix/Makefile_old +++ /dev/null @@ -1,27 +0,0 @@ -include .defs.mk - -TYPE := util - -PIC_ARCHIVE := Y -ARCHIVE_TARGET := portlib - -SOURCES.c = NdbCondition.c \ - NdbMutex.c \ - NdbSleep.c \ - NdbTick.c \ - NdbEnv.c \ - NdbThread.c \ - NdbHost.c \ - NdbTCP.c \ - NdbDaemon.c - -ifeq ($(NDB_OS), SOFTOSE) - SOURCES += NdbMem_SoftOse.cpp -else - SOURCES.c += NdbMem.c -endif - -include $(NDB_TOP)/Epilogue.mk - -testNdbDaemon: NdbDaemon.c - $(CC) -o $@ NdbDaemon.c $(CCFLAGS) -DNDB_DAEMON_TEST -L$(NDB_TOP)/lib diff --git a/ndb/src/common/portlib/win32/NdbCondition.c b/ndb/src/common/portlib/win32/NdbCondition.c new file mode 100644 index 00000000000..4046db1d60a --- /dev/null +++ b/ndb/src/common/portlib/win32/NdbCondition.c @@ -0,0 +1,178 @@ +/* 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 "NdbCondition.h" +#include <NdbMutex.h> + +struct NdbCondition +{ + long nWaiters; + NdbMutex* pNdbMutexWaitersLock; + HANDLE hSemaphore; + HANDLE hEventWaitersDone; + int bWasBroadcast; +}; + + +struct NdbCondition* +NdbCondition_Create(void) +{ + int result = 0; + struct NdbCondition* pNdbCondition = (struct NdbCondition*)malloc(sizeof(struct NdbCondition)); + if(!pNdbCondition) + return 0; + + pNdbCondition->nWaiters = 0; + pNdbCondition->bWasBroadcast = 0; + if(!(pNdbCondition->hSemaphore = CreateSemaphore(0, 0, MAXLONG, 0))) + result = -1; + else if(!(pNdbCondition->pNdbMutexWaitersLock = NdbMutex_Create())) + result = -1; + else if(!(pNdbCondition->hEventWaitersDone = CreateEvent(0, 0, 0, 0))) + result = -1; + + assert(!result); + return pNdbCondition; +} + + +int +NdbCondition_Wait(struct NdbCondition* p_cond, + NdbMutex* p_mutex) +{ + int result; + int bLastWaiter; + if(!p_cond || !p_mutex) + return 1; + + NdbMutex_Lock(p_cond->pNdbMutexWaitersLock); + p_cond->nWaiters++; + NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock); + + if(NdbMutex_Unlock(p_mutex)) + return -1; + result = WaitForSingleObject (p_cond->hSemaphore, INFINITE); + + NdbMutex_Lock(p_cond->pNdbMutexWaitersLock); + p_cond->nWaiters--; + bLastWaiter = (p_cond->bWasBroadcast && p_cond->nWaiters==0); + NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock); + + if(result==WAIT_OBJECT_0 && bLastWaiter) + SetEvent(p_cond->hEventWaitersDone); + + NdbMutex_Lock(p_mutex); + return result; +} + + +int +NdbCondition_WaitTimeout(struct NdbCondition* p_cond, + NdbMutex* p_mutex, + int msecs) +{ + int result; + int bLastWaiter; + if (!p_cond || !p_mutex) + return 1; + + NdbMutex_Lock(p_cond->pNdbMutexWaitersLock); + p_cond->nWaiters++; + NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock); + if(msecs<0) + msecs = 0; + + if(NdbMutex_Unlock(p_mutex)) + return -1; + result = WaitForSingleObject(p_cond->hSemaphore, msecs); + + NdbMutex_Lock(p_cond->pNdbMutexWaitersLock); + p_cond->nWaiters--; + bLastWaiter = (p_cond->bWasBroadcast && p_cond->nWaiters==0); + NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock); + + if(result!=WAIT_OBJECT_0) + result = -1; + + if(bLastWaiter) + SetEvent(p_cond->hEventWaitersDone); + + NdbMutex_Lock(p_mutex); + return result; +} + + +int +NdbCondition_Signal(struct NdbCondition* p_cond) +{ + int bHaveWaiters; + if(!p_cond) + return 1; + + NdbMutex_Lock(p_cond->pNdbMutexWaitersLock); + bHaveWaiters = (p_cond->nWaiters > 0); + NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock); + + if(bHaveWaiters) + return (ReleaseSemaphore(p_cond->hSemaphore, 1, 0) ? 0 : -1); + else + return 0; +} + + +int NdbCondition_Broadcast(struct NdbCondition* p_cond) +{ + int bHaveWaiters; + int result = 0; + if(!p_cond) + return 1; + + NdbMutex_Lock(p_cond->pNdbMutexWaitersLock); + bHaveWaiters = 0; + if(p_cond->nWaiters > 0) + { + p_cond->bWasBroadcast = !0; + bHaveWaiters = 1; + } + NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock); + if(bHaveWaiters) + { + if(!ReleaseSemaphore(p_cond->hSemaphore, p_cond->nWaiters, 0)) + result = -1; + else if(WaitForSingleObject (p_cond->hEventWaitersDone, INFINITE) != WAIT_OBJECT_0) + result = -1; + p_cond->bWasBroadcast = 0; + } + return result; +} + + +int NdbCondition_Destroy(struct NdbCondition* p_cond) +{ + int result; + if(!p_cond) + return 1; + + CloseHandle(p_cond->hEventWaitersDone); + NdbMutex_Destroy(p_cond->pNdbMutexWaitersLock); + result = (CloseHandle(p_cond->hSemaphore) ? 0 : -1); + + free(p_cond); + return 0; +} + diff --git a/ndb/src/common/portlib/win32/NdbDaemon.c b/ndb/src/common/portlib/win32/NdbDaemon.c new file mode 100644 index 00000000000..b96d4c20260 --- /dev/null +++ b/ndb/src/common/portlib/win32/NdbDaemon.c @@ -0,0 +1,44 @@ +/* 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 "NdbDaemon.h" + +#define NdbDaemon_ErrorSize 500 +long NdbDaemon_DaemonPid; +int NdbDaemon_ErrorCode; +char NdbDaemon_ErrorText[NdbDaemon_ErrorSize]; + +int +NdbDaemon_Make(const char* lockfile, const char* logfile, unsigned flags) +{ + // XXX do something + return 0; +} + +#ifdef NDB_DAEMON_TEST + +int +main() +{ + if (NdbDaemon_Make("test.pid", "test.log", 0) == -1) { + fprintf(stderr, "NdbDaemon_Make: %s\n", NdbDaemon_ErrorText); + return 1; + } + sleep(10); + return 0; +} + +#endif diff --git a/ndb/src/common/portlib/win32/NdbEnv.c b/ndb/src/common/portlib/win32/NdbEnv.c new file mode 100644 index 00000000000..f42e685fe15 --- /dev/null +++ b/ndb/src/common/portlib/win32/NdbEnv.c @@ -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 */ + +#include <ndb_global.h> +#include "NdbEnv.h" + +const char* NdbEnv_GetEnv(const char* name, char * buf, int buflen) +{ + char* p = NULL; + p = getenv(name); + + if (p != NULL && buf != NULL){ + strncpy(buf, p, buflen); + buf[buflen-1] = 0; + } + return p; +} + diff --git a/ndb/src/common/editline/editline_internal.h b/ndb/src/common/portlib/win32/NdbHost.c index 5ed2b32a873..7df96c45991 100644 --- a/ndb/src/common/editline/editline_internal.h +++ b/ndb/src/common/portlib/win32/NdbHost.c @@ -14,33 +14,39 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Revision: 1.2 $ -** -** Internal header file for editline library. -*/ #include <ndb_global.h> - -#if defined(SYS_UNIX) -#include "unix.h" -#endif /* defined(SYS_UNIX) */ - -#define MEM_INC 64 -#define SCREEN_INC 256 - -/* -** Variables and routines internal to this package. -*/ -extern int rl_eof; -extern int rl_erase; -extern int rl_intr; -extern int rl_kill; -extern int rl_quit; -#if defined(DO_SIGTSTP) -extern int rl_susp; -#endif /* defined(DO_SIGTSTP) */ -extern char *rl_complete(); -extern int rl_list_possib(); -extern void rl_ttyset(); -extern void rl_add_slash(); +#include "NdbHost.h" + + +int NdbHost_GetHostName(char* buf) +{ + /* We must initialize TCP/IP if we want to call gethostname */ + WORD wVersionRequested; + WSADATA wsaData; + int err; + + wVersionRequested = MAKEWORD( 2, 0 ); + err = WSAStartup( wVersionRequested, &wsaData ); + if ( err != 0 ) { + /** + * Tell the user that we couldn't find a usable + * WinSock DLL. + */ + return -1; + } + + /* Get host name */ + if(gethostname(buf, MAXHOSTNAMELEN)) + { + return -1; + } + return 0; +} + + +int NdbHost_GetProcessId(void) +{ + return _getpid(); +} diff --git a/ndb/src/common/portlib/win32/NdbMem.c b/ndb/src/common/portlib/win32/NdbMem.c new file mode 100644 index 00000000000..313ca9dff66 --- /dev/null +++ b/ndb/src/common/portlib/win32/NdbMem.c @@ -0,0 +1,283 @@ +/* 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 "NdbMem.h" + +#if 0 +struct AWEINFO +{ + SIZE_T dwSizeInBytesRequested; + ULONG_PTR nNumberOfPagesRequested; + ULONG_PTR nNumberOfPagesActual; + ULONG_PTR nNumberOfPagesFreed; + ULONG_PTR* pnPhysicalMemoryPageArray; + void* pRegionReserved; +}; + +const size_t cNdbMem_nMaxAWEinfo = 256; +size_t gNdbMem_nAWEinfo = 0; + +struct AWEINFO* gNdbMem_pAWEinfo = 0; + + +void ShowLastError(const char* szContext, const char* szFunction) +{ + DWORD dwError = GetLastError(); + LPVOID lpMsgBuf; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dwError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR)&lpMsgBuf, + 0, + NULL + ); + printf("%s : %s failed : %lu : %s\n", szContext, szFunction, dwError, (char*)lpMsgBuf); + LocalFree(lpMsgBuf); +} + + + +void NdbMem_Create() +{ + // Address Windowing Extensions + struct PRIVINFO + { + DWORD Count; + LUID_AND_ATTRIBUTES Privilege[1]; + } Info; + + HANDLE hProcess = GetCurrentProcess(); + HANDLE hToken; + if(!OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, &hToken)) + { + ShowLastError("NdbMem_Create", "OpenProcessToken"); + } + + Info.Count = 1; + Info.Privilege[0].Attributes = SE_PRIVILEGE_ENABLED; + if(!LookupPrivilegeValue(0, SE_LOCK_MEMORY_NAME, &(Info.Privilege[0].Luid))) + { + ShowLastError("NdbMem_Create", "LookupPrivilegeValue"); + } + + if(!AdjustTokenPrivileges(hToken, FALSE, (PTOKEN_PRIVILEGES)&Info, 0, 0, 0)) + { + ShowLastError("NdbMem_Create", "AdjustTokenPrivileges"); + } + + if(!CloseHandle(hToken)) + { + ShowLastError("NdbMem_Create", "CloseHandle"); + } + + return; +} + +void NdbMem_Destroy() +{ + /* Do nothing */ + return; +} + +void* NdbMem_Allocate(size_t size) +{ + // Address Windowing Extensions + struct AWEINFO* pAWEinfo; + HANDLE hProcess; + SYSTEM_INFO sysinfo; + + if(!gNdbMem_pAWEinfo) + { + gNdbMem_pAWEinfo = VirtualAlloc(0, + sizeof(struct AWEINFO)*cNdbMem_nMaxAWEinfo, + MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE); + } + + assert(gNdbMem_nAWEinfo < cNdbMem_nMaxAWEinfo); + pAWEinfo = gNdbMem_pAWEinfo+gNdbMem_nAWEinfo++; + + hProcess = GetCurrentProcess(); + GetSystemInfo(&sysinfo); + pAWEinfo->nNumberOfPagesRequested = (size+sysinfo.dwPageSize-1)/sysinfo.dwPageSize; + pAWEinfo->pnPhysicalMemoryPageArray = VirtualAlloc(0, + sizeof(ULONG_PTR)*pAWEinfo->nNumberOfPagesRequested, + MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE); + pAWEinfo->nNumberOfPagesActual = pAWEinfo->nNumberOfPagesRequested; + if(!AllocateUserPhysicalPages(hProcess, &(pAWEinfo->nNumberOfPagesActual), pAWEinfo->pnPhysicalMemoryPageArray)) + { + ShowLastError("NdbMem_Allocate", "AllocateUserPhysicalPages"); + return 0; + } + if(pAWEinfo->nNumberOfPagesRequested != pAWEinfo->nNumberOfPagesActual) + { + ShowLastError("NdbMem_Allocate", "nNumberOfPagesRequested != nNumberOfPagesActual"); + return 0; + } + + pAWEinfo->dwSizeInBytesRequested = size; + pAWEinfo->pRegionReserved = VirtualAlloc(0, pAWEinfo->dwSizeInBytesRequested, MEM_RESERVE | MEM_PHYSICAL, PAGE_READWRITE); + if(!pAWEinfo->pRegionReserved) + { + ShowLastError("NdbMem_Allocate", "VirtualAlloc"); + return 0; + } + + if(!MapUserPhysicalPages(pAWEinfo->pRegionReserved, pAWEinfo->nNumberOfPagesActual, pAWEinfo->pnPhysicalMemoryPageArray)) + { + ShowLastError("NdbMem_Allocate", "MapUserPhysicalPages"); + return 0; + } + + /* + printf("allocate AWE memory: %lu bytes, %lu pages, address %lx\n", + pAWEinfo->dwSizeInBytesRequested, + pAWEinfo->nNumberOfPagesActual, + pAWEinfo->pRegionReserved); + */ + return pAWEinfo->pRegionReserved; +} + + +void* NdbMem_AllocateAlign(size_t size, size_t alignment) +{ + /* + return (void*)memalign(alignment, size); + TEMP fix + */ + return NdbMem_Allocate(size); +} + + +void NdbMem_Free(void* ptr) +{ + // VirtualFree(ptr, 0, MEM_DECOMMIT|MEM_RELEASE); + + // Address Windowing Extensions + struct AWEINFO* pAWEinfo = 0; + size_t i; + HANDLE hProcess; + + for(i=0; i<gNdbMem_nAWEinfo; ++i) + { + if(ptr==gNdbMem_pAWEinfo[i].pRegionReserved) + { + pAWEinfo = gNdbMem_pAWEinfo+i; + } + } + if(!pAWEinfo) + { + ShowLastError("NdbMem_Free", "ptr is not AWE memory"); + } + + hProcess = GetCurrentProcess(); + if(!MapUserPhysicalPages(ptr, pAWEinfo->nNumberOfPagesActual, 0)) + { + ShowLastError("NdbMem_Free", "MapUserPhysicalPages"); + } + + if(!VirtualFree(ptr, 0, MEM_RELEASE)) + { + ShowLastError("NdbMem_Free", "VirtualFree"); + } + + pAWEinfo->nNumberOfPagesFreed = pAWEinfo->nNumberOfPagesActual; + if(!FreeUserPhysicalPages(hProcess, &(pAWEinfo->nNumberOfPagesFreed), pAWEinfo->pnPhysicalMemoryPageArray)) + { + ShowLastError("NdbMem_Free", "FreeUserPhysicalPages"); + } + + VirtualFree(pAWEinfo->pnPhysicalMemoryPageArray, 0, MEM_DECOMMIT|MEM_RELEASE); +} + + +int NdbMem_MemLockAll() +{ + /* + HANDLE hProcess = GetCurrentProcess(); + SIZE_T nMinimumWorkingSetSize; + SIZE_T nMaximumWorkingSetSize; + GetProcessWorkingSetSize(hProcess, &nMinimumWorkingSetSize, &nMaximumWorkingSetSize); + ndbout << "nMinimumWorkingSetSize=" << nMinimumWorkingSetSize << ", nMaximumWorkingSetSize=" << nMaximumWorkingSetSize << endl; + + SetProcessWorkingSetSize(hProcess, 50000000, 100000000); + + GetProcessWorkingSetSize(hProcess, &nMinimumWorkingSetSize, &nMaximumWorkingSetSize); + ndbout << "nMinimumWorkingSetSize=" << nMinimumWorkingSetSize << ", nMaximumWorkingSetSize=" << nMaximumWorkingSetSize << endl; + */ + return -1; +} + +int NdbMem_MemUnlockAll() +{ + //VirtualUnlock(); + return -1; +} + +#endif + +void NdbMem_Create() +{ + /* Do nothing */ + return; +} + +void NdbMem_Destroy() +{ + /* Do nothing */ + return; +} + + +void* NdbMem_Allocate(size_t size) +{ + void* mem_allocated; + assert(size > 0); + mem_allocated= (void*)malloc(size); + return mem_allocated; +} + +void* NdbMem_AllocateAlign(size_t size, size_t alignment) +{ + (void)alignment; /* remove warning for unused parameter */ + /* + return (void*)memalign(alignment, size); + TEMP fix + */ + return (void*)malloc(size); +} + + +void NdbMem_Free(void* ptr) +{ + free(ptr); +} + + +int NdbMem_MemLockAll() +{ + return 0; +} + +int NdbMem_MemUnlockAll() +{ + return 0; +} + diff --git a/ndb/src/common/portlib/win32/NdbMutex.c b/ndb/src/common/portlib/win32/NdbMutex.c new file mode 100644 index 00000000000..e6d1f081e9a --- /dev/null +++ b/ndb/src/common/portlib/win32/NdbMutex.c @@ -0,0 +1,73 @@ +/* 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 "NdbMutex.h" + +NdbMutex* NdbMutex_Create(void) +{ + NdbMutex* pNdbMutex = (NdbMutex*)malloc(sizeof(NdbMutex)); + if(!pNdbMutex) + return 0; + + InitializeCriticalSection(pNdbMutex); + return pNdbMutex; +} + + +int NdbMutex_Destroy(NdbMutex* p_mutex) +{ + if(!p_mutex) + return -1; + + DeleteCriticalSection(p_mutex); + free(p_mutex); + return 0; +} + + +int NdbMutex_Lock(NdbMutex* p_mutex) +{ + if(!p_mutex) + return -1; + + EnterCriticalSection (p_mutex); + return 0; +} + + +int NdbMutex_Unlock(NdbMutex* p_mutex) +{ + if(!p_mutex) + return -1; + + LeaveCriticalSection(p_mutex); + return 0; +} + + +int NdbMutex_Trylock(NdbMutex* p_mutex) +{ + int result = -1; + if(p_mutex) + { + result = NdbMutex_Lock(p_mutex); + //(TryEnterCriticalSection(p_mutex) ? 0 : -1); + } + return result; +} + diff --git a/ndb/src/common/editline/editline_win32.c b/ndb/src/common/portlib/win32/NdbSleep.c index 5083edb7fae..8f5bdc49acd 100644 --- a/ndb/src/common/editline/editline_win32.c +++ b/ndb/src/common/portlib/win32/NdbSleep.c @@ -14,19 +14,19 @@ 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 "NdbSleep.h" - -char* readline(const char* prompt) +int +NdbSleep_MilliSleep(int milliseconds) { - char* szBuf; - printf(prompt); - szBuf = (char*)malloc(256); - return gets(szBuf); + Sleep(milliseconds); + return 0; } -void add_history(char* pch) +int +NdbSleep_SecSleep(int seconds) { + return NdbSleep_MilliSleep(seconds*1000); } diff --git a/ndb/src/common/portlib/win32/NdbTCP.c b/ndb/src/common/portlib/win32/NdbTCP.c new file mode 100644 index 00000000000..b936cd2db6c --- /dev/null +++ b/ndb/src/common/portlib/win32/NdbTCP.c @@ -0,0 +1,39 @@ +/* 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 "NdbTCP.h" + +int +Ndb_getInAddr(struct in_addr * dst, const char *address) +{ + struct hostent * hostPtr; + + /* Try it as aaa.bbb.ccc.ddd. */ + dst->s_addr = inet_addr(address); + if (dst->s_addr != -1) { + return 0; + } + + hostPtr = gethostbyname(address); + if (hostPtr != NULL) { + dst->s_addr = ((struct in_addr *) *hostPtr->h_addr_list)->s_addr; + return 0; + } + + return -1; +} + diff --git a/ndb/src/common/portlib/win32/NdbThread.c b/ndb/src/common/portlib/win32/NdbThread.c new file mode 100644 index 00000000000..98db0d5c287 --- /dev/null +++ b/ndb/src/common/portlib/win32/NdbThread.c @@ -0,0 +1,114 @@ +/* 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 "NdbThread.h" +#include <process.h> + +#define MAX_THREAD_NAME 16 + +typedef unsigned (WINAPI* NDB_WIN32_THREAD_FUNC)(void*); + + +struct NdbThread +{ + HANDLE hThread; + unsigned nThreadId; + char thread_name[MAX_THREAD_NAME]; +}; + + +struct NdbThread* NdbThread_Create(NDB_THREAD_FUNC *p_thread_func, + NDB_THREAD_ARG *p_thread_arg, + const NDB_THREAD_STACKSIZE thread_stack_size, + const char* p_thread_name, + NDB_THREAD_PRIO thread_prio) +{ + struct NdbThread* tmpThread; + unsigned initflag; + int nPriority = 0; + + if(!p_thread_func) + return 0; + + tmpThread = (struct NdbThread*)malloc(sizeof(struct NdbThread)); + if(!tmpThread) + return 0; + + strncpy((char*)&tmpThread->thread_name, p_thread_name, MAX_THREAD_NAME); + + switch(thread_prio) + { + case NDB_THREAD_PRIO_HIGHEST: nPriority=THREAD_PRIORITY_HIGHEST; break; + case NDB_THREAD_PRIO_HIGH: nPriority=THREAD_PRIORITY_ABOVE_NORMAL; break; + case NDB_THREAD_PRIO_MEAN: nPriority=THREAD_PRIORITY_NORMAL; break; + case NDB_THREAD_PRIO_LOW: nPriority=THREAD_PRIORITY_BELOW_NORMAL; break; + case NDB_THREAD_PRIO_LOWEST: nPriority=THREAD_PRIORITY_LOWEST; break; + } + initflag = (nPriority ? CREATE_SUSPENDED : 0); + + tmpThread->hThread = (HANDLE)_beginthreadex(0, thread_stack_size, + (NDB_WIN32_THREAD_FUNC)p_thread_func, p_thread_arg, + initflag, &tmpThread->nThreadId); + + if(nPriority && tmpThread->hThread) + { + SetThreadPriority(tmpThread->hThread, nPriority); + ResumeThread (tmpThread->hThread); + } + + assert(tmpThread->hThread); + return tmpThread; +} + + +void NdbThread_Destroy(struct NdbThread** p_thread) +{ + CloseHandle((*p_thread)->hThread); + (*p_thread)->hThread = 0; + free(*p_thread); + *p_thread = 0; +} + + +int NdbThread_WaitFor(struct NdbThread* p_wait_thread, void** status) +{ + void *local_status = 0; + if (status == 0) + status = &local_status; + + if(WaitForSingleObject(p_wait_thread->hThread, INFINITE) == WAIT_OBJECT_0 + && GetExitCodeThread(p_wait_thread->hThread, (LPDWORD)status)) + { + CloseHandle(p_wait_thread->hThread); + p_wait_thread->hThread = 0; + return 0; + } + return -1; +} + + +void NdbThread_Exit(int status) +{ + _endthreadex((DWORD) status); +} + + +int NdbThread_SetConcurrencyLevel(int level) +{ + return 0; +} + diff --git a/ndb/src/common/portlib/win32/NdbTick.c b/ndb/src/common/portlib/win32/NdbTick.c new file mode 100644 index 00000000000..4430cbf419b --- /dev/null +++ b/ndb/src/common/portlib/win32/NdbTick.c @@ -0,0 +1,64 @@ +/* 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 "NdbTick.h" +//#include <windows.h> + +/* +#define FILETIME_PER_MICROSEC 10 +#define FILETIME_PER_MILLISEC 10000 +#define FILETIME_PER_SEC 10000000 + + +NDB_TICKS NdbTick_CurrentMillisecond(void) +{ + ULONGLONG ullTime; + GetSystemTimeAsFileTime((LPFILETIME)&ullTime); + return (ullTime / FILETIME_PER_MILLISEC); +} + +int +NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros) +{ + ULONGLONG ullTime; + GetSystemTimeAsFileTime((LPFILETIME)&ullTime); + *secs = (ullTime / FILETIME_PER_SEC); + *micros = (Uint32)((ullTime % FILETIME_PER_SEC) / FILETIME_PER_MICROSEC); + return 0; +} +*/ + + +NDB_TICKS NdbTick_CurrentMillisecond(void) +{ + LARGE_INTEGER liCount, liFreq; + QueryPerformanceCounter(&liCount); + QueryPerformanceFrequency(&liFreq); + return (liCount.QuadPart*1000) / liFreq.QuadPart; +} + +int +NdbTick_CurrentMicrosecond(NDB_TICKS * secs, Uint32 * micros) +{ + LARGE_INTEGER liCount, liFreq; + QueryPerformanceCounter(&liCount); + QueryPerformanceFrequency(&liFreq); + *secs = liCount.QuadPart / liFreq.QuadPart; + liCount.QuadPart -= *secs * liFreq.QuadPart; + *micros = (liCount.QuadPart*1000000) / liFreq.QuadPart; + return 0; +} diff --git a/ndb/src/common/transporter/Makefile.am b/ndb/src/common/transporter/Makefile.am index 9d91a210d46..b902012e56d 100644 --- a/ndb/src/common/transporter/Makefile.am +++ b/ndb/src/common/transporter/Makefile.am @@ -13,10 +13,24 @@ EXTRA_libtransporter_la_SOURCES = SHM_Transporter.cpp SHM_Transporter.unix.cpp S libtransporter_la_LIBADD = @ndb_transporter_opt_objs@ libtransporter_la_DEPENDENCIES = @ndb_transporter_opt_objs@ -INCLUDES_LOC = -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/include/transporter @NDB_SCI_INCLUDES@ +INCLUDES_LOC = -I$(top_srcdir)/ndb/include/mgmapi -I$(top_srcdir)/ndb/include/debugger -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/include/transporter @NDB_SCI_INCLUDES@ include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_util.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libtransporter.dsp + +libtransporter.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libtransporter_la_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/common/transporter/Makefile_old b/ndb/src/common/transporter/Makefile_old deleted file mode 100644 index 372bf640566..00000000000 --- a/ndb/src/common/transporter/Makefile_old +++ /dev/null @@ -1,43 +0,0 @@ -include .defs.mk - -TYPE := util - -PIC_ARCHIVE := Y -ARCHIVE_TARGET := transporter -DIRS := basictest perftest - -# Source files of non-templated classes (.cpp files) -SOURCES = \ - Transporter.cpp \ - SendBuffer.cpp \ - TCP_Transporter.cpp \ - TransporterRegistry.cpp \ - Packer.cpp - -DIRS := basictest perftest - -CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/include/kernel) \ - -I$(call fixpath,$(NDB_TOP)/include/transporter) - - -ifeq ($(NDB_SHM), Y) -SOURCES += SHM_Transporter.cpp -ifeq ($(NDB_OS), WIN32) -SOURCES += SHM_Transporter.win32.cpp -else -SOURCES += SHM_Transporter.unix.cpp -endif -endif - -ifeq ($(NDB_SCI), Y) -SOURCES += SCI_Transporter.cpp -endif - -ifneq ($(findstring OSE, $(NDB_OS)),) - SOURCES += OSE_Transporter.cpp - SOURCES += OSE_Receiver.cpp -endif - - - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/common/transporter/SCI_Transporter.cpp b/ndb/src/common/transporter/SCI_Transporter.cpp index 73fbb064599..e7807c972b1 100644 --- a/ndb/src/common/transporter/SCI_Transporter.cpp +++ b/ndb/src/common/transporter/SCI_Transporter.cpp @@ -44,7 +44,8 @@ SCI_Transporter::SCI_Transporter(TransporterRegistry &t_reg, bool chksm, bool signalId, Uint32 reportFreq) : - Transporter(t_reg, lHostName, rHostName, r_port, _localNodeId, + Transporter(t_reg, tt_SCI_TRANSPORTER, + lHostName, rHostName, r_port, _localNodeId, _remoteNodeId, 0, false, chksm, signalId) { DBUG_ENTER("SCI_Transporter::SCI_Transporter"); diff --git a/ndb/src/common/transporter/SHM_Transporter.cpp b/ndb/src/common/transporter/SHM_Transporter.cpp index ab161d8c18c..eed3ad77be6 100644 --- a/ndb/src/common/transporter/SHM_Transporter.cpp +++ b/ndb/src/common/transporter/SHM_Transporter.cpp @@ -26,6 +26,8 @@ #include <InputStream.hpp> #include <OutputStream.hpp> +extern int g_ndb_shm_signum; + SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, const char *lHostName, const char *rHostName, @@ -36,7 +38,8 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, bool signalId, key_t _shmKey, Uint32 _shmSize) : - Transporter(t_reg, lHostName, rHostName, r_port, lNodeId, rNodeId, + Transporter(t_reg, tt_SHM_TRANSPORTER, + lHostName, rHostName, r_port, lNodeId, rNodeId, 0, false, checksum, signalId), shmKey(_shmKey), shmSize(_shmSize) @@ -52,6 +55,7 @@ SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, #ifdef DEBUG_TRANSPORTER printf("shm key (%d - %d) = %d\n", lNodeId, rNodeId, shmKey); #endif + m_signal_threshold = 4096; } SHM_Transporter::~SHM_Transporter(){ @@ -60,7 +64,9 @@ SHM_Transporter::~SHM_Transporter(){ bool SHM_Transporter::initTransporter(){ - return true; + if (g_ndb_shm_signum) + return true; + return false; } void @@ -182,42 +188,6 @@ SHM_Transporter::setupBuffers(){ #endif } -#if 0 -SendStatus -SHM_Transporter::prepareSend(const SignalHeader * const signalHeader, - Uint8 prio, - const Uint32 * const signalData, - const LinearSegmentPtr ptr[3], - bool force){ - - if(isConnected()){ - - const Uint32 lenBytes = m_packer.getMessageLength(signalHeader, ptr); - - Uint32 * insertPtr = (Uint32 *)writer->getWritePtr(lenBytes); - - if(insertPtr != 0){ - - m_packer.pack(insertPtr, prio, signalHeader, signalData, ptr); - - /** - * Do funky membar stuff - */ - - writer->updateWritePtr(lenBytes); - return SEND_OK; - - } else { - // NdbSleep_MilliSleep(3); - //goto tryagain; - return SEND_BUFFER_FULL; - } - } - return SEND_DISCONNECTED; -} -#endif - - bool SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd) { @@ -247,10 +217,18 @@ SHM_Transporter::connect_server_impl(NDB_SOCKET_TYPE sockfd) } // Send ok to client - s_output.println("shm server 1 ok"); - + s_output.println("shm server 1 ok: %d", + m_transporter_registry.m_shm_own_pid); + // Wait for ok from client - if (s_input.gets(buf, 256) == 0) { + if (s_input.gets(buf, 256) == 0) + { + NDB_CLOSE_SOCKET(sockfd); + DBUG_RETURN(false); + } + + if(sscanf(buf, "shm client 1 ok: %d", &m_remote_pid) != 1) + { NDB_CLOSE_SOCKET(sockfd); DBUG_RETURN(false); } @@ -281,6 +259,9 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd) SocketOutputStream s_output(sockfd); char buf[256]; +#if 1 +#endif + // Wait for server to create and attach if (s_input.gets(buf, 256) == 0) { NDB_CLOSE_SOCKET(sockfd); @@ -289,6 +270,12 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd) DBUG_RETURN(false); } + if(sscanf(buf, "shm server 1 ok: %d", &m_remote_pid) != 1) + { + NDB_CLOSE_SOCKET(sockfd); + DBUG_RETURN(false); + } + // Create if(!_shmSegCreated){ if (!ndb_shm_get()) { @@ -313,10 +300,11 @@ SHM_Transporter::connect_client_impl(NDB_SOCKET_TYPE sockfd) } // Send ok to server - s_output.println("shm client 1 ok"); - + s_output.println("shm client 1 ok: %d", + m_transporter_registry.m_shm_own_pid); + int r= connect_common(sockfd); - + if (r) { // Wait for ok from server if (s_input.gets(buf, 256) == 0) { @@ -344,18 +332,33 @@ SHM_Transporter::connect_common(NDB_SOCKET_TYPE sockfd) return false; } - if(!setupBuffersDone) { + if(!setupBuffersDone) + { setupBuffers(); setupBuffersDone=true; } - if(setupBuffersDone) { + if(setupBuffersDone) + { NdbSleep_MilliSleep(m_timeOutMillis); if(*serverStatusFlag == 1 && *clientStatusFlag == 1) + { + m_last_signal = 0; return true; + } } DBUG_PRINT("error", ("Failed to set up buffers to node %d", remoteNodeId)); return false; } + +void +SHM_Transporter::doSend() +{ + if(m_last_signal) + { + m_last_signal = 0; + kill(m_remote_pid, g_ndb_shm_signum); + } +} diff --git a/ndb/src/common/transporter/SHM_Transporter.hpp b/ndb/src/common/transporter/SHM_Transporter.hpp index 27692209ffe..b501f652168 100644 --- a/ndb/src/common/transporter/SHM_Transporter.hpp +++ b/ndb/src/common/transporter/SHM_Transporter.hpp @@ -47,18 +47,25 @@ public: * SHM destructor */ virtual ~SHM_Transporter(); - + /** * Do initialization */ bool initTransporter(); - - Uint32 * getWritePtr(Uint32 lenBytes, Uint32 prio){ + + Uint32 * getWritePtr(Uint32 lenBytes, Uint32 prio) + { return (Uint32 *)writer->getWritePtr(lenBytes); } - void updateWritePtr(Uint32 lenBytes, Uint32 prio){ + void updateWritePtr(Uint32 lenBytes, Uint32 prio) + { writer->updateWritePtr(lenBytes); + m_last_signal += lenBytes; + if(m_last_signal >= m_signal_threshold) + { + doSend(); + } } void getReceivePtr(Uint32 ** ptr, Uint32 ** eod){ @@ -123,28 +130,36 @@ protected: */ void setupBuffers(); + /** + * doSend (i.e signal receiver) + */ + void doSend(); + int m_remote_pid; + Uint32 m_last_signal; + Uint32 m_signal_threshold; + private: bool _shmSegCreated; bool _attached; bool m_connected; - + key_t shmKey; volatile Uint32 * serverStatusFlag; volatile Uint32 * clientStatusFlag; bool setupBuffersDone; - + #ifdef NDB_WIN32 HANDLE hFileMapping; #else int shmId; #endif - + int shmSize; char * shmBuf; - + SHM_Reader * reader; SHM_Writer * writer; - + /** * @return - True if the reader has data to read on its segment. */ diff --git a/ndb/src/common/transporter/TCP_Transporter.cpp b/ndb/src/common/transporter/TCP_Transporter.cpp index 524ecd653e0..a629b620157 100644 --- a/ndb/src/common/transporter/TCP_Transporter.cpp +++ b/ndb/src/common/transporter/TCP_Transporter.cpp @@ -72,7 +72,8 @@ TCP_Transporter::TCP_Transporter(TransporterRegistry &t_reg, NodeId rNodeId, bool chksm, bool signalId, Uint32 _reportFreq) : - Transporter(t_reg, lHostName, rHostName, r_port, lNodeId, rNodeId, + Transporter(t_reg, tt_TCP_TRANSPORTER, + lHostName, rHostName, r_port, lNodeId, rNodeId, 0, false, chksm, signalId), m_sendBuffer(sendBufSize) { diff --git a/ndb/src/common/transporter/Transporter.cpp b/ndb/src/common/transporter/Transporter.cpp index e68bc86718e..b84f8f6fb5e 100644 --- a/ndb/src/common/transporter/Transporter.cpp +++ b/ndb/src/common/transporter/Transporter.cpp @@ -24,7 +24,11 @@ #include <InputStream.hpp> #include <OutputStream.hpp> +#include <EventLogger.hpp> +extern EventLogger g_eventLogger; + Transporter::Transporter(TransporterRegistry &t_reg, + TransporterType _type, const char *lHostName, const char *rHostName, int r_port, @@ -35,8 +39,10 @@ Transporter::Transporter(TransporterRegistry &t_reg, : m_r_port(r_port), remoteNodeId(rNodeId), localNodeId(lNodeId), isServer(lNodeId < rNodeId), m_packer(_signalId, _checksum), + m_type(_type), m_transporter_registry(t_reg) { + DBUG_ENTER("Transporter::Transporter"); if (rHostName && strlen(rHostName) > 0){ strncpy(remoteHostName, rHostName, sizeof(remoteHostName)); Ndb_getInAddr(&remoteHostAddress, rHostName); @@ -55,6 +61,11 @@ Transporter::Transporter(TransporterRegistry &t_reg, if (strlen(lHostName) > 0) Ndb_getInAddr(&localHostAddress, lHostName); + DBUG_PRINT("info",("rId=%d lId=%d isServer=%d rHost=%s lHost=%s r_port=%d", + remoteNodeId, localNodeId, isServer, + remoteHostName, localHostName, + r_port)); + byteOrder = _byteorder; compressionUsed = _compression; checksumUsed = _checksum; @@ -67,7 +78,9 @@ Transporter::Transporter(TransporterRegistry &t_reg, m_socket_client= 0; else m_socket_client= new SocketClient(remoteHostName, r_port, - new SocketAuthSimple("ndbd", "ndbd passwd")); + new SocketAuthSimple("ndbd", + "ndbd passwd")); + DBUG_VOID_RETURN; } Transporter::~Transporter(){ @@ -77,8 +90,13 @@ Transporter::~Transporter(){ bool Transporter::connect_server(NDB_SOCKET_TYPE sockfd) { + // all initial negotiation is done in TransporterRegistry::connect_server + DBUG_ENTER("Transporter::connect_server"); + if(m_connected) - return true; // TODO assert(0); + { + DBUG_RETURN(true); // TODO assert(0); + } bool res = connect_server_impl(sockfd); if(res){ @@ -86,7 +104,7 @@ Transporter::connect_server(NDB_SOCKET_TYPE sockfd) { m_errorCount = 0; } - return res; + DBUG_RETURN(res); } bool @@ -95,30 +113,63 @@ Transporter::connect_client() { return true; NDB_SOCKET_TYPE sockfd = m_socket_client->connect(); - if (sockfd < 0) + if (sockfd == NDB_INVALID_SOCKET) return false; - // send info about own id + DBUG_ENTER("Transporter::connect_client"); + + // send info about own id + // send info about own transporter type SocketOutputStream s_output(sockfd); - s_output.println("%d", localNodeId); + s_output.println("%d %d", localNodeId, m_type); // get remote id - int nodeId; + int nodeId, remote_transporter_type= -1; SocketInputStream s_input(sockfd); char buf[256]; if (s_input.gets(buf, 256) == 0) { NDB_CLOSE_SOCKET(sockfd); - return false; + DBUG_RETURN(false); } - if (sscanf(buf, "%d", &nodeId) != 1) { + + int r= sscanf(buf, "%d %d", &nodeId, &remote_transporter_type); + switch (r) { + case 2: + break; + case 1: + // we're running version prior to 4.1.9 + // ok, but with no checks on transporter configuration compatability + break; + default: NDB_CLOSE_SOCKET(sockfd); - return false; + DBUG_RETURN(false); } + + DBUG_PRINT("info", ("nodeId=%d remote_transporter_type=%d", + nodeId, remote_transporter_type)); + + if (remote_transporter_type != -1) + { + if (remote_transporter_type != m_type) + { + DBUG_PRINT("error", ("Transporter types mismatch this=%d remote=%d", + m_type, remote_transporter_type)); + NDB_CLOSE_SOCKET(sockfd); + g_eventLogger.error("Incompatible configuration: transporter type " + "mismatch with node %d", nodeId); + DBUG_RETURN(false); + } + } + else if (m_type == tt_SHM_TRANSPORTER) + { + g_eventLogger.warning("Unable to verify transporter compatability with node %d", nodeId); + } + bool res = connect_client_impl(sockfd); if(res){ m_connected = true; m_errorCount = 0; } - return res; + DBUG_RETURN(res); } void diff --git a/ndb/src/common/transporter/Transporter.hpp b/ndb/src/common/transporter/Transporter.hpp index 9a39f8788bc..baff6d53dd8 100644 --- a/ndb/src/common/transporter/Transporter.hpp +++ b/ndb/src/common/transporter/Transporter.hpp @@ -71,6 +71,7 @@ public: protected: Transporter(TransporterRegistry &, + TransporterType, const char *lHostName, const char *rHostName, int r_port, @@ -127,6 +128,7 @@ protected: protected: bool m_connected; // Are we connected + TransporterType m_type; TransporterRegistry &m_transporter_registry; void *get_callback_obj() { return m_transporter_registry.callbackObj; }; @@ -149,7 +151,7 @@ Transporter::getRemoteNodeId() const { inline NodeId Transporter::getLocalNodeId() const { - return remoteNodeId; + return localNodeId; } inline diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index cacbbed00f1..439730435ec 100644 --- a/ndb/src/common/transporter/TransporterRegistry.cpp +++ b/ndb/src/common/transporter/TransporterRegistry.cpp @@ -38,6 +38,7 @@ #ifdef NDB_SHM_TRANSPORTER #include "SHM_Transporter.hpp" +extern int g_ndb_shm_signum; #endif #include "TransporterCallback.hpp" @@ -47,6 +48,9 @@ #include <InputStream.hpp> #include <OutputStream.hpp> +#include <EventLogger.hpp> +extern EventLogger g_eventLogger; + SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd) { DBUG_ENTER("SocketServer::Session * TransporterService::newSession"); @@ -55,49 +59,10 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd) DBUG_RETURN(0); } + if (!m_transporter_registry->connect_server(sockfd)) { - // read node id from client - int nodeId; - SocketInputStream s_input(sockfd); - char buf[256]; - if (s_input.gets(buf, 256) == 0) { - NDB_CLOSE_SOCKET(sockfd); - DBUG_PRINT("error", ("Could not get node id from client")); - DBUG_RETURN(0); - } - if (sscanf(buf, "%d", &nodeId) != 1) { - NDB_CLOSE_SOCKET(sockfd); - DBUG_PRINT("error", ("Error in node id from client")); - DBUG_RETURN(0); - } - - //check that nodeid is valid and that there is an allocated transporter - if ( nodeId < 0 || nodeId >= (int)m_transporter_registry->maxTransporters) { - NDB_CLOSE_SOCKET(sockfd); - DBUG_PRINT("error", ("Node id out of range from client")); - DBUG_RETURN(0); - } - if (m_transporter_registry->theTransporters[nodeId] == 0) { - NDB_CLOSE_SOCKET(sockfd); - DBUG_PRINT("error", ("No transporter for this node id from client")); - DBUG_RETURN(0); - } - - //check that the transporter should be connected - if (m_transporter_registry->performStates[nodeId] != TransporterRegistry::CONNECTING) { - NDB_CLOSE_SOCKET(sockfd); - DBUG_PRINT("error", ("Transporter in wrong state for this node id from client")); - DBUG_RETURN(0); - } - - Transporter *t= m_transporter_registry->theTransporters[nodeId]; - - // send info about own id (just as response to acknowledge connection) - SocketOutputStream s_output(sockfd); - s_output.println("%d", t->getLocalNodeId()); - - // setup transporter (transporter responsible for closing sockfd) - t->connect_server(sockfd); + NDB_CLOSE_SOCKET(sockfd); + DBUG_RETURN(0); } DBUG_RETURN(0); @@ -184,13 +149,98 @@ TransporterRegistry::disconnectAll(){ bool TransporterRegistry::init(NodeId nodeId) { + DBUG_ENTER("TransporterRegistry::init"); nodeIdSpecified = true; localNodeId = nodeId; DEBUG("TransporterRegistry started node: " << localNodeId); - // return allocateLongSignalMemoryPool(nLargeSegments); - return true; + DBUG_RETURN(true); +} + +bool +TransporterRegistry::connect_server(NDB_SOCKET_TYPE sockfd) +{ + DBUG_ENTER("TransporterRegistry::connect_server"); + + // read node id from client + // read transporter type + int nodeId, remote_transporter_type= -1; + SocketInputStream s_input(sockfd); + char buf[256]; + if (s_input.gets(buf, 256) == 0) { + DBUG_PRINT("error", ("Could not get node id from client")); + DBUG_RETURN(false); + } + int r= sscanf(buf, "%d %d", &nodeId, &remote_transporter_type); + switch (r) { + case 2: + break; + case 1: + // we're running version prior to 4.1.9 + // ok, but with no checks on transporter configuration compatability + break; + default: + DBUG_PRINT("error", ("Error in node id from client")); + DBUG_RETURN(false); + } + + DBUG_PRINT("info", ("nodeId=%d remote_transporter_type=%d", + nodeId,remote_transporter_type)); + + //check that nodeid is valid and that there is an allocated transporter + if ( nodeId < 0 || nodeId >= (int)maxTransporters) { + DBUG_PRINT("error", ("Node id out of range from client")); + DBUG_RETURN(false); + } + if (theTransporters[nodeId] == 0) { + DBUG_PRINT("error", ("No transporter for this node id from client")); + DBUG_RETURN(false); + } + + //check that the transporter should be connected + if (performStates[nodeId] != TransporterRegistry::CONNECTING) { + DBUG_PRINT("error", ("Transporter in wrong state for this node id from client")); + DBUG_RETURN(false); + } + + Transporter *t= theTransporters[nodeId]; + + // send info about own id (just as response to acknowledge connection) + // send info on own transporter type + SocketOutputStream s_output(sockfd); + s_output.println("%d %d", t->getLocalNodeId(), t->m_type); + + if (remote_transporter_type != -1) + { + if (remote_transporter_type != t->m_type) + { + DBUG_PRINT("error", ("Transporter types mismatch this=%d remote=%d", + t->m_type, remote_transporter_type)); + g_eventLogger.error("Incompatible configuration: Transporter type " + "mismatch with node %d", nodeId); + + // wait for socket close for 1 second to let message arrive at client + { + fd_set a_set; + FD_ZERO(&a_set); + FD_SET(sockfd, &a_set); + struct timeval timeout; + timeout.tv_sec = 1; timeout.tv_usec = 0; + select(sockfd+1, &a_set, 0, 0, &timeout); + } + DBUG_RETURN(false); + } + } + else if (t->m_type == tt_SHM_TRANSPORTER) + { + g_eventLogger.warning("Unable to verify transporter compatability with node %d", nodeId); + } + + // setup transporter (transporter responsible for closing sockfd) + t->connect_server(sockfd); + + DBUG_RETURN(true); } bool @@ -344,6 +394,7 @@ TransporterRegistry::createTransporter(SCI_TransporterConfiguration *config) { bool TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { + DBUG_ENTER("TransporterRegistry::createTransporter SHM"); #ifdef NDB_SHM_TRANSPORTER if(!nodeIdSpecified){ init(config->localNodeId); @@ -352,12 +403,28 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { if(config->localNodeId != localNodeId) return false; + if (!g_ndb_shm_signum) { + g_ndb_shm_signum= config->signum; + DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum)); + /** + * Make sure to block g_ndb_shm_signum + * TransporterRegistry::init is run from "main" thread + */ + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, g_ndb_shm_signum); + pthread_sigmask(SIG_BLOCK, &mask, 0); + } + + if(config->signum != g_ndb_shm_signum) + return false; + if(theTransporters[config->remoteNodeId] != NULL) return false; SHM_Transporter * t = new SHM_Transporter(*this, - "localhost", - "localhost", + config->localHostName, + config->remoteHostName, config->port, localNodeId, config->remoteNodeId, @@ -381,9 +448,9 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { nTransporters++; nSHMTransporters++; - return true; + DBUG_RETURN(true); #else - return false; + DBUG_RETURN(false); #endif } @@ -467,8 +534,9 @@ TransporterRegistry::prepareSend(const SignalHeader * const signalHeader, Transporter *t = theTransporters[nodeId]; if(t != NULL && (((ioStates[nodeId] != HaltOutput) && (ioStates[nodeId] != HaltIO)) || - (signalHeader->theReceiversBlockNumber == 252))) { - + ((signalHeader->theReceiversBlockNumber == 252) || + (signalHeader->theReceiversBlockNumber == 4002)))) { + if(t->isConnected()){ Uint32 lenBytes = t->m_packer.getMessageLength(signalHeader, ptr); if(lenBytes <= MAX_MESSAGE_SIZE){ @@ -538,8 +606,9 @@ TransporterRegistry::prepareSend(const SignalHeader * const signalHeader, Transporter *t = theTransporters[nodeId]; if(t != NULL && (((ioStates[nodeId] != HaltOutput) && (ioStates[nodeId] != HaltIO)) || - (signalHeader->theReceiversBlockNumber == 252))) { - + ((signalHeader->theReceiversBlockNumber == 252)|| + (signalHeader->theReceiversBlockNumber == 4002)))) { + if(t->isConnected()){ Uint32 lenBytes = t->m_packer.getMessageLength(signalHeader, ptr); if(lenBytes <= MAX_MESSAGE_SIZE){ @@ -550,7 +619,7 @@ TransporterRegistry::prepareSend(const SignalHeader * const signalHeader, return SEND_OK; } - + /** * @note: on linux/i386 the granularity is 10ms * so sleepTime = 2 generates a 10 ms sleep. @@ -620,11 +689,28 @@ TransporterRegistry::pollReceive(Uint32 timeOutMillis){ return retVal; #endif - if((nSHMTransporters+nSCITransporters) > 0) + if((nSCITransporters) > 0) + { timeOutMillis=0; + } + +#ifdef NDB_SHM_TRANSPORTER + if(nSHMTransporters > 0) + { + Uint32 res = poll_SHM(0); + if(res) + { + retVal |= res; + timeOutMillis = 0; + } + } +#endif + #ifdef NDB_TCP_TRANSPORTER - if(nTCPTransporters > 0) + if(nTCPTransporters > 0 || retVal == 0) + { retVal |= poll_TCP(timeOutMillis); + } else tcpReadSelectReply = 0; #endif @@ -633,8 +719,11 @@ TransporterRegistry::pollReceive(Uint32 timeOutMillis){ retVal |= poll_SCI(timeOutMillis); #endif #ifdef NDB_SHM_TRANSPORTER - if(nSHMTransporters > 0) - retVal |= poll_SHM(timeOutMillis); + if(nSHMTransporters > 0 && retVal == 0) + { + int res = poll_SHM(0); + retVal |= res; + } #endif return retVal; } @@ -642,8 +731,8 @@ TransporterRegistry::pollReceive(Uint32 timeOutMillis){ #ifdef NDB_SCI_TRANSPORTER Uint32 -TransporterRegistry::poll_SCI(Uint32 timeOutMillis){ - +TransporterRegistry::poll_SCI(Uint32 timeOutMillis) +{ for (int i=0; i<nSCITransporters; i++) { SCI_Transporter * t = theSCITransporters[i]; if (t->isConnected()) { @@ -657,73 +746,29 @@ TransporterRegistry::poll_SCI(Uint32 timeOutMillis){ #ifdef NDB_SHM_TRANSPORTER +static int g_shm_counter = 0; Uint32 TransporterRegistry::poll_SHM(Uint32 timeOutMillis) { - for(int j=0; j < 20; j++) - for (int i=0; i<nSHMTransporters; i++) { - SHM_Transporter * t = theSHMTransporters[i]; - if (t->isConnected()) { - if(t->hasDataToRead()) { - return 1; - } - } - } - /** - * @note: granularity of linux/i386 timer is not good enough. - * Can't sleep if using SHM as it is now. - */ - /* - if(timeOutMillis > 0) - NdbSleep_MilliSleep(timeOutMillis); - else - NdbSleep_MilliSleep(1); - */ - return 0; -#if 0 - NDB_TICKS startTime = NdbTick_CurrentMillisecond(); - for(int i=0; i<100; i++) { + for(int j=0; j < 100; j++) + { for (int i=0; i<nSHMTransporters; i++) { SHM_Transporter * t = theSHMTransporters[i]; if (t->isConnected()) { - if(t->hasDataToRead()){ + if(t->hasDataToRead()) { return 1; } - else - continue; } - else - continue; } - - if(NdbTick_CurrentMillisecond() > (startTime +timeOutMillis)) - return 0; } - NdbSleep_MilliSleep(5); return 0; - -#endif -#if 0 - - for(int j=0; j < 100; j++) { - for (int i=0; i<nSHMTransporters; i++) { - SHM_Transporter * t = theSHMTransporters[i]; - if (t->isConnected()) { - if(t->hasDataToRead()) - return 1; - } - } - } - return 0; -#endif } - - #endif #ifdef NDB_OSE_TRANSPORTER Uint32 -TransporterRegistry::poll_OSE(Uint32 timeOutMillis){ +TransporterRegistry::poll_OSE(Uint32 timeOutMillis) +{ if(theOSEReceiver != NULL){ return theOSEReceiver->doReceive(timeOutMillis); } @@ -734,18 +779,18 @@ TransporterRegistry::poll_OSE(Uint32 timeOutMillis){ #ifdef NDB_TCP_TRANSPORTER Uint32 -TransporterRegistry::poll_TCP(Uint32 timeOutMillis){ - - if (nTCPTransporters == 0){ +TransporterRegistry::poll_TCP(Uint32 timeOutMillis) +{ + if (false && nTCPTransporters == 0) + { tcpReadSelectReply = 0; return 0; } struct timeval timeout; #ifdef NDB_OSE - // Return directly if there are no TCP transporters configured - + if(timeOutMillis <= 1){ timeout.tv_sec = 0; timeout.tv_usec = 1025; @@ -758,7 +803,7 @@ TransporterRegistry::poll_TCP(Uint32 timeOutMillis){ timeout.tv_usec = (timeOutMillis % 1000) * 1000; #endif - NDB_SOCKET_TYPE maxSocketValue = 0; + NDB_SOCKET_TYPE maxSocketValue = -1; // Needed for TCP/IP connections // The read- and writeset are used by select @@ -786,23 +831,29 @@ TransporterRegistry::poll_TCP(Uint32 timeOutMillis){ maxSocketValue++; tcpReadSelectReply = select(maxSocketValue, &tcpReadset, 0, 0, &timeout); + if(false && tcpReadSelectReply == -1 && errno == EINTR) + ndbout_c("woke-up by signal"); + #ifdef NDB_WIN32 if(tcpReadSelectReply == SOCKET_ERROR) { NdbSleep_MilliSleep(timeOutMillis); } #endif - + return tcpReadSelectReply; } #endif void -TransporterRegistry::performReceive(){ +TransporterRegistry::performReceive() +{ #ifdef NDB_OSE_TRANSPORTER - if(theOSEReceiver != 0){ - while(theOSEReceiver->hasData()){ + if(theOSEReceiver != 0) + { + while(theOSEReceiver->hasData()) + { NodeId remoteNodeId; Uint32 * readPtr; Uint32 sz = theOSEReceiver->getReceiveData(&remoteNodeId, &readPtr); @@ -825,16 +876,20 @@ TransporterRegistry::performReceive(){ #endif #ifdef NDB_TCP_TRANSPORTER - if(tcpReadSelectReply > 0){ - for (int i=0; i<nTCPTransporters; i++) { + if(tcpReadSelectReply > 0) + { + for (int i=0; i<nTCPTransporters; i++) + { checkJobBuffer(); TCP_Transporter *t = theTCPTransporters[i]; const NodeId nodeId = t->getRemoteNodeId(); const NDB_SOCKET_TYPE socket = t->getSocket(); if(is_connected(nodeId)){ - if(t->isConnected() && FD_ISSET(socket, &tcpReadset)) { + if(t->isConnected() && FD_ISSET(socket, &tcpReadset)) + { const int receiveSize = t->doReceive(); - if(receiveSize > 0){ + if(receiveSize > 0) + { Uint32 * ptr; Uint32 sz = t->getReceiveData(&ptr); Uint32 szUsed = unpack(ptr, sz, nodeId, ioStates[nodeId]); @@ -845,142 +900,165 @@ TransporterRegistry::performReceive(){ } } #endif - - + #ifdef NDB_SCI_TRANSPORTER //performReceive //do prepareReceive on the SCI transporters (prepareReceive(t,,,,)) - for (int i=0; i<nSCITransporters; i++) { - checkJobBuffer(); - SCI_Transporter *t = theSCITransporters[i]; - const NodeId nodeId = t->getRemoteNodeId(); - if(is_connected(nodeId)){ - if(t->isConnected() && t->checkConnected()){ - Uint32 * readPtr, * eodPtr; - t->getReceivePtr(&readPtr, &eodPtr); - Uint32 *newPtr = unpack(readPtr, eodPtr, nodeId, ioStates[nodeId]); - t->updateReceivePtr(newPtr); - } - } - } + for (int i=0; i<nSCITransporters; i++) + { + checkJobBuffer(); + SCI_Transporter *t = theSCITransporters[i]; + const NodeId nodeId = t->getRemoteNodeId(); + if(is_connected(nodeId)) + { + if(t->isConnected() && t->checkConnected()) + { + Uint32 * readPtr, * eodPtr; + t->getReceivePtr(&readPtr, &eodPtr); + Uint32 *newPtr = unpack(readPtr, eodPtr, nodeId, ioStates[nodeId]); + t->updateReceivePtr(newPtr); + } + } + } #endif #ifdef NDB_SHM_TRANSPORTER - for (int i=0; i<nSHMTransporters; i++) { - checkJobBuffer(); - SHM_Transporter *t = theSHMTransporters[i]; - const NodeId nodeId = t->getRemoteNodeId(); - if(is_connected(nodeId)){ - if(t->isConnected() && t->checkConnected()){ - Uint32 * readPtr, * eodPtr; - t->getReceivePtr(&readPtr, &eodPtr); - Uint32 *newPtr = unpack(readPtr, eodPtr, nodeId, ioStates[nodeId]); - t->updateReceivePtr(newPtr); - } - } - } + for (int i=0; i<nSHMTransporters; i++) + { + checkJobBuffer(); + SHM_Transporter *t = theSHMTransporters[i]; + const NodeId nodeId = t->getRemoteNodeId(); + if(is_connected(nodeId)){ + if(t->isConnected() && t->checkConnected()) + { + Uint32 * readPtr, * eodPtr; + t->getReceivePtr(&readPtr, &eodPtr); + Uint32 *newPtr = unpack(readPtr, eodPtr, nodeId, ioStates[nodeId]); + t->updateReceivePtr(newPtr); + } + } + } #endif } static int x = 0; void -TransporterRegistry::performSend(){ - int i; - sendCounter = 1; - +TransporterRegistry::performSend() +{ + int i; + sendCounter = 1; + #ifdef NDB_OSE_TRANSPORTER - for (int i = 0; i < nOSETransporters; i++){ - OSE_Transporter *t = theOSETransporters[i]; - if((is_connected(t->getRemoteNodeId()) && - (t->isConnected())) { - t->doSend(); - }//if - }//for + for (int i = 0; i < nOSETransporters; i++) + { + OSE_Transporter *t = theOSETransporters[i]; + if(is_connected(t->getRemoteNodeId()) &&& (t->isConnected())) + { + t->doSend(); + }//if + }//for #endif - + #ifdef NDB_TCP_TRANSPORTER #ifdef NDB_OSE + { + int maxSocketValue = 0; + + // Needed for TCP/IP connections + // The writeset are used by select + fd_set writeset; + FD_ZERO(&writeset); + + // Prepare for sending and receiving + for (i = 0; i < nTCPTransporters; i++) { + TCP_Transporter * t = theTCPTransporters[i]; + + // If the transporter is connected + if ((t->hasDataToSend()) && (t->isConnected())) { + const int socket = t->getSocket(); + // Find the highest socket value. It will be used by select + if (socket > maxSocketValue) { + maxSocketValue = socket; + }//if + FD_SET(socket, &writeset); + }//if + }//for + + // The highest socket value plus one + if(maxSocketValue == 0) + return; + + maxSocketValue++; + struct timeval timeout = { 0, 1025 }; + Uint32 tmp = select(maxSocketValue, 0, &writeset, 0, &timeout); + + if (tmp == 0) { - int maxSocketValue = 0; - - // Needed for TCP/IP connections - // The writeset are used by select - fd_set writeset; - FD_ZERO(&writeset); - - // Prepare for sending and receiving - for (i = 0; i < nTCPTransporters; i++) { - TCP_Transporter * t = theTCPTransporters[i]; - - // If the transporter is connected - if ((t->hasDataToSend()) && (t->isConnected())) { - const int socket = t->getSocket(); - // Find the highest socket value. It will be used by select - if (socket > maxSocketValue) { - maxSocketValue = socket; - }//if - FD_SET(socket, &writeset); - }//if - }//for - - // The highest socket value plus one - if(maxSocketValue == 0) - return; - - maxSocketValue++; - struct timeval timeout = { 0, 1025 }; - Uint32 tmp = select(maxSocketValue, 0, &writeset, 0, &timeout); - - if (tmp == 0) { - return; - }//if - for (i = 0; i < nTCPTransporters; i++) { - TCP_Transporter *t = theTCPTransporters[i]; - const NodeId nodeId = t->getRemoteNodeId(); - const int socket = t->getSocket(); - if(is_connected(nodeId)){ - if(t->isConnected() && FD_ISSET(socket, &writeset)) { - t->doSend(); - }//if - }//if - }//for + return; + }//if + for (i = 0; i < nTCPTransporters; i++) { + TCP_Transporter *t = theTCPTransporters[i]; + const NodeId nodeId = t->getRemoteNodeId(); + const int socket = t->getSocket(); + if(is_connected(nodeId)){ + if(t->isConnected() && FD_ISSET(socket, &writeset)) { + t->doSend(); + }//if + }//if + }//for } #endif #ifdef NDB_TCP_TRANSPORTER - for (i = x; i < nTCPTransporters; i++) { - TCP_Transporter *t = theTCPTransporters[i]; - if (t && - (t->hasDataToSend()) && - (t->isConnected()) && - (is_connected(t->getRemoteNodeId()))) { - t->doSend(); - }//if - }//for - for (i = 0; i < x && i < nTCPTransporters; i++) { - TCP_Transporter *t = theTCPTransporters[i]; - if (t && - (t->hasDataToSend()) && - (t->isConnected()) && - (is_connected(t->getRemoteNodeId()))) { - t->doSend(); - }//if - }//for - x++; - if (x == nTCPTransporters) x = 0; + for (i = x; i < nTCPTransporters; i++) + { + TCP_Transporter *t = theTCPTransporters[i]; + if (t && t->hasDataToSend() && t->isConnected() && + is_connected(t->getRemoteNodeId())) + { + t->doSend(); + } + } + for (i = 0; i < x && i < nTCPTransporters; i++) + { + TCP_Transporter *t = theTCPTransporters[i]; + if (t && t->hasDataToSend() && t->isConnected() && + is_connected(t->getRemoteNodeId())) + { + t->doSend(); + } + } + x++; + if (x == nTCPTransporters) x = 0; #endif #endif #ifdef NDB_SCI_TRANSPORTER - //scroll through the SCI transporters, - // get each transporter, check if connected, send data - for (i=0; i<nSCITransporters; i++) { - SCI_Transporter *t = theSCITransporters[i]; - const NodeId nodeId = t->getRemoteNodeId(); - - if(is_connected(nodeId)){ - if(t->isConnected() && t->hasDataToSend()) { - t->doSend(); - } //if + //scroll through the SCI transporters, + // get each transporter, check if connected, send data + for (i=0; i<nSCITransporters; i++) { + SCI_Transporter *t = theSCITransporters[i]; + const NodeId nodeId = t->getRemoteNodeId(); + + if(is_connected(nodeId)) + { + if(t->isConnected() && t->hasDataToSend()) { + t->doSend(); } //if - } //if + } //if + } +#endif + +#ifdef NDB_SHM_TRANSPORTER + for (i=0; i<nSHMTransporters; i++) + { + SHM_Transporter *t = theSHMTransporters[i]; + const NodeId nodeId = t->getRemoteNodeId(); + if(is_connected(nodeId)) + { + if(t->isConnected()) + { + t->doSend(); + } + } + } #endif } @@ -1026,11 +1104,8 @@ TransporterRegistry::setIOState(NodeId nodeId, IOState state) { static void * run_start_clients_C(void * me) { - my_thread_init(); ((TransporterRegistry*) me)->start_clients_thread(); - my_thread_end(); - NdbThread_Exit(0); - return me; + return 0; } // Run by kernel thread @@ -1167,31 +1242,31 @@ TransporterRegistry::stop_clients() } void -TransporterRegistry::add_transporter_interface(const char *interface, unsigned short port) +TransporterRegistry::add_transporter_interface(const char *interf, unsigned short port) { DBUG_ENTER("TransporterRegistry::add_transporter_interface"); - DBUG_PRINT("enter",("interface=%s, port= %d", interface, port)); - if (interface && strlen(interface) == 0) - interface= 0; + DBUG_PRINT("enter",("interface=%s, port= %d", interf, port)); + if (interf && strlen(interf) == 0) + interf= 0; for (unsigned i= 0; i < m_transporter_interface.size(); i++) { Transporter_interface &tmp= m_transporter_interface[i]; if (port != tmp.m_service_port) continue; - if (interface != 0 && tmp.m_interface != 0 && - strcmp(interface, tmp.m_interface) == 0) + if (interf != 0 && tmp.m_interface != 0 && + strcmp(interf, tmp.m_interface) == 0) { DBUG_VOID_RETURN; // found match, no need to insert } - if (interface == 0 && tmp.m_interface == 0) + if (interf == 0 && tmp.m_interface == 0) { DBUG_VOID_RETURN; // found match, no need to insert } } Transporter_interface t; t.m_service_port= port; - t.m_interface= interface; + t.m_interface= interf; m_transporter_interface.push_back(t); DBUG_PRINT("exit",("interface and port added")); DBUG_VOID_RETURN; @@ -1200,7 +1275,7 @@ TransporterRegistry::add_transporter_interface(const char *interface, unsigned s bool TransporterRegistry::start_service(SocketServer& socket_server) { - if (m_transporter_interface.size() > 0 && nodeIdSpecified != true) + if (m_transporter_interface.size() > 0 && !nodeIdSpecified) { ndbout_c("TransporterRegistry::startReceiving: localNodeId not specified"); return false; @@ -1230,9 +1305,19 @@ TransporterRegistry::start_service(SocketServer& socket_server) return true; } +#ifdef NDB_SHM_TRANSPORTER +static +RETSIGTYPE +shm_sig_handler(int signo) +{ + g_shm_counter++; +} +#endif + void TransporterRegistry::startReceiving() { + DBUG_ENTER("TransporterRegistry::startReceiving"); #ifdef NDB_OSE_TRANSPORTER if(theOSEReceiver != NULL){ theOSEReceiver->createPhantom(); @@ -1248,6 +1333,37 @@ TransporterRegistry::startReceiving() for(int i = 0; i<nTCPTransporters; i++) theTCPTransporters[i]->theReceiverPid = theReceiverPid; #endif + +#ifdef NDB_SHM_TRANSPORTER + m_shm_own_pid = getpid(); + if (g_ndb_shm_signum) + { + DBUG_PRINT("info",("Install signal handler for signum %d", + g_ndb_shm_signum)); + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, g_ndb_shm_signum); + pthread_sigmask(SIG_UNBLOCK, &sa.sa_mask, 0); + sa.sa_handler = shm_sig_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + int ret; + while((ret = sigaction(g_ndb_shm_signum, &sa, 0)) == -1 && errno == EINTR); + if(ret != 0) + { + DBUG_PRINT("error",("Install failed")); + g_eventLogger.error("Failed to install signal handler for" + " SHM transporter errno: %d (%s)", errno, +#ifdef HAVE_STRERROR + strerror(errno) +#else + "" +#endif + ); + } + } +#endif // NDB_SHM_TRANSPORTER + DBUG_VOID_RETURN; } void diff --git a/ndb/src/common/util/File.cpp b/ndb/src/common/util/File.cpp index f3faa8c4f7f..937b8c0fa59 100644 --- a/ndb/src/common/util/File.cpp +++ b/ndb/src/common/util/File.cpp @@ -19,6 +19,7 @@ #include <File.hpp> #include <NdbOut.hpp> +#include <my_dir.h> // // PUBLIC @@ -28,9 +29,12 @@ bool File_class::exists(const char* aFileName) { bool rc = true; - +#ifdef USE_MY_STAT_STRUCT + struct my_stat stmp; +#else struct stat stmp; - if (::stat(aFileName, &stmp) != 0) +#endif + if (my_stat(aFileName, &stmp, MYF(0)) != 0) { rc = false; } diff --git a/ndb/src/common/util/Makefile.am b/ndb/src/common/util/Makefile.am index 0235adae7c9..a62c8186174 100644 --- a/ndb/src/common/util/Makefile.am +++ b/ndb/src/common/util/Makefile.am @@ -7,8 +7,8 @@ libgeneral_la_SOURCES = \ SocketServer.cpp SocketClient.cpp SocketAuthenticator.cpp\ OutputStream.cpp NdbOut.cpp BaseString.cpp Base64.cpp \ NdbSqlUtil.cpp new.cpp \ - uucode.c random.c getarg.c version.c \ - strdup.c strlcat.c strlcpy.c \ + uucode.c random.c version.c \ + strdup.c \ ConfigValues.cpp ndb_init.c basestring_vsnprintf.c include $(top_srcdir)/ndb/config/common.mk.am @@ -16,3 +16,17 @@ include $(top_srcdir)/ndb/config/type_util.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libgeneral.dsp + +libgeneral.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libgeneral_la_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/common/util/Makefile_old b/ndb/src/common/util/Makefile_old deleted file mode 100644 index 65093396246..00000000000 --- a/ndb/src/common/util/Makefile_old +++ /dev/null @@ -1,28 +0,0 @@ -include .defs.mk - -TYPE := util - -PIC_ARCHIVE := Y -ARCHIVE_TARGET := general - -SOURCES = File.cpp md5_hash.cpp Properties.cpp socket_io.cpp \ - SimpleProperties.cpp Parser.cpp InputStream.cpp SocketServer.cpp \ - OutputStream.cpp NdbOut.cpp BaseString.cpp Base64.cpp \ - NdbSqlUtil.cpp ConfigValues.cpp new.cpp - -SOURCES.c = uucode.c random.c getarg.c version.c - -ifeq ($(NDB_OS), OSE) - SOURCES += NdbErrHnd.cpp -endif -ifeq ($(NDB_OS), OSE) - SOURCES += NdbErrHnd.cpp -endif - SOURCES.c += strdup.c strlcat.c strlcpy.c - -DIRS := testSimpleProperties testProperties testConfigValues - -include $(NDB_TOP)/Epilogue.mk - -testNdbSqlUtil: NdbSqlUtil.cpp - $(CC) -o $@ NdbSqlUtil.cpp $(CCFLAGS) -DNDB_SQL_UTIL_TEST -L$(NDB_TOP)/lib -lportlib -lgeneral diff --git a/ndb/src/common/util/NdbOut.cpp b/ndb/src/common/util/NdbOut.cpp index fa74cb364f3..e20119a7987 100644 --- a/ndb/src/common/util/NdbOut.cpp +++ b/ndb/src/common/util/NdbOut.cpp @@ -54,7 +54,7 @@ NdbOut& NdbOut::operator<<(unsigned long int v) { return *this << (Uint64) v; } NdbOut& -NdbOut::operator<<(const char* val){ m_out->print("%s", val); return * this; } +NdbOut::operator<<(const char* val){ m_out->print("%s", val ? val : "(null)"); return * this; } NdbOut& NdbOut::operator<<(const void* val){ m_out->print("%p", val); return * this; } NdbOut& diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 6e4e5919e43..c4114ad5ffa 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -76,93 +76,121 @@ NdbSqlUtil::char_like(const char* s1, unsigned n1, const NdbSqlUtil::Type NdbSqlUtil::m_typeList[] = { - { + { // 0 Type::Undefined, NULL }, - { + { // 1 Type::Tinyint, cmpTinyint }, - { + { // 2 Type::Tinyunsigned, cmpTinyunsigned }, - { + { // 3 Type::Smallint, cmpSmallint }, - { + { // 4 Type::Smallunsigned, cmpSmallunsigned }, - { + { // 5 Type::Mediumint, cmpMediumint }, - { + { // 6 Type::Mediumunsigned, cmpMediumunsigned }, - { + { // 7 Type::Int, cmpInt }, - { + { // 8 Type::Unsigned, cmpUnsigned }, - { + { // 9 Type::Bigint, cmpBigint }, - { + { // 10 Type::Bigunsigned, cmpBigunsigned }, - { + { // 11 Type::Float, cmpFloat }, - { + { // 12 Type::Double, cmpDouble }, - { - Type::Decimal, - NULL // cmpDecimal + { // 13 + Type::Olddecimal, + cmpOlddecimal }, - { + { // 14 Type::Char, cmpChar }, - { + { // 15 Type::Varchar, cmpVarchar }, - { + { // 16 Type::Binary, cmpBinary }, - { + { // 17 Type::Varbinary, cmpVarbinary }, - { + { // 18 Type::Datetime, cmpDatetime }, - { - Type::Timespec, - cmpTimespec + { // 19 + Type::Date, + cmpDate }, - { + { // 20 Type::Blob, cmpBlob }, - { + { // 21 Type::Text, cmpText + }, + { // 22 + Type::Undefined, // 5.0 Bit + NULL + }, + { // 23 + Type::Undefined, // 5.0 Longvarchar + NULL + }, + { // 24 + Type::Undefined, // 5.0 Longvarbinary + NULL + }, + { // 25 + Type::Time, + cmpTime + }, + { // 26 + Type::Year, + cmpYear + }, + { // 27 + Type::Timestamp, + cmpTimestamp + }, + { // 28 + Type::Olddecimalunsigned, + cmpOlddecimalunsigned } }; @@ -387,15 +415,57 @@ NdbSqlUtil::cmpDouble(const void* info, const Uint32* p1, const Uint32* p2, Uint } int -NdbSqlUtil::cmpDecimal(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +NdbSqlUtil::cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n) { - assert(full >= size && size > 0); - // not used by MySQL or NDB - assert(false); + int sgn = +1; + unsigned i = 0; + while (i < n) { + int c1 = s1[i]; + int c2 = s2[i]; + if (c1 == c2) { + if (c1 == '-') + sgn = -1; + } else if (c1 == '-') { + return -1; + } else if (c2 == '-') { + return +1; + } else if (c1 < c2) { + return -1 * sgn; + } else { + return +1 * sgn; + } + i++; + } return 0; } int +NdbSqlUtil::cmpOlddecimal(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + if (full == size) { + union { const Uint32* p; const uchar* v; } u1, u2; + u1.p = p1; + u2.p = p2; + return cmp_olddecimal(u1.v, u2.v, full << 2); + } + return CmpUnknown; +} + +int +NdbSqlUtil::cmpOlddecimalunsigned(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + if (full == size) { + union { const Uint32* p; const uchar* v; } u1, u2; + u1.p = p1; + u2.p = p2; + return cmp_olddecimal(u1.v, u2.v, full << 2); + } + return CmpUnknown; +} + +int NdbSqlUtil::cmpChar(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) { // collation does not work on prefix for some charsets @@ -469,56 +539,78 @@ int NdbSqlUtil::cmpDatetime(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) { assert(full >= size && size > 0); - /* - * Datetime is CC YY MM DD hh mm ss \0 - * - * Not used via MySQL. - */ - union { const Uint32* p; const unsigned char* v; } u1, u2; - u1.p = p1; - u2.p = p2; - // no format check - int k = memcmp(u1.v, u2.v, 4); - if (k != 0) - return k < 0 ? -1 : +1; if (size >= 2) { - k = memcmp(u1.v + 4, u2.v + 4, 4); - return k < 0 ? -1 : k > 0 ? +1 : 0; + union { Uint32 p[2]; Int64 v; } u1, u2; + u1.p[0] = p1[0]; + u1.p[1] = p1[1]; + u2.p[0] = p2[0]; + u2.p[1] = p2[1]; + if (u1.v < u2.v) + return -1; + if (u1.v > u2.v) + return +1; + return 0; } return CmpUnknown; } int -NdbSqlUtil::cmpTimespec(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +NdbSqlUtil::cmpDate(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) { +#ifdef ndb_date_is_4_byte_native_int + assert(full >= size && size > 0); + union { Uint32 p[2]; Int32 v; } u1, u2; + u1.p[0] = p1[0]; + u2.p[0] = p2[0]; + if (u1.v < u2.v) + return -1; + if (u1.v > u2.v) + return +1; + return 0; +#else assert(full >= size && size > 0); - /* - * Timespec is CC YY MM DD hh mm ss \0 NN NN NN NN - * - * Not used via MySQL. - */ union { const Uint32* p; const unsigned char* v; } u1, u2; u1.p = p1; u2.p = p2; - // no format check - int k = memcmp(u1.v, u2.v, 4); - if (k != 0) - return k < 0 ? -1 : +1; - if (size >= 2) { - k = memcmp(u1.v + 4, u2.v + 4, 4); - if (k != 0) - return k < 0 ? -1 : +1; - if (size >= 3) { - Uint32 n1 = *(const Uint32*)(u1.v + 8); - Uint32 n2 = *(const Uint32*)(u2.v + 8); - if (n1 < n2) - return -1; - if (n2 > n1) - return +1; - return 0; - } - } - return CmpUnknown; +#ifdef ndb_date_sol9x86_cc_xO3_madness + // from Field_newdate::val_int + Uint64 j1 = uint3korr(u1.v); + Uint64 j2 = uint3korr(u2.v); + j1 = (j1 % 32L)+(j1 / 32L % 16L)*100L + (j1/(16L*32L))*10000L; + j2 = (j2 % 32L)+(j2 / 32L % 16L)*100L + (j2/(16L*32L))*10000L; + if (j1 < j2) + return -1; + if (j1 > j2) + return +1; + return 0; +#else + uint j1 = uint3korr(u1.v); + uint j2 = uint3korr(u2.v); + uint d1 = (j1 & 31); + uint d2 = (j2 & 31); + j1 = (j1 >> 5); + j2 = (j2 >> 5); + uint m1 = (j1 & 15); + uint m2 = (j2 & 15); + j1 = (j1 >> 4); + j2 = (j2 >> 4); + uint y1 = j1; + uint y2 = j2; + if (y1 < y2) + return -1; + if (y1 > y2) + return +1; + if (m1 < m2) + return -1; + if (m1 > m2) + return +1; + if (d1 < d2) + return -1; + if (d1 > d2) + return +1; + return 0; +#endif +#endif } int @@ -565,6 +657,51 @@ NdbSqlUtil::cmpText(const void* info, const Uint32* p1, const Uint32* p2, Uint32 return CmpUnknown; } +int +NdbSqlUtil::cmpTime(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + union { const Uint32* p; const unsigned char* v; } u1, u2; + u1.p = p1; + u2.p = p2; + // from Field_time::val_int + Int32 j1 = sint3korr(u1.v); + Int32 j2 = sint3korr(u2.v); + if (j1 < j2) + return -1; + if (j1 > j2) + return +1; + return 0; +} + +int +NdbSqlUtil::cmpYear(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + union { const Uint32* p; const unsigned char* v; } u1, u2; + u1.p = p1; + u2.p = p2; + if (u1.v[0] < u2.v[0]) + return -1; + if (u1.v[0] > u2.v[0]) + return +1; + return 0; +} + +int +NdbSqlUtil::cmpTimestamp(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + union { Uint32 p[1]; Uint32 v; } u1, u2; + u1.v = p1[0]; + u2.v = p2[0]; + if (u1.v < u2.v) + return -1; + if (u1.v > u2.v) + return +1; + return 0; +} + // check charset bool @@ -582,7 +719,7 @@ NdbSqlUtil::usable_in_pk(Uint32 typeId, const void* info) cs->cset != 0 && cs->coll != 0 && cs->coll->strnxfrm != 0 && - cs->strxfrm_multiply == 1; // current limitation + cs->strxfrm_multiply <= 1; // current limitation } break; case Type::Varchar: @@ -618,7 +755,7 @@ NdbSqlUtil::usable_in_ordered_index(Uint32 typeId, const void* info) cs->coll != 0 && cs->coll->strnxfrm != 0 && cs->coll->strnncollsp != 0 && - cs->strxfrm_multiply == 1; // current limitation + cs->strxfrm_multiply <= 1; // current limitation } break; case Type::Varchar: @@ -633,7 +770,7 @@ NdbSqlUtil::usable_in_ordered_index(Uint32 typeId, const void* info) cs->coll != 0 && cs->coll->strnxfrm != 0 && cs->coll->strnncollsp != 0 && - cs->strxfrm_multiply == 1; // current limitation + cs->strxfrm_multiply <= 1; // current limitation } break; default: diff --git a/ndb/src/common/util/Properties.cpp b/ndb/src/common/util/Properties.cpp index 4443fd45bba..0edcda0e726 100644 --- a/ndb/src/common/util/Properties.cpp +++ b/ndb/src/common/util/Properties.cpp @@ -881,7 +881,7 @@ PropertiesImpl::unpack(const Uint32 * buf, Uint32 &bufLen, Properties * top, case PropertiesType_Properties: assert(0); } - if(res3 != true){ + if(!res3){ return false; } _items--; diff --git a/ndb/src/common/util/SocketClient.cpp b/ndb/src/common/util/SocketClient.cpp index 50e60956b94..38df1417eb8 100644 --- a/ndb/src/common/util/SocketClient.cpp +++ b/ndb/src/common/util/SocketClient.cpp @@ -26,14 +26,14 @@ SocketClient::SocketClient(const char *server_name, unsigned short port, SocketA m_auth= sa; m_port= port; m_server_name= strdup(server_name); - m_sockfd= -1; + m_sockfd= NDB_INVALID_SOCKET; } SocketClient::~SocketClient() { if (m_server_name) free(m_server_name); - if (m_sockfd >= 0) + if (m_sockfd != NDB_INVALID_SOCKET) NDB_CLOSE_SOCKET(m_sockfd); if (m_auth) delete m_auth; @@ -42,7 +42,7 @@ SocketClient::~SocketClient() bool SocketClient::init() { - if (m_sockfd >= 0) + if (m_sockfd != NDB_INVALID_SOCKET) NDB_CLOSE_SOCKET(m_sockfd); memset(&m_servaddr, 0, sizeof(m_servaddr)); @@ -63,32 +63,32 @@ SocketClient::init() NDB_SOCKET_TYPE SocketClient::connect() { - if (m_sockfd < 0) + if (m_sockfd == NDB_INVALID_SOCKET) { if (!init()) { #ifdef VM_TRACE ndbout << "SocketClient::connect() failed " << m_server_name << " " << m_port << endl; #endif - return -1; + return NDB_INVALID_SOCKET; } } const int r = ::connect(m_sockfd, (struct sockaddr*) &m_servaddr, sizeof(m_servaddr)); if (r == -1) { NDB_CLOSE_SOCKET(m_sockfd); - m_sockfd= -1; - return -1; + m_sockfd= NDB_INVALID_SOCKET; + return NDB_INVALID_SOCKET; } if (m_auth) { if (!m_auth->client_authenticate(m_sockfd)) { NDB_CLOSE_SOCKET(m_sockfd); - m_sockfd= -1; - return -1; + m_sockfd= NDB_INVALID_SOCKET; + return NDB_INVALID_SOCKET; } } NDB_SOCKET_TYPE sockfd= m_sockfd; - m_sockfd= -1; + m_sockfd= NDB_INVALID_SOCKET; return sockfd; } diff --git a/ndb/src/common/util/SocketServer.cpp b/ndb/src/common/util/SocketServer.cpp index c3cffa1399b..da06389b5df 100644 --- a/ndb/src/common/util/SocketServer.cpp +++ b/ndb/src/common/util/SocketServer.cpp @@ -186,11 +186,7 @@ extern "C" void* socketServerThread_C(void* _ss){ SocketServer * ss = (SocketServer *)_ss; - - my_thread_init(); ss->doRun(); - my_thread_end(); - NdbThread_Exit(0); return 0; } @@ -259,6 +255,15 @@ transfer(NDB_SOCKET_TYPE sock){ } void +SocketServer::foreachSession(void (*func)(SocketServer::Session*, void *), void *data) +{ + for(int i = m_sessions.size() - 1; i >= 0; i--){ + (*func)(m_sessions[i].m_session, data); + } + checkSessions(); +} + +void SocketServer::checkSessions(){ for(int i = m_sessions.size() - 1; i >= 0; i--){ if(m_sessions[i].m_session->m_stopped){ @@ -278,8 +283,10 @@ void SocketServer::stopSessions(bool wait){ int i; for(i = m_sessions.size() - 1; i>=0; i--) - m_sessions[i].m_session->m_stop = true; - + { + m_sessions[i].m_session->stopSession(); + m_sessions[i].m_session->m_stop = true; // to make sure + } for(i = m_services.size() - 1; i>=0; i--) m_services[i].m_service->stopSessions(); @@ -298,11 +305,8 @@ void* sessionThread_C(void* _sc){ SocketServer::Session * si = (SocketServer::Session *)_sc; - my_thread_init(); if(!transfer(si->m_socket)){ si->m_stopped = true; - my_thread_end(); - NdbThread_Exit(0); return 0; } @@ -314,8 +318,6 @@ sessionThread_C(void* _sc){ } si->m_stopped = true; - my_thread_end(); - NdbThread_Exit(0); return 0; } diff --git a/ndb/src/common/util/basestring_vsnprintf.c b/ndb/src/common/util/basestring_vsnprintf.c index 10932226d18..58203e33bd1 100644 --- a/ndb/src/common/util/basestring_vsnprintf.c +++ b/ndb/src/common/util/basestring_vsnprintf.c @@ -18,6 +18,13 @@ #define _XOPEN_SOURCE 500 #include <stdio.h> #include <basestring_vsnprintf.h> +#include <my_config.h> + +#ifdef _WINDOWS +#define SNPRINTF_RETURN_TRUNC +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#endif int basestring_snprintf(char *str, size_t size, const char *format, ...) @@ -30,8 +37,33 @@ basestring_snprintf(char *str, size_t size, const char *format, ...) return(ret); } +#ifdef SNPRINTF_RETURN_TRUNC +static char basestring_vsnprintf_buf[16*1024]; +#endif int basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap) { - return(vsnprintf(str, size, format, ap)); + if (size == 0) + { +#ifdef SNPRINTF_RETURN_TRUNC + return vsnprintf(basestring_vsnprintf_buf, + sizeof(basestring_vsnprintf_buf), + format, ap); +#else + char buf[1]; + return vsnprintf(buf, 1, format, ap); +#endif + } + { + int ret= vsnprintf(str, size, format, ap); +#ifdef SNPRINTF_RETURN_TRUNC + if (ret == size-1 || ret == -1) + { + ret= vsnprintf(basestring_vsnprintf_buf, + sizeof(basestring_vsnprintf_buf), + format, ap); + } +#endif + return ret; + } } diff --git a/ndb/src/common/util/getarg.3 b/ndb/src/common/util/getarg.3 deleted file mode 100644 index 43aae5d7b31..00000000000 --- a/ndb/src/common/util/getarg.3 +++ /dev/null @@ -1,315 +0,0 @@ -.\" Copyright (c) 1999 Kungliga Tekniska Högskolan -.\" $KTH: getarg.3,v 1.1.4.1 2001/07/26 19:54:45 lha Exp $ -.Dd September 24, 1999 -.Dt GETARG 3 -.Os ROKEN -.Sh NAME -.Nm getarg , -.Nm arg_printusage -.Nd collect command line options -.Sh SYNOPSIS -.Fd #include <getarg.h> - -.Ft int -.Fn getarg "struct getargs *args" "size_t num_args" "int argc" "char **argv" "int *optind" - -.Ft void -.Fn arg_printusage "struct getargs *args" "size_t num_args" "const char *progname" "const char *extra_string" - -.Sh DESCRIPTION -.Fn getarg -collects any command line options given to a program in an easily used way. -.Fn arg_printusage -pretty-prints the available options, with a short help text. -.Pp -.Fa args -is the option specification to use, and it's an array of -.Fa struct getargs -elements. -.Fa num_args -is the size of -.Fa args -(in elements). -.Fa argc -and -.Fa argv -are the argument count and argument vector to extract option from. -.Fa optind -is a pointer to an integer where the index to the last processed -argument is stored, it must be initialised to the first index (minus -one) to process (normally 0) before the first call. -.Pp -.Fa arg_printusage -take the same -.Fa args -and -.Fa num_args -as getarg; -.Fa progname is the name of the program (to be used in the help text), and -.Fa extra_string -is a string to print after the actual options to indicate more -arguments. The usefulness of this function is realised only be people -who has used programs that has help strings that doesn't match what -the code does. -.Pp -The -.Fa getargs -struct has the following elements. - -.Bd -literal -struct getargs{ - const char *long_name; - char short_name; - enum { arg_integer, - arg_string, - arg_flag, - arg_negative_flag, - arg_strings, - arg_double, - arg_collect - } type; - void *value; - const char *help; - const char *arg_help; -}; -.Ed -.Pp -.Fa long_name -is the long name of the option, it can be -.Dv NULL , -if you don't want a long name. -.Fa short_name -is the characted to use as short option, it can be zero. If the option -has a value the -.Fa value -field gets filled in with that value interpreted as specified by the -.Fa type -field. -.Fa help -is a longer help string for the option as a whole, if it's -.Dv NULL -the help text for the option is omitted (but it's still displayed in -the synopsis). -.Fa arg_help -is a description of the argument, if -.Dv NULL -a default value will be used, depending on the type of the option: -.Pp -.Bl -hang -width arg_negative_flag -.It arg_integer -the argument is a signed integer, and -.Fa value -should point to an -.Fa int . -.It Fa arg_string -the argument is a string, and -.Fa value -should point to a -.Fa char* . -.It Fa arg_flag -the argument is a flag, and -.Fa value -should point to a -.Fa int . -It gets filled in with either zero or one, depending on how the option -is given, the normal case beeing one. Note that if the option isn't -given, the value isn't altered, so it should be initialised to some -useful default. -.It Fa arg_negative_flag -this is the same as -.Fa arg_flag -but it reverses the meaning of the flag (a given short option clears -the flag), and the synopsis of a long option is negated. -.It Fa arg_strings -the argument can be given multiple times, and the values are collected -in an array; -.Fa value -should be a pointer to a -.Fa struct getarg_strings -structure, which holds a length and a string pointer. -.It Fa arg_double -argument is a double precision floating point value, and -.Fa value -should point to a -.Fa double . -.It Fa arg_collect -allows more fine-grained control of the option parsing process. -.Fa value -should be a pointer to a -.Fa getarg_collect_info -structure: -.Bd -literal -typedef int (*getarg_collect_func)(int short_opt, - int argc, - char **argv, - int *optind, - int *optarg, - void *data); - -typedef struct getarg_collect_info { - getarg_collect_func func; - void *data; -} getarg_collect_info; -.Ed -.Pp -With the -.Fa func -member set to a function to call, and -.Fa data -to some application specific data. The parameters to the collect function are: -.Bl -inset -.It Fa short_flag -non-zero if this call is via a short option flag, zero otherwise -.It Fa argc , argv -the whole argument list -.It Fa optind -pointer to the index in argv where the flag is -.It Fa optarg -pointer to the index in argv[*optind] where the flag name starts -.It Fa data -application specific data -.El -.Pp -You can modify -.Fa *optind , -and -.Fa *optarg , -but to do this correct you (more or less) have to know about the inner -workings of getarg. - -You can skip parts of arguments by increasing -.Fa *optarg -(you could -implement the -.Fl z Ns Ar 3 -set of flags from -.Nm gzip -with this), or whole argument strings by increasing -.Fa *optind -(let's say you want a flag -.Fl c Ar x y z -to specify a coordinate); if you also have to set -.Fa *optarg -to a sane value. -.Pp -The collect function should return one of -.Dv ARG_ERR_NO_MATCH , ARG_ERR_BAD_ARG , ARG_ERR_NO_ARG -on error, zero otherwise. -.Pp -For your convenience there is a function, -.Fn getarg_optarg , -that returns the traditional argument string, and you pass it all -arguments, sans data, that where given to the collection function. -.Pp -Don't use this more this unless you absolutely have to. -.El -.Pp -Option parsing is similar to what -.Xr getopt -uses. Short options without arguments can be compressed -.Pf ( Fl xyz -is the same as -.Fl x y z ) , -and short -options with arguments take these as either the rest of the -argv-string or as the next option -.Pf ( Fl o Ns Ar foo , -or -.Fl o Ar foo ) . -.Pp -Long option names are prefixed with -- (double dash), and the value -with a = (equal), -.Fl -foo= Ns Ar bar . -Long option flags can either be specified as they are -.Pf ( Fl -help ) , -or with an (boolean parsable) option -.Pf ( Fl -help= Ns Ar yes , -.Fl -help= Ns Ar true , -or similar), or they can also be negated -.Pf ( Fl -no-help -is the same as -.Fl -help= Ns no ) , -and if you're really confused you can do it multiple times -.Pf ( Fl -no-no-help= Ns Ar false , -or even -.Fl -no-no-help= Ns Ar maybe ) . -.Sh EXAMPLE -.Bd -literal -#include <stdio.h> -#include <string.h> -#include <getarg.h> - -char *source = "Ouagadougou"; -char *destination; -int weight; -int include_catalog = 1; -int help_flag; - -struct getargs args[] = { - { "source", 's', arg_string, &source, - "source of shippment", "city" }, - { "destination", 'd', arg_string, &destination, - "destination of shippment", "city" }, - { "weight", 'w', arg_integer, &weight, - "weight of shippment", "tons" }, - { "catalog", 'c', arg_negative_flag, &include_catalog, - "include product catalog" }, - { "help", 'h', arg_flag, &help_flag } -}; - -int num_args = sizeof(args) / sizeof(args[0]); /* number of elements in args */ - -const char *progname = "ship++"; - -int -main(int argc, char **argv) -{ - int optind = 0; - if (getarg(args, num_args, argc, argv, &optind)) { - arg_printusage(args, num_args, progname, "stuff..."); - exit (1); - } - if (help_flag) { - arg_printusage(args, num_args, progname, "stuff..."); - exit (0); - } - if (destination == NULL) { - fprintf(stderr, "%s: must specify destination\n", progname); - exit(1); - } - if (strcmp(source, destination) == 0) { - fprintf(stderr, "%s: destination must be different from source\n"); - exit(1); - } - /* include more stuff here ... */ - exit(2); -} -.Ed -.Pp -The output help output from this program looks like this: -.Bd -literal -$ ship++ --help -Usage: ship++ [--source=city] [-s city] [--destination=city] [-d city] - [--weight=tons] [-w tons] [--no-catalog] [-c] [--help] [-h] stuff... --s city, --source=city source of shippment --d city, --destination=city destination of shippment --w tons, --weight=tons weight of shippment --c, --no-catalog include product catalog -.Ed - -.Sh BUGS -It should be more flexible, so it would be possible to use other more -complicated option syntaxes, such as what -.Xr ps 1 , -and -.Xr tar 1 , -uses, or the AFS model where you can skip the flag names as long as -the options come in the correct order. -.Pp -Options with multiple arguments should be handled better. -.Pp -Should be integreated with SL. -.Pp -It's very confusing that the struct you pass in is called getargS. -.Sh SEE ALSO -.Xr getopt 3 diff --git a/ndb/src/common/util/getarg.3.ps b/ndb/src/common/util/getarg.3.ps deleted file mode 100644 index 146fb8e4961..00000000000 --- a/ndb/src/common/util/getarg.3.ps +++ /dev/null @@ -1,458 +0,0 @@ -%!PS-Adobe-3.0 -%%Creator: groff version 1.15 -%%CreationDate: Thu Nov 7 12:53:13 2002 -%%DocumentNeededResources: font Times-Roman -%%+ font Times-Bold -%%+ font Courier-Bold -%%+ font Courier-Oblique -%%+ font Symbol -%%+ font Courier -%%DocumentSuppliedResources: procset grops 1.15 0 -%%Pages: 4 -%%PageOrder: Ascend -%%Orientation: Portrait -%%EndComments -%%BeginProlog -%%BeginResource: procset grops 1.15 0 -/setpacking where{ -pop -currentpacking -true setpacking -}if -/grops 120 dict dup begin -/SC 32 def -/A/show load def -/B{0 SC 3 -1 roll widthshow}bind def -/C{0 exch ashow}bind def -/D{0 exch 0 SC 5 2 roll awidthshow}bind def -/E{0 rmoveto show}bind def -/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def -/G{0 rmoveto 0 exch ashow}bind def -/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/I{0 exch rmoveto show}bind def -/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def -/K{0 exch rmoveto 0 exch ashow}bind def -/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/M{rmoveto show}bind def -/N{rmoveto 0 SC 3 -1 roll widthshow}bind def -/O{rmoveto 0 exch ashow}bind def -/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/Q{moveto show}bind def -/R{moveto 0 SC 3 -1 roll widthshow}bind def -/S{moveto 0 exch ashow}bind def -/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def -/SF{ -findfont exch -[exch dup 0 exch 0 exch neg 0 0]makefont -dup setfont -[exch/setfont cvx]cvx bind def -}bind def -/MF{ -findfont -[5 2 roll -0 3 1 roll -neg 0 0]makefont -dup setfont -[exch/setfont cvx]cvx bind def -}bind def -/level0 0 def -/RES 0 def -/PL 0 def -/LS 0 def -/MANUAL{ -statusdict begin/manualfeed true store end -}bind def -/PLG{ -gsave newpath clippath pathbbox grestore -exch pop add exch pop -}bind def -/BP{ -/level0 save def -1 setlinecap -1 setlinejoin -72 RES div dup scale -LS{ -90 rotate -}{ -0 PL translate -}ifelse -1 -1 scale -}bind def -/EP{ -level0 restore -showpage -}bind def -/DA{ -newpath arcn stroke -}bind def -/SN{ -transform -.25 sub exch .25 sub exch -round .25 add exch round .25 add exch -itransform -}bind def -/DL{ -SN -moveto -SN -lineto stroke -}bind def -/DC{ -newpath 0 360 arc closepath -}bind def -/TM matrix def -/DE{ -TM currentmatrix pop -translate scale newpath 0 0 .5 0 360 arc closepath -TM setmatrix -}bind def -/RC/rcurveto load def -/RL/rlineto load def -/ST/stroke load def -/MT/moveto load def -/CL/closepath load def -/FL{ -currentgray exch setgray fill setgray -}bind def -/BL/fill load def -/LW/setlinewidth load def -/RE{ -findfont -dup maxlength 1 index/FontName known not{1 add}if dict begin -{ -1 index/FID ne{def}{pop pop}ifelse -}forall -/Encoding exch def -dup/FontName exch def -currentdict end definefont pop -}bind def -/DEFS 0 def -/EBEGIN{ -moveto -DEFS begin -}bind def -/EEND/end load def -/CNT 0 def -/level1 0 def -/PBEGIN{ -/level1 save def -translate -div 3 1 roll div exch scale -neg exch neg exch translate -0 setgray -0 setlinecap -1 setlinewidth -0 setlinejoin -10 setmiterlimit -[]0 setdash -/setstrokeadjust where{ -pop -false setstrokeadjust -}if -/setoverprint where{ -pop -false setoverprint -}if -newpath -/CNT countdictstack def -userdict begin -/showpage{}def -}bind def -/PEND{ -clear -countdictstack CNT sub{end}repeat -level1 restore -}bind def -end def -/setpacking where{ -pop -setpacking -}if -%%EndResource -%%IncludeResource: font Times-Roman -%%IncludeResource: font Times-Bold -%%IncludeResource: font Courier-Bold -%%IncludeResource: font Courier-Oblique -%%IncludeResource: font Symbol -%%IncludeResource: font Courier -grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 -def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron -/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef -/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef -/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef -/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent -/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen -/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon -/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O -/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex -/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y -/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft -/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl -/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut -/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash -/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen -/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft -/logicalnot/minus/registered/macron/degree/plusminus/twosuperior -/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior -/ordmasculine/guilsinglright/onequarter/onehalf/threequarters -/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE -/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex -/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis -/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn -/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla -/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis -/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash -/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def -/Courier@0 ENC0/Courier RE/Courier-Oblique@0 ENC0/Courier-Oblique RE -/Courier-Bold@0 ENC0/Courier-Bold RE/Times-Bold@0 ENC0/Times-Bold RE -/Times-Roman@0 ENC0/Times-Roman RE -%%EndProlog -%%Page: 1 1 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F/F1 10/Times-Bold@0 SF -.2(NA)72 108 S(ME).2 E -/F2 10/Courier-Bold@0 SF(getarg)102 120 Q F0(,)A F2(arg_printusage)2.5 E -F0 2.5<ad63>2.5 G(ollect command line options)-2.5 E F1(SYNOPSIS)72 144 -Q F2(#include <getarg.h>)102 156 Q/F3 10/Courier-Oblique@0 SF(int)102 -186 Q F2(getarg)102 198 Q F0(\()A F3(struct getargs)A/F4 10/Symbol SF(*) -6 E F3(args)A F0(,)1.666 E F3(size_t num_args)4.166 E F0(,)1.666 E F3 -(int argc)4.166 E F0(,)1.666 E F3(char)4.166 E F4(**)6 E F3(argv)A F0(,) -1.666 E F3(int)151.666 210 Q F4(*)6 E F3(optind)A F0(\);)A F3(void)102 -240 Q F2(arg_printusage)102 252 Q F0(\()A F3(struct getargs)A F4(*)6 E -F3(args)A F0(,)1.666 E F3(size_t num_args)4.166 E F0(,)1.666 E F3 -(const char)4.166 E F4(*)6 E F3(progname)A F0(,)1.666 E F3(const char) -151.666 264 Q F4(*)6 E F3(extra_string)A F0(\);)A F1(DESCRIPTION)72 300 -Q F2(getarg)102 312 Q F0 2.721 1.666(\(\) c)D 6.053(ollects an)-1.666 F -8.553(yc)-.15 G 6.053(ommand line options gi)-8.553 F -.15(ve)-.25 G -8.552(nt).15 G 8.552(oap)-8.552 G 6.052(rogram in an easily used w) --8.552 F(ay)-.1 E(.)-.65 E F2(arg_printusage)102 324 Q F0 -3.332 1.666 -(\(\) p)D(retty-prints the a)-1.666 E -.25(va)-.2 G -(ilable options, with a short help te).25 E(xt.)-.15 E F3(args)102 342 Q -F0 .855(is the option speci\214cation to use, and it')3.355 F 3.356(sa) --.55 G 3.356(na)-3.356 G .856(rray of)-3.356 F F3 .856(struct getargs) -3.356 F F0(elements.)3.356 E F3(num_args)5.856 E F0(is)3.356 E .344 -(the size of)102 354 R F3(args)2.844 E F0 .344(\(in elements\).)2.844 F -F3(argc)5.344 E F0(and)2.844 E F3(argv)2.844 E F0 .344(are the ar)2.844 -F .344(gument count and ar)-.18 F .344(gument v)-.18 F .344(ector to e) --.15 F .343(xtract op-)-.15 F 1.127(tion from.)102 366 R F3(optind)6.127 -E F0 1.127(is a pointer to an inte)3.627 F 1.127(ger where the inde)-.15 -F 3.627(xt)-.15 G 3.628(ot)-3.627 G 1.128(he last processed ar)-3.628 F -1.128(gument is stored, it)-.18 F -(must be initialised to the \214rst inde)102 378 Q 2.5(x\()-.15 G -(minus one\) to process \(normally 0\) before the \214rst call.)-2.5 E -F3(arg_printusage)102 396 Q F0(tak)4.178 E 4.178(et)-.1 G 1.678(he same) --4.178 F F3(args)4.178 E F0(and)4.178 E F3(num_args)4.178 E F0 1.678 -(as getar)4.178 F(g;)-.18 E F3 1.677(progname is the name of)4.178 F -6.381(the program \(to be)102 408 R F0(progname0)12.381 E F3(0)12.381 E -F0(progname1)A F3(1)12.381 E F0(progname2)A F3(2)12.382 E F0(progname3)A -F3(3)12.382 E F0(progname4)A F3(4)102 420 Q F0(progname5)A F3 -(extra_string)3.404 E F0 .904 -(is a string to print after the actual options to indicate more ar)3.404 -F .904(guments. The)-.18 F .025(usefulness of this function is realised\ - only be people who has used programs that has help strings that doesn') -102 432 R(t)-.18 E(match what the code does.)102 444 Q(The)102 462 Q F3 -(getargs)2.5 E F0(struct has the follo)2.5 E(wing elements.)-.25 E/F5 10 -/Courier@0 SF(struct getargs{)102 504 Q(const char)126 516 Q F4(*)6 E F5 -(long_name;)A(char short_name;)126 528 Q(enum { arg_integer,)126 540 Q -(arg_string,)165 552 Q(arg_flag,)165 564 Q(arg_negative_flag,)165 576 Q -(arg_strings,)165 588 Q(arg_double,)165 600 Q(arg_collect)168 612 Q 6 -(}t)126 624 S(ype;)-6 E(void)126 636 Q F4(*)6 E F5(value;)A(const char) -126 648 Q F4(*)6 E F5(help;)A(const char)126 660 Q F4(*)6 E F5 -(arg_help;)A(};)102 672 Q F3(long_name)102 690 Q F0 .207 -(is the long name of the option, it can be)2.707 F F5(NULL)2.706 E F0 -2.706(,i)C 2.706(fy)-2.706 G .206(ou don')-2.706 F 2.706(tw)-.18 G .206 -(ant a long name.)-2.806 F F3(short_name)5.206 E F0 .397(is the charact\ -ed to use as short option, it can be zero. If the option has a v)102 702 -R .398(alue the)-.25 F F3(value)2.898 E F0 .398 -(\214eld gets \214lled in)2.898 F -.4(RO)77 750 S 152.325(KEN September) -.4 F(24, 1999)2.5 E(1)188.865 E EP -%%Page: 2 2 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F .737(with that v)102 96 R .737 -(alue interpreted as speci\214ed by the)-.25 F/F1 10/Courier-Oblique@0 -SF(type)3.237 E F0(\214eld.)3.237 E F1(help)5.737 E F0 .737 -(is a longer help string for the option as a)3.237 F 2.833 -(whole, if it')102 108 R(s)-.55 E/F2 10/Courier@0 SF(NULL)5.333 E F0 -2.833(the help te)5.333 F 2.833(xt for the option is omitted \(b)-.15 F -2.834(ut it')-.2 F 5.334(ss)-.55 G 2.834 -(till displayed in the synopsis\).)-5.334 F F1(arg_help)102 120 Q F0 -.391(is a description of the ar)2.891 F .391(gument, if)-.18 F F2(NULL) -2.891 E F0 2.891(ad)2.891 G(ef)-2.891 E .39(ault v)-.1 F .39 -(alue will be used, depending on the type of)-.25 F(the option:)102 132 -Q(ar)102 150 Q(g_inte)-.18 E 59.29(ger the)-.15 F(ar)2.5 E -(gument is a signed inte)-.18 E(ger)-.15 E 2.5(,a)-.4 G(nd)-2.5 E F1 -(value)2.5 E F0(should point to an)2.5 E F1(int)2.5 E F0(.)A F1 -(arg_string)102 168 Q F0(the ar)47 E(gument is a string, and)-.18 E F1 -(value)2.5 E F0(should point to a)2.5 E F1(char)2.5 E/F3 10/Symbol SF(*) -A F0(.)A F1(arg_flag)102 186 Q F0 .4(the ar)59 F .4 -(gument is a \215ag, and)-.18 F F1(value)2.9 E F0 .4(should point to a) -2.9 F F1(int)2.9 E F0 2.9(.I)C 2.9(tg)-2.9 G .4 -(ets \214lled in with ei-)-2.9 F 1.154 -(ther zero or one, depending on ho)209 198 R 3.654(wt)-.25 G 1.153 -(he option is gi)-3.654 F -.15(ve)-.25 G 1.153 -(n, the normal case beeing).15 F .526(one. Note that if the option isn') -209 210 R 3.026(tg)-.18 G -2.15 -.25(iv e)-3.026 H .526(n, the v).25 F -.526(alue isn')-.25 F 3.026(ta)-.18 G .527(ltered, so it should be ini-) --3.026 F(tialised to some useful def)209 222 Q(ault.)-.1 E F1 -(arg_negative_flag)102 240 Q F0 .058(this is the same as)2.558 F F1 -(arg_flag)2.558 E F0 -.2(bu)2.558 G 2.558(ti).2 G 2.558(tr)-2.558 G --2.15 -.25(ev e)-2.558 H .057(rses the meaning of the \215ag \(a gi).25 -F -.15(ve)-.25 G 2.557(ns).15 G(hort)-2.557 E -(option clears the \215ag\), and the synopsis of a long option is ne)209 -252 Q -.05(ga)-.15 G(ted.).05 E F1(arg_strings)102 270 Q F0 .195(the ar) -41 F .195(gument can be gi)-.18 F -.15(ve)-.25 G 2.695(nm).15 G .195 -(ultiple times, and the v)-2.695 F .195 -(alues are collected in an array;)-.25 F F1(value)209 282 Q F0 .947 -(should be a pointer to a)3.447 F F1 .947(struct getarg_strings)3.447 F -F0 .947(structure, which)3.447 F(holds a length and a string pointer)209 -294 Q(.)-.55 E F1(arg_double)102 312 Q F0(ar)47 E .538 -(gument is a double precision \215oating point v)-.18 F .539(alue, and) --.25 F F1(value)3.039 E F0 .539(should point to a)3.039 F F1(double)209 -324 Q F0(.)A F1(arg_collect)102 342 Q F0(allo)41 E .345 -(ws more \214ne-grained control of the option parsing process.)-.25 F F1 -(value)5.344 E F0 .344(should be)2.844 F 2.5(ap)209 354 S(ointer to a) --2.5 E F1(getarg_collect_info)2.5 E F0(structure:)2.5 E F2 -(typedef int \()209 372 Q F3(*)A F2 -(getarg_collect_func\)\(int short_opt,)A(int argc,)407 384 Q(char)407 -396 Q F3(**)6 E F2(argv,)A(int)407 408 Q F3(*)6 E F2(optind,)A(int)407 -420 Q F3(*)6 E F2(optarg,)A(void)407 432 Q F3(*)6 E F2(data\);)A -(typedef struct getarg_collect_info {)209 456 Q -(getarg_collect_func func;)233 468 Q(void)233 480 Q F3(*)6 E F2(data;)A -6(}g)209 492 S(etarg_collect_info;)-6 E F0 -.4(Wi)209 510 S 1.018 -(th the).4 F F1(func)3.518 E F0 1.019 -(member set to a function to call, and)3.518 F F1(data)3.519 E F0 1.019 -(to some application)3.519 F -(speci\214c data. The parameters to the collect function are:)209 522 Q -F1(short_flag)209 540 Q F0 -(non-zero if this call is via a short option \215ag, zero otherwise)2.5 -E F1(argc)209 558 Q F0(,)A F1(argv)6 E F0(the whole ar)2.5 E -(gument list)-.18 E F1(optind)209 576 Q F0(pointer to the inde)2.5 E 2.5 -(xi)-.15 G 2.5(na)-2.5 G -.18(rg)-2.5 G 2.5(vw).18 G(here the \215ag is) --2.5 E F1(optarg)209 594 Q F0(pointer to the inde)2.5 E 2.5(xi)-.15 G -2.5(na)-2.5 G -.18(rg)-2.5 G(v[).18 E F3(*)A F0 -(optind] where the \215ag name starts)A F1(data)209 612 Q F0 -(application speci\214c data)2.5 E -1.1(Yo)209 630 S 3.915(uc)1.1 G -1.415(an modify)-3.915 F F3(*)3.915 E F1(optind)A F0 3.915(,a)C(nd) --3.915 E F3(*)3.915 E F1(optarg)A F0 3.915(,b)C 1.414 -(ut to do this correct you \(more or)-4.115 F(less\) ha)209 642 Q .3 --.15(ve t)-.2 H 2.5(ok).15 G(no)-2.5 E 2.5(wa)-.25 G(bout the inner w) --2.5 E(orkings of getar)-.1 E(g.)-.18 E -1.1(Yo)209 666 S 3.604(uc)1.1 G -1.104(an skip parts of ar)-3.604 F 1.105(guments by increasing)-.18 F F3 -(*)3.605 E F1(optarg)A F0 1.105(\(you could implement)3.605 F(the)209 -678 Q/F4 10/Courier-Bold@0 SF<ad7a>4.567 E F1(3)A F0 .401 -(set of \215ags from)2.901 F F4(gzip)2.9 E F0 .4 -(with this\), or whole ar)2.9 F .4(gument strings by increas-)-.18 F -(ing)209 690 Q F3(*)3.275 E F1(optind)A F0(\(let')3.275 E 3.276(ss)-.55 -G .776(ay you w)-3.276 F .776(ant a \215ag)-.1 F F4<ad63>4.942 E F1 -6.776(xyz)6.776 G F0 .776(to specify a coordinate\); if)-3.5 F -(you also ha)209 702 Q .3 -.15(ve t)-.2 H 2.5(os).15 G(et)-2.5 E F3(*) -2.5 E F1(optarg)A F0(to a sane v)2.5 E(alue.)-.25 E -.4(RO)77 750 S -152.325(KEN September).4 F(24, 1999)2.5 E(2)188.865 E EP -%%Page: 3 3 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F 9.449 -(The collect function should return one of)209 96 R/F1 10/Courier@0 SF -(ARG_ERR_NO_MATCH)11.948 E F0(,)A F1(ARG_ERR_BAD_ARG)209 108 Q F0(,)A F1 -(ARG_ERR_NO_ARG)6 E F0(on error)2.5 E 2.5(,z)-.4 G(ero otherwise.)-2.5 E --.15(Fo)209 126 S 4.042(ry).15 G 1.542(our con)-4.042 F -.15(ve)-.4 G -1.542(nience there is a function,).15 F/F2 10/Courier-Bold@0 SF -(getarg_optarg)4.042 E F0 1.542(\(\), that returns the)B 1.251 -(traditional ar)209 138 R 1.251(gument string, and you pass it all ar) --.18 F 1.251(guments, sans data, that where)-.18 F(gi)209 150 Q -.15(ve) --.25 G 2.5(nt).15 G 2.5(ot)-2.5 G(he collection function.)-2.5 E(Don') -209 168 Q 2.5(tu)-.18 G(se this more this unless you absolutely ha)-2.5 -E .3 -.15(ve t)-.2 H(o.).15 E .213(Option parsing is similar to what)102 -186 R F1(getopt)2.713 E F0 .214(uses. Short options without ar)2.714 F -.214(guments can be compressed \()-.18 F F2(\255xyz)1.666 E F0 .207 -(is the same as)102 198 R F2 1.873<ad7820ad7920ad7a>4.373 F F0 .207 -(\), and short options with ar)B .207(guments tak)-.18 F 2.706(et)-.1 G -.206(hese as either the rest of the ar)-2.706 F(gv-string)-.18 E -(or as the ne)102 210 Q(xt option \()-.15 E F2<ad6f>1.666 E/F3 10 -/Courier-Oblique@0 SF(foo)A F0 2.5(,o)C(r)-2.5 E F2<ad6f>4.166 E F3(foo) -6 E F0(\).)A .78(Long option names are pre\214x)102 228 R .781 -(ed with -- \(double dash\), and the v)-.15 F .781 -(alue with a = \(equal\),)-.25 F F2(\255-foo=)4.947 E F3(bar)A F0 3.281 -(.L)C(ong)-3.281 E 3.815 -(option \215ags can either be speci\214ed as the)102 240 R 6.315(ya)-.15 -G 3.815(re \()-6.315 F F2(\255-help)1.666 E F0 3.815 -(\), or with an \(boolean parsable\) option)B(\()102 252 Q F2 -(\255-help=)1.666 E F3(yes)A F0(,)A F2(\255-help=)5.659 E F3(true)A F0 -3.993(,o)C 3.993(rs)-3.993 G 1.493(imilar\), or the)-3.993 F 3.993(yc) --.15 G 1.493(an also be ne)-3.993 F -.05(ga)-.15 G 1.493(ted \().05 F F2 -(\255-no-help)1.666 E F0 1.493(is the same as)3.993 F F2(\255-help=) -103.666 264 Q F0 1.363(no\), and if you')B 1.362 -(re really confused you can do it multiple times \()-.5 F F2 -(\255-no-no-help=)1.666 E F3(false)A F0 3.862(,o)C(r)-3.862 E -2.15 -.25 -(ev e)102 276 T(n).25 E F2(\255-no-no-help=)4.166 E F3(maybe)A F0(\).)A -/F4 10/Times-Bold@0 SF(EXAMPLE)72 300 Q F1(#include <stdio.h>)102 330 Q -(#include <string.h>)102 342 Q(#include <getarg.h>)102 354 Q(char)102 -378 Q/F5 10/Symbol SF(*)6 E F1(source = "Ouagadougou";)A(char)102 390 Q -F5(*)6 E F1(destination;)A(int weight;)102 402 Q -(int include_catalog = 1;)102 414 Q(int help_flag;)102 426 Q -(struct getargs args[] = {)102 450 Q 6({")126 462 S 30(source", 's',)-6 -F 6(arg_string, &source,)6 F("source of shippment", "city" },)138 474 Q -6({")126 486 S(destination", 'd', arg_string,)-6 E(&destination,)12 E -("destination of shippment", "city" },)138 498 Q 6({")126 510 S 30 -(weight", 'w',)-6 F(arg_integer, &weight,)6 E -("weight of shippment", "tons" },)138 522 Q 6({")126 534 S 24 -(catalog", 'c',)-6 F(arg_negative_flag, &include_catalog,)6 E -("include product catalog" },)138 546 Q 6({")126 558 S 42(help", 'h',)-6 -F(arg_flag, &help_flag })6 E(};)102 570 Q -(int num_args = sizeof\(args\) / sizeof\(args[0]\); /)102 594 Q F5(*)A -F1(number of elements in args)6 E F5(*)6 E F1(/)A(const char)102 618 Q -F5(*)6 E F1(progname = "ship++";)A(int)102 642 Q(main\(int argc, char) -102 654 Q F5(**)6 E F1(argv\))A({)102 666 Q(int optind = 0;)126 678 Q -(if \(getarg\(args, num_args, argc, argv, &optind\)\) {)126 690 Q -(arg_printusage\(args, num_args, progname, "stuff..."\);)147 702 Q F0 --.4(RO)77 750 S 152.325(KEN September).4 F(24, 1999)2.5 E(3)188.865 E EP -%%Page: 4 4 -%%BeginPageSetup -BP -%%EndPageSetup -/F0 10/Times-Roman@0 SF(GET)72 48 Q -.834(ARG \( 3 \))-.93 F -(OpenBSD Programmer')111.062 E 2.5(sM)-.55 G 108.562(anual GET)-2.5 F --.834(ARG \( 3 \))-.93 F/F1 10/Courier@0 SF(exit \(1\);)147 96 Q(})126 -108 Q(if \(help_flag\) {)126 120 Q -(arg_printusage\(args, num_args, progname, "stuff..."\);)147 132 Q -(exit \(0\);)147 144 Q(})126 156 Q(if \(destination == NULL\) {)126 168 -Q(fprintf\(stderr, "%s: must specify destination0, progname\);)147 180 Q -(exit\(1\);)147 192 Q(})126 204 Q -(if \(strcmp\(source, destination\) == 0\) {)126 216 Q -(fprintf\(stderr, "%s: destination must be different from source0\);)147 -228 Q(exit\(1\);)147 240 Q(})126 252 Q(/)126 264 Q/F2 10/Symbol SF(*)A -F1(include more stuff here ...)6 E F2(*)6 E F1(/)A(exit\(2\);)126 276 Q -(})102 288 Q F0(The output help output from this program looks lik)102 -306 Q 2.5(et)-.1 G(his:)-2.5 E F1 6($s)102 324 S(hip++ --help)-6 E -(Usage: ship++ [--source=city] [-s city] [--destination=city] [-d city]) -102 336 Q -([--weight=tons] [-w tons] [--no-catalog] [-c] [--help] [-h] stuff...) -120 348 Q(-s city, --source=city)102 360 Q(source of shippment)36 E -(-d city, --destination=city destination of shippment)102 372 Q -(-w tons, --weight=tons)102 384 Q(weight of shippment)36 E -(-c, --no-catalog)102 396 Q(include product catalog)72 E/F3 10 -/Times-Bold@0 SF -.1(BU)72 432 S(GS).1 E F0 .9(It should be more \215e) -102 444 R .9(xible, so it w)-.15 F .901 -(ould be possible to use other more complicated option syntax)-.1 F .901 -(es, such as)-.15 F(what)102 456 Q F1(ps)3.167 E F0 .667(\(1\), and)B F1 -(tar)3.167 E F0 .666(\(1\), uses, or the AFS model where you can skip t\ -he \215ag names as long as the options)B(come in the correct order)102 -468 Q(.)-.55 E(Options with multiple ar)102 486 Q -(guments should be handled better)-.18 E(.)-.55 E(Should be inte)102 504 -Q(greated with SL.)-.15 E(It')102 522 Q 2.5(sv)-.55 G -(ery confusing that the struct you pass in is called getar)-2.65 E(gS.) --.18 E F3 1.666(SEE ALSO)72 546 R F1(getopt)102 558 Q F0(\(3\))A -.4(RO) -77 750 S 152.325(KEN September).4 F(24, 1999)2.5 E(4)188.865 E EP -%%Trailer -end -%%EOF diff --git a/ndb/src/common/util/md5-rfc1321.txt b/ndb/src/common/util/md5-rfc1321.txt deleted file mode 100644 index c9e09e00cce..00000000000 --- a/ndb/src/common/util/md5-rfc1321.txt +++ /dev/null @@ -1,1179 +0,0 @@ - - - - - - -Network Working Group R. Rivest -Request for Comments: 1321 MIT Laboratory for Computer Science - and RSA Data Security, Inc. - April 1992 - - - The MD5 Message-Digest Algorithm - -Status of this Memo - - This memo provides information for the Internet community. It does - not specify an Internet standard. Distribution of this memo is - unlimited. - -Acknowlegements - - We would like to thank Don Coppersmith, Burt Kaliski, Ralph Merkle, - David Chaum, and Noam Nisan for numerous helpful comments and - suggestions. - -Table of Contents - - 1. Executive Summary 1 - 2. Terminology and Notation 2 - 3. MD5 Algorithm Description 3 - 4. Summary 6 - 5. Differences Between MD4 and MD5 6 - References 7 - APPENDIX A - Reference Implementation 7 - Security Considerations 21 - Author's Address 21 - -1. Executive Summary - - This document describes the MD5 message-digest algorithm. The - algorithm takes as input a message of arbitrary length and produces - as output a 128-bit "fingerprint" or "message digest" of the input. - It is conjectured that it is computationally infeasible to produce - two messages having the same message digest, or to produce any - message having a given prespecified target message digest. The MD5 - algorithm is intended for digital signature applications, where a - large file must be "compressed" in a secure manner before being - encrypted with a private (secret) key under a public-key cryptosystem - such as RSA. - - - - - - - -Rivest [Page 1] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - The MD5 algorithm is designed to be quite fast on 32-bit machines. In - addition, the MD5 algorithm does not require any large substitution - tables; the algorithm can be coded quite compactly. - - The MD5 algorithm is an extension of the MD4 message-digest algorithm - 1,2]. MD5 is slightly slower than MD4, but is more "conservative" in - design. MD5 was designed because it was felt that MD4 was perhaps - being adopted for use more quickly than justified by the existing - critical review; because MD4 was designed to be exceptionally fast, - it is "at the edge" in terms of risking successful cryptanalytic - attack. MD5 backs off a bit, giving up a little in speed for a much - greater likelihood of ultimate security. It incorporates some - suggestions made by various reviewers, and contains additional - optimizations. The MD5 algorithm is being placed in the public domain - for review and possible adoption as a standard. - - For OSI-based applications, MD5's object identifier is - - md5 OBJECT IDENTIFIER ::= - iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2) 5} - - In the X.509 type AlgorithmIdentifier [3], the parameters for MD5 - should have type NULL. - -2. Terminology and Notation - - In this document a "word" is a 32-bit quantity and a "byte" is an - eight-bit quantity. A sequence of bits can be interpreted in a - natural manner as a sequence of bytes, where each consecutive group - of eight bits is interpreted as a byte with the high-order (most - significant) bit of each byte listed first. Similarly, a sequence of - bytes can be interpreted as a sequence of 32-bit words, where each - consecutive group of four bytes is interpreted as a word with the - low-order (least significant) byte given first. - - Let x_i denote "x sub i". If the subscript is an expression, we - surround it in braces, as in x_{i+1}. Similarly, we use ^ for - superscripts (exponentiation), so that x^i denotes x to the i-th - power. - - Let the symbol "+" denote addition of words (i.e., modulo-2^32 - addition). Let X <<< s denote the 32-bit value obtained by circularly - shifting (rotating) X left by s bit positions. Let not(X) denote the - bit-wise complement of X, and let X v Y denote the bit-wise OR of X - and Y. Let X xor Y denote the bit-wise XOR of X and Y, and let XY - denote the bit-wise AND of X and Y. - - - - - -Rivest [Page 2] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -3. MD5 Algorithm Description - - We begin by supposing that we have a b-bit message as input, and that - we wish to find its message digest. Here b is an arbitrary - nonnegative integer; b may be zero, it need not be a multiple of - eight, and it may be arbitrarily large. We imagine the bits of the - message written down as follows: - - m_0 m_1 ... m_{b-1} - - The following five steps are performed to compute the message digest - of the message. - -3.1 Step 1. Append Padding Bits - - The message is "padded" (extended) so that its length (in bits) is - congruent to 448, modulo 512. That is, the message is extended so - that it is just 64 bits shy of being a multiple of 512 bits long. - Padding is always performed, even if the length of the message is - already congruent to 448, modulo 512. - - Padding is performed as follows: a single "1" bit is appended to the - message, and then "0" bits are appended so that the length in bits of - the padded message becomes congruent to 448, modulo 512. In all, at - least one bit and at most 512 bits are appended. - -3.2 Step 2. Append Length - - A 64-bit representation of b (the length of the message before the - padding bits were added) is appended to the result of the previous - step. In the unlikely event that b is greater than 2^64, then only - the low-order 64 bits of b are used. (These bits are appended as two - 32-bit words and appended low-order word first in accordance with the - previous conventions.) - - At this point the resulting message (after padding with bits and with - b) has a length that is an exact multiple of 512 bits. Equivalently, - this message has a length that is an exact multiple of 16 (32-bit) - words. Let M[0 ... N-1] denote the words of the resulting message, - where N is a multiple of 16. - -3.3 Step 3. Initialize MD Buffer - - A four-word buffer (A,B,C,D) is used to compute the message digest. - Here each of A, B, C, D is a 32-bit register. These registers are - initialized to the following values in hexadecimal, low-order bytes - first): - - - - -Rivest [Page 3] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - word A: 01 23 45 67 - word B: 89 ab cd ef - word C: fe dc ba 98 - word D: 76 54 32 10 - -3.4 Step 4. Process Message in 16-Word Blocks - - We first define four auxiliary functions that each take as input - three 32-bit words and produce as output one 32-bit word. - - F(X,Y,Z) = XY v not(X) Z - G(X,Y,Z) = XZ v Y not(Z) - H(X,Y,Z) = X xor Y xor Z - I(X,Y,Z) = Y xor (X v not(Z)) - - In each bit position F acts as a conditional: if X then Y else Z. - The function F could have been defined using + instead of v since XY - and not(X)Z will never have 1's in the same bit position.) It is - interesting to note that if the bits of X, Y, and Z are independent - and unbiased, the each bit of F(X,Y,Z) will be independent and - unbiased. - - The functions G, H, and I are similar to the function F, in that they - act in "bitwise parallel" to produce their output from the bits of X, - Y, and Z, in such a manner that if the corresponding bits of X, Y, - and Z are independent and unbiased, then each bit of G(X,Y,Z), - H(X,Y,Z), and I(X,Y,Z) will be independent and unbiased. Note that - the function H is the bit-wise "xor" or "parity" function of its - inputs. - - This step uses a 64-element table T[1 ... 64] constructed from the - sine function. Let T[i] denote the i-th element of the table, which - is equal to the integer part of 4294967296 times abs(sin(i)), where i - is in radians. The elements of the table are given in the appendix. - - Do the following: - - /* Process each 16-word block. */ - For i = 0 to N/16-1 do - - /* Copy block i into X. */ - For j = 0 to 15 do - Set X[j] to M[i*16+j]. - end /* of loop on j */ - - /* Save A as AA, B as BB, C as CC, and D as DD. */ - AA = A - BB = B - - - -Rivest [Page 4] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - CC = C - DD = D - - /* Round 1. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ - /* Do the following 16 operations. */ - [ABCD 0 7 1] [DABC 1 12 2] [CDAB 2 17 3] [BCDA 3 22 4] - [ABCD 4 7 5] [DABC 5 12 6] [CDAB 6 17 7] [BCDA 7 22 8] - [ABCD 8 7 9] [DABC 9 12 10] [CDAB 10 17 11] [BCDA 11 22 12] - [ABCD 12 7 13] [DABC 13 12 14] [CDAB 14 17 15] [BCDA 15 22 16] - - /* Round 2. */ - /* Let [abcd k s i] denote the operation - a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ - /* Do the following 16 operations. */ - [ABCD 1 5 17] [DABC 6 9 18] [CDAB 11 14 19] [BCDA 0 20 20] - [ABCD 5 5 21] [DABC 10 9 22] [CDAB 15 14 23] [BCDA 4 20 24] - [ABCD 9 5 25] [DABC 14 9 26] [CDAB 3 14 27] [BCDA 8 20 28] - [ABCD 13 5 29] [DABC 2 9 30] [CDAB 7 14 31] [BCDA 12 20 32] - - /* Round 3. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ - /* Do the following 16 operations. */ - [ABCD 5 4 33] [DABC 8 11 34] [CDAB 11 16 35] [BCDA 14 23 36] - [ABCD 1 4 37] [DABC 4 11 38] [CDAB 7 16 39] [BCDA 10 23 40] - [ABCD 13 4 41] [DABC 0 11 42] [CDAB 3 16 43] [BCDA 6 23 44] - [ABCD 9 4 45] [DABC 12 11 46] [CDAB 15 16 47] [BCDA 2 23 48] - - /* Round 4. */ - /* Let [abcd k s t] denote the operation - a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ - /* Do the following 16 operations. */ - [ABCD 0 6 49] [DABC 7 10 50] [CDAB 14 15 51] [BCDA 5 21 52] - [ABCD 12 6 53] [DABC 3 10 54] [CDAB 10 15 55] [BCDA 1 21 56] - [ABCD 8 6 57] [DABC 15 10 58] [CDAB 6 15 59] [BCDA 13 21 60] - [ABCD 4 6 61] [DABC 11 10 62] [CDAB 2 15 63] [BCDA 9 21 64] - - /* Then perform the following additions. (That is increment each - of the four registers by the value it had before this block - was started.) */ - A = A + AA - B = B + BB - C = C + CC - D = D + DD - - end /* of loop on i */ - - - -Rivest [Page 5] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -3.5 Step 5. Output - - The message digest produced as output is A, B, C, D. That is, we - begin with the low-order byte of A, and end with the high-order byte - of D. - - This completes the description of MD5. A reference implementation in - C is given in the appendix. - -4. Summary - - The MD5 message-digest algorithm is simple to implement, and provides - a "fingerprint" or message digest of a message of arbitrary length. - It is conjectured that the difficulty of coming up with two messages - having the same message digest is on the order of 2^64 operations, - and that the difficulty of coming up with any message having a given - message digest is on the order of 2^128 operations. The MD5 algorithm - has been carefully scrutinized for weaknesses. It is, however, a - relatively new algorithm and further security analysis is of course - justified, as is the case with any new proposal of this sort. - -5. Differences Between MD4 and MD5 - - The following are the differences between MD4 and MD5: - - 1. A fourth round has been added. - - 2. Each step now has a unique additive constant. - - 3. The function g in round 2 was changed from (XY v XZ v YZ) to - (XZ v Y not(Z)) to make g less symmetric. - - 4. Each step now adds in the result of the previous step. This - promotes a faster "avalanche effect". - - 5. The order in which input words are accessed in rounds 2 and - 3 is changed, to make these patterns less like each other. - - 6. The shift amounts in each round have been approximately - optimized, to yield a faster "avalanche effect." The shifts in - different rounds are distinct. - - - - - - - - - - -Rivest [Page 6] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -References - - [1] Rivest, R., "The MD4 Message Digest Algorithm", RFC 1320, MIT and - RSA Data Security, Inc., April 1992. - - [2] Rivest, R., "The MD4 message digest algorithm", in A.J. Menezes - and S.A. Vanstone, editors, Advances in Cryptology - CRYPTO '90 - Proceedings, pages 303-311, Springer-Verlag, 1991. - - [3] CCITT Recommendation X.509 (1988), "The Directory - - Authentication Framework." - -APPENDIX A - Reference Implementation - - This appendix contains the following files taken from RSAREF: A - Cryptographic Toolkit for Privacy-Enhanced Mail: - - global.h -- global header file - - md5.h -- header file for MD5 - - md5c.c -- source code for MD5 - - For more information on RSAREF, send email to <rsaref@rsa.com>. - - The appendix also includes the following file: - - mddriver.c -- test driver for MD2, MD4 and MD5 - - The driver compiles for MD5 by default but can compile for MD2 or MD4 - if the symbol MD is defined on the C compiler command line as 2 or 4. - - The implementation is portable and should work on many different - plaforms. However, it is not difficult to optimize the implementation - on particular platforms, an exercise left to the reader. For example, - on "little-endian" platforms where the lowest-addressed byte in a 32- - bit word is the least significant and there are no alignment - restrictions, the call to Decode in MD5Transform can be replaced with - a typecast. - -A.1 global.h - -/* GLOBAL.H - RSAREF types and constants - */ - -/* PROTOTYPES should be set to one if and only if the compiler supports - function argument prototyping. -The following makes PROTOTYPES default to 0 if it has not already - - - -Rivest [Page 7] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - been defined with C compiler flags. - */ -#ifndef PROTOTYPES -#define PROTOTYPES 0 -#endif - -/* POINTER defines a generic pointer type */ -typedef unsigned char *POINTER; - -/* UINT2 defines a two byte word */ -typedef unsigned short int UINT2; - -/* UINT4 defines a four byte word */ -typedef unsigned long int UINT4; - -/* PROTO_LIST is defined depending on how PROTOTYPES is defined above. -If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it - returns an empty list. - */ -#if PROTOTYPES -#define PROTO_LIST(list) list -#else -#define PROTO_LIST(list) () -#endif - -A.2 md5.h - -/* MD5.H - header file for MD5C.C - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - - - - -Rivest [Page 8] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -/* MD5 context. */ -typedef struct { - UINT4 state[4]; /* state (ABCD) */ - UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ - unsigned char buffer[64]; /* input buffer */ -} MD5_CTX; - -void MD5Init PROTO_LIST ((MD5_CTX *)); -void MD5Update PROTO_LIST - ((MD5_CTX *, unsigned char *, unsigned int)); -void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); - -A.3 md5c.c - -/* MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm - */ - -/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -#include "global.h" -#include "md5.h" - -/* Constants for MD5Transform routine. - */ - - - -Rivest [Page 9] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64])); -static void Encode PROTO_LIST - ((unsigned char *, UINT4 *, unsigned int)); -static void Decode PROTO_LIST - ((UINT4 *, unsigned char *, unsigned int)); -static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned int)); -static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int)); - -static unsigned char PADDING[64] = { - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* F, G, H and I are basic MD5 functions. - */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* ROTATE_LEFT rotates x left n bits. - */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -Rotation is separate from addition to prevent recomputation. - */ -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - - - -Rivest [Page 10] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -/* MD5 initialization. Begins an MD5 operation, writing a new context. - */ -void MD5Init (context) -MD5_CTX *context; /* context */ -{ - context->count[0] = context->count[1] = 0; - /* Load magic initialization constants. -*/ - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; -} - -/* MD5 block update operation. Continues an MD5 message-digest - operation, processing another message block, and updating the - context. - */ -void MD5Update (context, input, inputLen) -MD5_CTX *context; /* context */ -unsigned char *input; /* input block */ -unsigned int inputLen; /* length of input block */ -{ - unsigned int i, index, partLen; - - /* Compute number of bytes mod 64 */ - index = (unsigned int)((context->count[0] >> 3) & 0x3F); - - /* Update number of bits */ - if ((context->count[0] += ((UINT4)inputLen << 3)) - - - -Rivest [Page 11] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - < ((UINT4)inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); - - partLen = 64 - index; - - /* Transform as many times as possible. -*/ - if (inputLen >= partLen) { - MD5_memcpy - ((POINTER)&context->buffer[index], (POINTER)input, partLen); - MD5Transform (context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform (context->state, &input[i]); - - index = 0; - } - else - i = 0; - - /* Buffer remaining input */ - MD5_memcpy - ((POINTER)&context->buffer[index], (POINTER)&input[i], - inputLen-i); -} - -/* MD5 finalization. Ends an MD5 message-digest operation, writing the - the message digest and zeroizing the context. - */ -void MD5Final (digest, context) -unsigned char digest[16]; /* message digest */ -MD5_CTX *context; /* context */ -{ - unsigned char bits[8]; - unsigned int index, padLen; - - /* Save number of bits */ - Encode (bits, context->count, 8); - - /* Pad out to 56 mod 64. -*/ - index = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - MD5Update (context, PADDING, padLen); - - /* Append length (before padding) */ - MD5Update (context, bits, 8); - - - -Rivest [Page 12] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - /* Store state in digest */ - Encode (digest, context->state, 16); - - /* Zeroize sensitive information. -*/ - MD5_memset ((POINTER)context, 0, sizeof (*context)); -} - -/* MD5 basic transformation. Transforms state based on block. - */ -static void MD5Transform (state, block) -UINT4 state[4]; -unsigned char block[64]; -{ - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode (x, block, 64); - - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - - - -Rivest [Page 13] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - /* Zeroize sensitive information. - - - -Rivest [Page 14] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -*/ - MD5_memset ((POINTER)x, 0, sizeof (x)); -} - -/* Encodes input (UINT4) into output (unsigned char). Assumes len is - a multiple of 4. - */ -static void Encode (output, input, len) -unsigned char *output; -UINT4 *input; -unsigned int len; -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); - } -} - -/* Decodes input (unsigned char) into output (UINT4). Assumes len is - a multiple of 4. - */ -static void Decode (output, input, len) -UINT4 *output; -unsigned char *input; -unsigned int len; -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); -} - -/* Note: Replace "for loop" with standard memcpy if possible. - */ - -static void MD5_memcpy (output, input, len) -POINTER output; -POINTER input; -unsigned int len; -{ - unsigned int i; - - for (i = 0; i < len; i++) - - - -Rivest [Page 15] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - output[i] = input[i]; -} - -/* Note: Replace "for loop" with standard memset if possible. - */ -static void MD5_memset (output, value, len) -POINTER output; -int value; -unsigned int len; -{ - unsigned int i; - - for (i = 0; i < len; i++) - ((char *)output)[i] = (char)value; -} - -A.4 mddriver.c - -/* MDDRIVER.C - test driver for MD2, MD4 and MD5 - */ - -/* Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All -rights reserved. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - */ - -/* The following makes MD default to MD5 if it has not already been - defined with C compiler flags. - */ -#ifndef MD -#define MD MD5 -#endif - -#include <stdio.h> -#include <time.h> -#include <string.h> -#include "global.h" -#if MD == 2 -#include "md2.h" -#endif -#if MD == 4 - - - -Rivest [Page 16] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -#include "md4.h" -#endif -#if MD == 5 -#include "md5.h" -#endif - -/* Length of test block, number of test blocks. - */ -#define TEST_BLOCK_LEN 1000 -#define TEST_BLOCK_COUNT 1000 - -static void MDString PROTO_LIST ((char *)); -static void MDTimeTrial PROTO_LIST ((void)); -static void MDTestSuite PROTO_LIST ((void)); -static void MDFile PROTO_LIST ((char *)); -static void MDFilter PROTO_LIST ((void)); -static void MDPrint PROTO_LIST ((unsigned char [16])); - -#if MD == 2 -#define MD_CTX MD2_CTX -#define MDInit MD2Init -#define MDUpdate MD2Update -#define MDFinal MD2Final -#endif -#if MD == 4 -#define MD_CTX MD4_CTX -#define MDInit MD4Init -#define MDUpdate MD4Update -#define MDFinal MD4Final -#endif -#if MD == 5 -#define MD_CTX MD5_CTX -#define MDInit MD5Init -#define MDUpdate MD5Update -#define MDFinal MD5Final -#endif - -/* Main driver. - -Arguments (may be any combination): - -sstring - digests string - -t - runs time trial - -x - runs test script - filename - digests file - (none) - digests standard input - */ -int main (argc, argv) -int argc; - - - -Rivest [Page 17] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - -char *argv[]; -{ - int i; - - if (argc > 1) - for (i = 1; i < argc; i++) - if (argv[i][0] == '-' && argv[i][1] == 's') - MDString (argv[i] + 2); - else if (strcmp (argv[i], "-t") == 0) - MDTimeTrial (); - else if (strcmp (argv[i], "-x") == 0) - MDTestSuite (); - else - MDFile (argv[i]); - else - MDFilter (); - - return (0); -} - -/* Digests a string and prints the result. - */ -static void MDString (string) -char *string; -{ - MD_CTX context; - unsigned char digest[16]; - unsigned int len = strlen (string); - - MDInit (&context); - MDUpdate (&context, string, len); - MDFinal (digest, &context); - - printf ("MD%d (\"%s\") = ", MD, string); - MDPrint (digest); - printf ("\n"); -} - -/* Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte - blocks. - */ -static void MDTimeTrial () -{ - MD_CTX context; - time_t endTime, startTime; - unsigned char block[TEST_BLOCK_LEN], digest[16]; - unsigned int i; - - - - -Rivest [Page 18] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - printf - ("MD%d time trial. Digesting %d %d-byte blocks ...", MD, - TEST_BLOCK_LEN, TEST_BLOCK_COUNT); - - /* Initialize block */ - for (i = 0; i < TEST_BLOCK_LEN; i++) - block[i] = (unsigned char)(i & 0xff); - - /* Start timer */ - time (&startTime); - - /* Digest blocks */ - MDInit (&context); - for (i = 0; i < TEST_BLOCK_COUNT; i++) - MDUpdate (&context, block, TEST_BLOCK_LEN); - MDFinal (digest, &context); - - /* Stop timer */ - time (&endTime); - - printf (" done\n"); - printf ("Digest = "); - MDPrint (digest); - printf ("\nTime = %ld seconds\n", (long)(endTime-startTime)); - printf - ("Speed = %ld bytes/second\n", - (long)TEST_BLOCK_LEN * (long)TEST_BLOCK_COUNT/(endTime-startTime)); -} - -/* Digests a reference suite of strings and prints the results. - */ -static void MDTestSuite () -{ - printf ("MD%d test suite:\n", MD); - - MDString (""); - MDString ("a"); - MDString ("abc"); - MDString ("message digest"); - MDString ("abcdefghijklmnopqrstuvwxyz"); - MDString - ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); - MDString - ("1234567890123456789012345678901234567890\ -1234567890123456789012345678901234567890"); -} - -/* Digests a file and prints the result. - - - -Rivest [Page 19] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - */ -static void MDFile (filename) -char *filename; -{ - FILE *file; - MD_CTX context; - int len; - unsigned char buffer[1024], digest[16]; - - if ((file = fopen (filename, "rb")) == NULL) - printf ("%s can't be opened\n", filename); - - else { - MDInit (&context); - while (len = fread (buffer, 1, 1024, file)) - MDUpdate (&context, buffer, len); - MDFinal (digest, &context); - - fclose (file); - - printf ("MD%d (%s) = ", MD, filename); - MDPrint (digest); - printf ("\n"); - } -} - -/* Digests the standard input and prints the result. - */ -static void MDFilter () -{ - MD_CTX context; - int len; - unsigned char buffer[16], digest[16]; - - MDInit (&context); - while (len = fread (buffer, 1, 16, stdin)) - MDUpdate (&context, buffer, len); - MDFinal (digest, &context); - - MDPrint (digest); - printf ("\n"); -} - -/* Prints a message digest in hexadecimal. - */ -static void MDPrint (digest) -unsigned char digest[16]; -{ - - - -Rivest [Page 20] - -RFC 1321 MD5 Message-Digest Algorithm April 1992 - - - unsigned int i; - - for (i = 0; i < 16; i++) - printf ("%02x", digest[i]); -} - -A.5 Test suite - - The MD5 test suite (driver option "-x") should print the following - results: - -MD5 test suite: -MD5 ("") = d41d8cd98f00b204e9800998ecf8427e -MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661 -MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72 -MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0 -MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b -MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = -d174ab98d277d9f5a5611c2c9f419d9f -MD5 ("123456789012345678901234567890123456789012345678901234567890123456 -78901234567890") = 57edf4a22be3c955ac49da2e2107b67a - -Security Considerations - - The level of security discussed in this memo is considered to be - sufficient for implementing very high security hybrid digital- - signature schemes based on MD5 and a public-key cryptosystem. - -Author's Address - - Ronald L. Rivest - Massachusetts Institute of Technology - Laboratory for Computer Science - NE43-324 - 545 Technology Square - Cambridge, MA 02139-1986 - - Phone: (617) 253-5880 - EMail: rivest@theory.lcs.mit.edu - - - - - - - - - - - - -Rivest [Page 21] - diff --git a/ndb/src/common/util/socket_io.cpp b/ndb/src/common/util/socket_io.cpp index 6f4c7e63684..83a546de773 100644 --- a/ndb/src/common/util/socket_io.cpp +++ b/ndb/src/common/util/socket_io.cpp @@ -172,22 +172,21 @@ vprint_socket(NDB_SOCKET_TYPE socket, int timeout_millis, const char * fmt, va_list ap){ char buf[1000]; char *buf2 = buf; - size_t size = sizeof(buf); + size_t size; - if (fmt != 0) { + if (fmt != 0 && fmt[0] != 0) { size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap); /* Check if the output was truncated */ - if(size >= sizeof(buf)) { - buf2 = (char *)malloc(size+1); + if(size > sizeof(buf)) { + buf2 = (char *)malloc(size); if(buf2 == NULL) return -1; BaseString::vsnprintf(buf2, size, fmt, ap); - } else - size = sizeof(buf); + } } else - buf[0] = 0; + return 0; - int ret = write_socket(socket, timeout_millis, buf2, strlen(buf2)); + int ret = write_socket(socket, timeout_millis, buf2, size); if(buf2 != buf) free(buf2); return ret; @@ -199,23 +198,23 @@ vprintln_socket(NDB_SOCKET_TYPE socket, int timeout_millis, const char * fmt, va_list ap){ char buf[1000]; char *buf2 = buf; - size_t size = sizeof(buf); + size_t size; - if (fmt != 0) { - size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap); + if (fmt != 0 && fmt[0] != 0) { + size = BaseString::vsnprintf(buf, sizeof(buf), fmt, ap)+1;// extra byte for '/n' /* Check if the output was truncated */ - if(size >= sizeof(buf)-1) { - buf2 = (char *)malloc(size+2); + if(size > sizeof(buf)) { + buf2 = (char *)malloc(size); if(buf2 == NULL) return -1; - BaseString::vsnprintf(buf2, size+1, fmt, ap); - } else - size = sizeof(buf); - } else - buf[0] = 0; - strlcat(buf2, "\n", size+2); + BaseString::vsnprintf(buf2, size, fmt, ap); + } + } else { + size = 1; + } + buf2[size-1]='\n'; - int ret = write_socket(socket, timeout_millis, buf2, strlen(buf2)); + int ret = write_socket(socket, timeout_millis, buf2, size); if(buf2 != buf) free(buf2); return ret; diff --git a/ndb/src/common/util/strdup.c b/ndb/src/common/util/strdup.c index afe2306427e..d8f4d99bd28 100644 --- a/ndb/src/common/util/strdup.c +++ b/ndb/src/common/util/strdup.c @@ -21,8 +21,8 @@ char * strdup(const char *s){ void *p2; - p2 = malloc(strlen(s)+1); - strcpy(p2, s); + if ((p2 = malloc(strlen(s)+1))) + strcpy(p2, s); return p2; } #endif diff --git a/ndb/src/common/util/strlcat.c b/ndb/src/common/util/strlcat.c deleted file mode 100644 index aa282abe48d..00000000000 --- a/ndb/src/common/util/strlcat.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <ndb_global.h> - -/* RCSID("$KTH: strlcat.c,v 1.1 2000/08/16 01:23:47 lha Exp $"); */ - - -#ifndef HAVE_STRLCAT - -size_t -strlcat (char *dst, const char *src, size_t dst_sz) -{ - size_t len = strlen(dst); - - return len + strlcpy (dst + len, src, dst_sz - len); -} -#endif diff --git a/ndb/src/common/util/strlcpy.c b/ndb/src/common/util/strlcpy.c deleted file mode 100644 index 97cff177d48..00000000000 --- a/ndb/src/common/util/strlcpy.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1995 - 1999 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <ndb_global.h> - -/* RCSID("$KTH: strlcpy.c,v 1.1 2000/08/16 01:23:48 lha Exp $"); */ - -#ifndef HAVE_STRLCPY - -size_t -strlcpy (char *dst, const char *src, size_t dst_sz) -{ - size_t n; - char *p; - - for (p = dst, n = 0; - n + 1 < dst_sz && *src != '\0'; - ++p, ++src, ++n) - *p = *src; - *p = '\0'; - if (*src == '\0') - return n; - else - return n + strlen (src); -} - -#endif diff --git a/ndb/src/common/util/version.c b/ndb/src/common/util/version.c index e2515b243b1..8cc6de0fc24 100644 --- a/ndb/src/common/util/version.c +++ b/ndb/src/common/util/version.c @@ -17,6 +17,9 @@ #include <ndb_global.h> #include <ndb_version.h> #include <version.h> +#include <basestring_vsnprintf.h> +#include <NdbEnv.h> +#include <NdbOut.hpp> Uint32 getMajor(Uint32 version) { return (version >> 16) & 0xFF; @@ -38,14 +41,14 @@ Uint32 makeVersion(Uint32 major, Uint32 minor, Uint32 build) { const char * getVersionString(Uint32 version, const char * status) { char buff[100]; if (status && status[0] != 0) - snprintf(buff, sizeof(buff), + basestring_snprintf(buff, sizeof(buff), "Version %d.%d.%d (%s)", getMajor(version), getMinor(version), getBuild(version), status); else - snprintf(buff, sizeof(buff), + basestring_snprintf(buff, sizeof(buff), "Version %d.%d.%d", getMajor(version), getMinor(version), @@ -67,18 +70,37 @@ struct NdbUpGradeCompatible { /*#define TEST_VERSION*/ +#define HAVE_NDB_SETVERSION +#ifdef HAVE_NDB_SETVERSION +Uint32 ndbOwnVersionTesting = 0; +void +ndbSetOwnVersion() { + char buf[256]; + if (NdbEnv_GetEnv("NDB_SETVERSION", buf, sizeof(buf))) { + Uint32 _v1,_v2,_v3; + if (sscanf(buf, "%u.%u.%u", &_v1, &_v2, &_v3) == 3) { + ndbOwnVersionTesting = MAKE_VERSION(_v1,_v2,_v3); + ndbout_c("Testing: Version set to 0x%x", ndbOwnVersionTesting); + } + } +} +#else +void ndbSetOwnVersion() {} +#endif + #ifndef TEST_VERSION struct NdbUpGradeCompatible ndbCompatibleTable_full[] = { + { MAKE_VERSION(4,1,10), MAKE_VERSION(4,1,9), UG_Exact }, + { MAKE_VERSION(4,1,9), MAKE_VERSION(4,1,8), UG_Exact }, { MAKE_VERSION(3,5,2), MAKE_VERSION(3,5,1), UG_Exact }, { 0, 0, UG_Null } }; struct NdbUpGradeCompatible ndbCompatibleTable_upgrade[] = { + { MAKE_VERSION(3,5,4), MAKE_VERSION(3,5,3), UG_Exact }, { 0, 0, UG_Null } }; -void ndbSetOwnVersion() {} - #else /* testing purposes */ struct NdbUpGradeCompatible ndbCompatibleTable_full[] = { @@ -99,19 +121,6 @@ struct NdbUpGradeCompatible ndbCompatibleTable_upgrade[] = { }; -Uint32 ndbOwnVersionTesting = 0; -void -ndbSetOwnVersion() { - char buf[256]; - if (NdbEnv_GetEnv("NDB_SETVERSION", buf, sizeof(buf))) { - Uint32 _v1,_v2,_v3; - if (sscanf(buf, "%u.%u.%u", &_v1, &_v2, &_v3) == 3) { - ndbOwnVersionTesting = MAKE_VERSION(_v1,_v2,_v3); - ndbout_c("Testing: Version set to 0x%x", ndbOwnVersionTesting); - } - } -} - #endif void ndbPrintVersion() @@ -125,13 +134,13 @@ void ndbPrintVersion() Uint32 ndbGetOwnVersion() { -#ifndef TEST_VERSION - return NDB_VERSION_D; -#else /* testing purposes */ +#ifdef HAVE_NDB_SETVERSION if (ndbOwnVersionTesting == 0) return NDB_VERSION_D; else return ndbOwnVersionTesting; +#else + return NDB_VERSION_D; #endif } diff --git a/ndb/src/cw/Makefile.am b/ndb/src/cw/Makefile.am index b530922a3a7..7348fc9eab6 100644 --- a/ndb/src/cw/Makefile.am +++ b/ndb/src/cw/Makefile.am @@ -1 +1,4 @@ SUBDIRS = cpcd + +windoze-dsp: + diff --git a/ndb/src/cw/Makefile_old b/ndb/src/cw/Makefile_old deleted file mode 100644 index e710c1e244d..00000000000 --- a/ndb/src/cw/Makefile_old +++ /dev/null @@ -1,6 +0,0 @@ -include .defs.mk - -DIRS := cpcd - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/src/cw/cpcc-win32/csharp/AssemblyInfo.cs b/ndb/src/cw/cpcc-win32/csharp/AssemblyInfo.cs deleted file mode 100644 index 9f89a3282c5..00000000000 --- a/ndb/src/cw/cpcc-win32/csharp/AssemblyInfo.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.*")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\<configuration>. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] diff --git a/ndb/src/cw/cpcc-win32/vb6/frmSplash.frm b/ndb/src/cw/cpcc-win32/vb6/frmSplash.frm deleted file mode 100644 index 56ccbd79876..00000000000 --- a/ndb/src/cw/cpcc-win32/vb6/frmSplash.frm +++ /dev/null @@ -1,159 +0,0 @@ -VERSION 5.00 -Begin VB.Form frmSplash - BorderStyle = 3 'Fixed Dialog - ClientHeight = 4710 - ClientLeft = 45 - ClientTop = 45 - ClientWidth = 7455 - ControlBox = 0 'False - LinkTopic = "Form1" - MaxButton = 0 'False - MinButton = 0 'False - ScaleHeight = 4710 - ScaleWidth = 7455 - ShowInTaskbar = 0 'False - StartUpPosition = 2 'CenterScreen - Visible = 0 'False - Begin VB.Frame fraMainFrame - Height = 4590 - Left = 45 - TabIndex = 0 - Top = -15 - Width = 7380 - Begin VB.PictureBox picLogo - Height = 2385 - Left = 510 - Picture = "frmSplash.frx":0000 - ScaleHeight = 2325 - ScaleWidth = 1755 - TabIndex = 2 - Top = 855 - Width = 1815 - End - Begin VB.Label lblLicenseTo - Alignment = 1 'Right Justify - Caption = "LicenseTo" - Height = 255 - Left = 270 - TabIndex = 1 - Tag = "LicenseTo" - Top = 300 - Width = 6855 - End - Begin VB.Label lblProductName - AutoSize = -1 'True - Caption = "Product" - BeginProperty Font - Name = "MS Sans Serif" - Size = 29.25 - Charset = 0 - Weight = 700 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - Height = 720 - Left = 2670 - TabIndex = 9 - Tag = "Product" - Top = 1200 - Width = 2190 - End - Begin VB.Label lblCompanyProduct - AutoSize = -1 'True - Caption = "CompanyProduct" - BeginProperty Font - Name = "MS Sans Serif" - Size = 18 - Charset = 0 - Weight = 700 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - Height = 435 - Left = 2505 - TabIndex = 8 - Tag = "CompanyProduct" - Top = 765 - Width = 3000 - End - Begin VB.Label lblPlatform - Alignment = 1 'Right Justify - AutoSize = -1 'True - Caption = "Platform" - BeginProperty Font - Name = "MS Sans Serif" - Size = 13.5 - Charset = 0 - Weight = 700 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - Height = 360 - Left = 5865 - TabIndex = 7 - Tag = "Platform" - Top = 2400 - Width = 1140 - End - Begin VB.Label lblVersion - Alignment = 1 'Right Justify - AutoSize = -1 'True - Caption = "Version" - BeginProperty Font - Name = "MS Sans Serif" - Size = 12 - Charset = 0 - Weight = 700 - Underline = 0 'False - Italic = 0 'False - Strikethrough = 0 'False - EndProperty - Height = 300 - Left = 6075 - TabIndex = 6 - Tag = "Version" - Top = 2760 - Width = 930 - End - Begin VB.Label lblWarning - Caption = "Warning" - Height = 195 - Left = 300 - TabIndex = 3 - Tag = "Warning" - Top = 3720 - Width = 6855 - End - Begin VB.Label lblCompany - Caption = "Company" - Height = 255 - Left = 4710 - TabIndex = 5 - Tag = "Company" - Top = 3330 - Width = 2415 - End - Begin VB.Label lblCopyright - Caption = "Copyright" - Height = 255 - Left = 4710 - TabIndex = 4 - Tag = "Copyright" - Top = 3120 - Width = 2415 - End - End -End -Attribute VB_Name = "frmSplash" -Attribute VB_GlobalNameSpace = False -Attribute VB_Creatable = False -Attribute VB_PredeclaredId = True -Attribute VB_Exposed = False -Private Sub Form_Load() - lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision - lblProductName.Caption = App.Title -End Sub - diff --git a/ndb/src/cw/cpcd/Makefile.am b/ndb/src/cw/cpcd/Makefile.am index 6af44a359fc..75f557b2af7 100644 --- a/ndb/src/cw/cpcd/Makefile.am +++ b/ndb/src/cw/cpcd/Makefile.am @@ -16,3 +16,5 @@ ndb_cpcd_LDFLAGS = @ndb_bin_am_ldflags@ # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: diff --git a/ndb/src/cw/cpcd/Makefile_old b/ndb/src/cw/cpcd/Makefile_old deleted file mode 100644 index f214fb087d2..00000000000 --- a/ndb/src/cw/cpcd/Makefile_old +++ /dev/null @@ -1,11 +0,0 @@ -include .defs.mk - -TYPE := util -BIN_TARGET := ndb_cpcd - -# Source files of non-templated classes (.cpp files) -SOURCES = main.cpp CPCD.cpp Process.cpp APIService.cpp Monitor.cpp common.cpp - -BIN_TARGET_LIBS += logger - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/cw/cpcd/common.cpp b/ndb/src/cw/cpcd/common.cpp index cb1c0c37183..53c0e4d5a64 100644 --- a/ndb/src/cw/cpcd/common.cpp +++ b/ndb/src/cw/cpcd/common.cpp @@ -96,66 +96,3 @@ insert_file(const char * filename, class Properties& p){ if(f) fclose(f); return res; } - -int -parse_config_file(struct getargs args[], int num_arg, const Properties& p){ - Properties::Iterator it(&p); - for(const char * name = it.first(); name != 0; name = it.next()){ - bool found = false; - for(int i = 0; i<num_arg; i++){ - if(strcmp(name, args[i].long_name) != 0) - continue; - - found = true; - - const char * tmp; - p.get(name, &tmp); - - int t = 1; - - switch(args[i].type){ - case arg_integer:{ - int val = atoi(tmp); - if(args[i].value){ - *((int*)args[i].value) = val; - } - } - break; - case arg_string: - if(args[i].value){ - *((const char**)args[i].value) = tmp; - } - break; - case arg_negative_flag: - t = 0; - case arg_flag: - if(args[i].value){ - if(!strcasecmp(tmp, "y") || - !strcasecmp(tmp, "on") || - !strcasecmp(tmp, "true") || - !strcasecmp(tmp, "1")){ - *((int*)args[i].value) = t; - } - if(!strcasecmp(tmp, "n") || - !strcasecmp(tmp, "off") || - !strcasecmp(tmp, "false") || - !strcasecmp(tmp, "0")){ - *((int*)args[i].value) = t; - } - } - t = 1; - break; - case arg_strings: - case arg_double: - case arg_collect: - case arg_counter: - break; - } - } - if(!found) { - printf("Unknown parameter: %s\n", name); - return 1; - } - } - return 0; -} diff --git a/ndb/src/cw/cpcd/common.hpp b/ndb/src/cw/cpcd/common.hpp index c3d87b8b9f5..4f5f702762f 100644 --- a/ndb/src/cw/cpcd/common.hpp +++ b/ndb/src/cw/cpcd/common.hpp @@ -19,7 +19,9 @@ #include <ndb_global.h> #include <logger/Logger.hpp> +#if 0 #include <getarg.h> +#endif extern int debug; @@ -30,6 +32,5 @@ int insert(const char * pair, class Properties & p); int insert_file(const char * filename, class Properties&); int insert_file(FILE *, class Properties&, bool break_on_empty = false); -int parse_config_file(struct getargs args[], int num_arg, const Properties& p); #endif /* ! __CPCD_COMMON_HPP_INCLUDED__ */ diff --git a/ndb/src/cw/cpcd/main.cpp b/ndb/src/cw/cpcd/main.cpp index 207b81bfa89..25632f132e9 100644 --- a/ndb/src/cw/cpcd/main.cpp +++ b/ndb/src/cw/cpcd/main.cpp @@ -15,13 +15,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> /* Needed for mkdir(2) */ +#include <my_sys.h> +#include <my_getopt.h> +#include <mysql_version.h> +#include <ndb_version.h> #include "CPCD.hpp" #include "APIService.hpp" #include <NdbMain.h> #include <NdbSleep.h> #include <BaseString.hpp> -#include <getarg.h> #include <logger/Logger.hpp> #include <logger/FileLogHandler.hpp> #include <logger/SysLogHandler.hpp> @@ -29,28 +32,44 @@ #include "common.hpp" static const char *work_dir = CPCD_DEFAULT_WORK_DIR; -static int port = CPCD_DEFAULT_TCP_PORT; -static int use_syslog = 0; +static int port; +static int use_syslog; static const char *logfile = NULL; static const char *config_file = CPCD_DEFAULT_CONFIG_FILE; static const char *user = 0; -static struct getargs args[] = { - { "work-dir", 'w', arg_string, &work_dir, - "Work directory", "directory" }, - { "port", 'p', arg_integer, &port, - "TCP port to listen on", "port" }, - { "syslog", 'S', arg_flag, &use_syslog, - "Log events to syslog", NULL}, - { "logfile", 'L', arg_string, &logfile, - "File to log events to", "file"}, - { "debug", 'D', arg_flag, &debug, - "Enable debug mode", NULL}, - { "config", 'c', arg_string, &config_file, "Config file", NULL }, - { "user", 'u', arg_string, &user, "Run as user", NULL } +static struct my_option my_long_options[] = +{ + { "work-dir", 'w', "Work directory", + (gptr*) &work_dir, (gptr*) &work_dir, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "port", 'p', "TCP port to listen on", + (gptr*) &port, (gptr*) &port, 0, + GET_INT, REQUIRED_ARG, CPCD_DEFAULT_TCP_PORT, 0, 0, 0, 0, 0 }, + { "syslog", 'S', "Log events to syslog", + (gptr*) &use_syslog, (gptr*) &use_syslog, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "logfile", 'L', "File to log events to", + (gptr*) &logfile, (gptr*) &logfile, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "debug", 'D', "Enable debug mode", + (gptr*) &debug, (gptr*) &debug, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "config", 'c', "Config file", + (gptr*) &config_file, (gptr*) &config_file, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "user", 'u', "Run as user", + (gptr*) &user, (gptr*) &user, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static const int num_args = sizeof(args) / sizeof(args[0]); +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return 0; +} static CPCD * g_cpcd = 0; #if 0 @@ -59,23 +78,16 @@ extern "C" static void sig_child(int signo, siginfo_t*, void*); const char *progname = "ndb_cpcd"; -NDB_MAIN(ndb_cpcd){ - int optind = 0; - - if(getarg(args, num_args, argc, argv, &optind)) { - arg_printusage(args, num_args, progname, ""); - exit(1); - } - - Properties p; - insert_file(config_file, p); - if(parse_config_file(args, num_args, p)){ - ndbout_c("Invalid config file: %s", config_file); - exit(1); - } +int main(int argc, char** argv){ + int save_argc= argc; + char** save_argv= argv; + const char *load_default_groups[]= { "ndb_cpcd",0 }; + MY_INIT(argv[0]); - if(getarg(args, num_args, argc, argv, &optind)) { - arg_printusage(args, num_args, progname, ""); + load_defaults("ndb_cpcd",load_default_groups,&argc,&argv); + if (handle_options(&argc, &argv, my_long_options, get_one_option)) { + my_print_help(my_long_options); + my_print_variables(my_long_options); exit(1); } diff --git a/ndb/src/external/LINUX.x86/sci/include/list.h b/ndb/src/external/LINUX.x86/sci/include/list.h deleted file mode 100644 index 81c467a461b..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/list.h +++ /dev/null @@ -1,56 +0,0 @@ -/* $Id: list.h,v 1.1 2002/12/13 12:17:20 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _LIST_H -#define _LIST_H -#include "sci_types.h" - - -typedef struct ListElement *ListElement_t; -typedef struct List *List_t; - -struct ListElement { - void *element; - u_vkaddr_t key; - ListElement_t prev,next; -}; - -void *Get_Element(ListElement_t el); -void Set_Element(ListElement_t el,void *elptr,u_vkaddr_t key); -void Create_Element(ListElement_t *el); -void Destroy_Element(ListElement_t *el); -void Create_List(List_t *list); -void Destroy_List(List_t *list); -void Add_Element(List_t list,ListElement_t el); -void Remove_Element(List_t list,ListElement_t el); -ListElement_t Find_Element(List_t list,u_vkaddr_t key); -scibool List_Empty(List_t); -scibool List_Elements(List_t); -ListElement_t First_Element(List_t list); -ListElement_t Last_Element(List_t list); -ListElement_t Next_Element(ListElement_t el); - -#endif /* _LIST_H */ diff --git a/ndb/src/external/LINUX.x86/sci/include/os/inttypes.h b/ndb/src/external/LINUX.x86/sci/include/os/inttypes.h deleted file mode 100644 index b9e5a6cb19f..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/os/inttypes.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $Id: inttypes.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SCI_OS_INTTYPES_H_ -#define _SCI_OS_INTTYPES_H_ - -/* - * -------------------------------------------------------------------------------------- - * Basic types of various sizes. - * -------------------------------------------------------------------------------------- - */ -typedef unsigned char unsigned8; -typedef unsigned short unsigned16; -typedef unsigned int unsigned32; -typedef unsigned long long unsigned64; - -typedef signed char signed8; -typedef signed short signed16; -typedef signed int signed32; -typedef signed long long signed64; - - -#ifdef CPU_WORD_IS_64_BIT -typedef unsigned64 uptr_t; -typedef signed64 iptr_t; -#else -typedef unsigned32 uptr_t; -typedef signed32 iptr_t; -#endif - -#endif /* _SCI_OS_INTTYPES_H_ */ diff --git a/ndb/src/external/LINUX.x86/sci/include/rmlib.h b/ndb/src/external/LINUX.x86/sci/include/rmlib.h deleted file mode 100644 index 9d2722e9798..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/rmlib.h +++ /dev/null @@ -1,212 +0,0 @@ -/* $Id: rmlib.h,v 1.1 2002/12/13 12:17:20 hin Exp $ */ - -/********************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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. * - * * - * * - *********************************************************************************/ - -/********************************************************************************/ -/* This header file contains the declarations of the SCI Reflective Memory */ -/* library rmlib. The implementation of the library functions is in rmlib.c. */ -/* The library contains all the functions that operate on the reflective */ -/* memory. */ -/* */ -/* NB! */ -/* */ -/* DOLPHIN'S SCI REFLECTIVE MEMORY FILES ARE UNDER DEVELOPMENT AND MAY CHANGE. */ -/* PLEASE CONTACT DOLPHIN FOR FURTHER INFORMATION. */ -/* */ -/* */ -/********************************************************************************/ - -#include "sisci_error.h" -#include "sisci_api.h" -#include "sisci_demolib.h" -#include "sisci_types.h" - -unsigned int seqerr, syncseqerr; - -#ifndef _RMLIB_H -#define _RMLIB_H - - -#if defined(_REENTRANT) - -#define _RMLIB_EXPAND_NAME(name) _RMLIB_MT_ ## name - -#else - -#define _RMLIB_EXPAND_NAME(name) _RMLIB_ST_ ## name - -#endif - -#ifdef __sparc -#define CACHE_SIZE 2097152 -#else -#define CACHE_SIZE 8192 -#endif - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define REFLECT_ERRCHECK 0x2 - -struct ReflectiveMemorySpace { - unsigned int localAdapterNo; - unsigned int localNodeId; - unsigned int remoteNodeId; - sci_desc_t sd; - sci_desc_t syncsd; - sci_map_t localMap; - sci_map_t remoteMap; - unsigned int localSegmentId; - unsigned int remoteSegmentId; - unsigned int syncSegmentId; - unsigned int sync_rSegmentId; - unsigned int segmentSize; - unsigned int *localMapAddr; - volatile unsigned int *remoteMapAddr; - sci_local_segment_t localSegment; - sci_remote_segment_t remoteSegment; - sci_local_segment_t syncSegment; - sci_remote_segment_t sync_rSegment; - sci_map_t syncMap; - sci_map_t sync_rMap; - sci_sequence_t syncsequence; - sci_sequence_t sequence; - unsigned int protection; - unsigned int retry_value; - sci_sequence_status_t sequenceStatus, syncsequenceStatus; - volatile unsigned int *syncMapAddr; - volatile unsigned int *sync_rMapAddr; -}; - -/*********************************************************************************/ -/* P R I N T R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectPrintParameters _RMLIB_EXPAND_NAME(ReflectPrintParameters) -void ReflectPrintParameters(FILE *stream, struct ReflectiveMemorySpace RM_space); - -/*********************************************************************************/ -/* R E F L E C T D M A S E T U P */ -/* */ -/*********************************************************************************/ -#define ReflectDmaSetup _RMLIB_EXPAND_NAME(ReflectDmaSetup) -sci_error_t ReflectDmaSetup(struct ReflectiveMemorySpace RM_space, sci_dma_queue_t *dmaQueue); - -/*********************************************************************************/ -/* R E F L E C T D M A R E M O V E */ -/* */ -/*********************************************************************************/ -#define ReflectDmaRemove _RMLIB_EXPAND_NAME(ReflectDmaRemove) -sci_error_t ReflectDmaRemove(sci_dma_queue_t dmaQueue); - -/*********************************************************************************/ -/* R E F L E C T D M A R U N */ -/* */ -/*********************************************************************************/ -#define ReflectDmaRun _RMLIB_EXPAND_NAME(ReflectDmaRun) -sci_error_t ReflectDmaRun(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset, - sci_dma_queue_t dmaQueue); -/*********************************************************************************/ -/* C L O S E R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectClose _RMLIB_EXPAND_NAME(ReflectClose) -sci_error_t ReflectClose(struct ReflectiveMemorySpace RM_space, unsigned int segment_no); - -/*********************************************************************************/ -/* O P E N R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectOpen _RMLIB_EXPAND_NAME(ReflectOpen) -sci_error_t ReflectOpen(struct ReflectiveMemorySpace *RM_space, - unsigned int size, - unsigned int segment_no, - unsigned int localAdapterNo, - unsigned int remoteNodeId, - unsigned int protection, - unsigned int retry_value); - -/*********************************************************************************/ -/* R E F L E C T G E T A C C E S S */ -/* */ -/*********************************************************************************/ -#define ReflectGetAccess _RMLIB_EXPAND_NAME(ReflectGetAccess) -sci_error_t ReflectGetAccess(struct ReflectiveMemorySpace *RM_space); - -/*********************************************************************************/ -/* R E F L E C T R E L E A S E A C C E S S */ -/* */ -/*********************************************************************************/ -#define ReflectReleaseAccess _RMLIB_EXPAND_NAME(ReflectReleaseAccess) -sci_error_t ReflectReleaseAccess(struct ReflectiveMemorySpace *RM_space); - -/*********************************************************************************/ -/* R E F L E C T D M A */ -/* */ -/*********************************************************************************/ -#define ReflectDma _RMLIB_EXPAND_NAME(ReflectDma) -sci_error_t ReflectDma(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset); - -/*********************************************************************************/ -/* R E F L E C T M E M C O P Y */ -/* */ -/*********************************************************************************/ -#define ReflectMemCopy _RMLIB_EXPAND_NAME(ReflectMemCopy) -sci_error_t ReflectMemCopy(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset, - unsigned int flags); - -/*********************************************************************************/ -/* R E F L E C T S E T */ -/* */ -/*********************************************************************************/ -#define ReflectSet _RMLIB_EXPAND_NAME(ReflectSet) -sci_error_t ReflectSet(struct ReflectiveMemorySpace RM_space, - unsigned int value, - unsigned int size, - unsigned int offset, - unsigned int flags - ); - -/*********************************************************************************/ -/* R E F L E C T P R I N T */ -/* */ -/*********************************************************************************/ -#define ReflectPrint _RMLIB_EXPAND_NAME(ReflectPrint) -sci_error_t ReflectPrint(FILE *stream, - struct ReflectiveMemorySpace RM_space, - unsigned int size, - unsigned int offset - ); - - -#endif diff --git a/ndb/src/external/LINUX.x86/sci/include/sci_errno.h b/ndb/src/external/LINUX.x86/sci/include/sci_errno.h deleted file mode 100644 index 03f3256a86f..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sci_errno.h +++ /dev/null @@ -1,216 +0,0 @@ -/* $Id: sci_errno.h,v 1.1 2002/12/13 12:17:20 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SCI_ERRNO_H_ -#define _SCI_ERRNO_H_ - - -/* - * SCI Error return values always have 30 bit set - * Remote errors should have bit 0 set - */ -#define SCI_ERR_MASK 0x40000000 -#define ESCI_REMOTE_MASK 0x01000000 - -#define SCI_ERR(u) ((unsigned32)(u)&0x7FFFFFFF ) -#define _SCI_ERROR(x) ((x) | SCI_ERR_MASK) -#define _SCI_REMOTE_ERROR(x) ( _SCI_ERROR(x) | ESCI_REMOTE_MASK ) - -/* - * Error codes - */ -typedef enum { - ESCI_OK = 0x000, - ESCI_STILL_EXPORTED = _SCI_ERROR(0x800), - - ESCI_BUS_ERR = _SCI_ERROR(0x900), - ESCI_PEND_SCIERR = _SCI_ERROR(0x901), - ESCI_SCI_ERR = _SCI_ERROR(0x902), - - /* - * Specific SCI error responses: - */ - ESCI_SCI_ERR_DATA = _SCI_ERROR(0x9021), - ESCI_SCI_ERR_TYPE = _SCI_ERROR(0x9022), - ESCI_SCI_ERR_ADDR = _SCI_ERROR(0x9023), - - ESCI_LINK_TIMEOUT = _SCI_ERROR(0x903), - ESCI_EXDEV_TIMEOUT = _SCI_ERROR(0x904), - ESCI_REMOTE_ERR = _SCI_ERROR(0x905), - ESCI_MBX_BUSY = _SCI_ERROR(0x906), - ESCI_DMAERR = _SCI_ERROR(0x907), - ESCI_DMA_DISABLED = _SCI_ERROR(0x908), - ESCI_SW_MBX_SEND_FAILED = _SCI_ERROR(0x909), - ESCI_HW_MBX_SEND_FAILED = _SCI_ERROR(0x90A), - ESCI_HAS_NO_SESSION = _SCI_ERROR(0xA00), - ESCI_CONNREFUSED_SESSION = _SCI_ERROR(0xA01), - ESCI_SESSION_NOT_ESTABLISHED = _SCI_ERROR(0xA11), - ESCI_REMOTE_NO_VALID_SESSION = _SCI_ERROR(0xA02), - ESCI_SESSION_DISABLED = _SCI_ERROR(0xA03), - ESCI_NODE_CLOSED = _SCI_ERROR(0xA04), - ESCI_NODE_DISABLED = _SCI_ERROR(0xA05), - - ESCI_LOCAL_MASTER_ERR = _SCI_ERROR(0xA06), - ESCI_REMOTE_MASTER_ERR = _SCI_REMOTE_ERROR(0xA06), - - ESCI_ILLEGAL_CMD_RECEIVED = _SCI_ERROR(0xA08), - ESCI_ILLEGAL_CMD_SENT = _SCI_ERROR(0xA09), - - /* used above: ESCI_SESSION_NOT_ESTABLISHED = _SCI_ERROR(0xA11), */ - - /* - * Remote error codes - */ - ESCI_CONNREFUSED = _SCI_ERROR(0xB00), - ESCI_NODE_NOT_RESPONDING = _SCI_ERROR(0xB01), - ESCI_ISCONN = _SCI_ERROR(0xB02), - ESCI_HOSTUNREACH = _SCI_ERROR(0xB03), - ESCI_NO_SUCH_USER_ID = _SCI_ERROR(0xB04), - ESCI_REMOTE_NO_SUCH_USER_ID = _SCI_REMOTE_ERROR(0xB04), /* ESCI_NO_SUCH_USER_ID */ - ESCI_NO_SUCH_KEY = _SCI_ERROR(0xB04), /* ESCI_NO_SUCH_USER_ID */ - ESCI_REMOTE_NO_SUCH_KEY = _SCI_REMOTE_ERROR(0xB04), /* ESCI_REMOTE_NO_SUCH_USER_ID */ - ESCI_NODE_ERR = _SCI_ERROR(0xB06), - ESCI_REMOTE_NODE_ERR = _SCI_REMOTE_ERROR(0xB06), /* ESCI_NODE_ERR */ - ESCI_NOSPC = _SCI_ERROR(0xB08), - ESCI_REMOTE_NOSPC = _SCI_REMOTE_ERROR(0xB08), /* ESCI_NOSPC */ - ESCI_NODMASPC = _SCI_ERROR(0xB0A), - ESCI_REMOTE_NODMASPC = _SCI_REMOTE_ERROR(0xB0A), /* ESCI_NODMASPC */ - ESCI_NOTMAP = _SCI_ERROR(0xC00), - ESCI_ISMAP = _SCI_ERROR(0xC01), - ESCI_NOT_INITIALIZED = _SCI_ERROR(0xD00), - ESCI_REMOTE_NOT_INITIALIZED = _SCI_REMOTE_ERROR(ESCI_NOT_INITIALIZED), - /* - * ??? - */ - ESCI_PARAM_ERR = _SCI_ERROR(0xD01), - ESCI_NO_FREE_VC = _SCI_ERROR(0xD02), - ESCI_REMOTE_NO_FREE_VC = _SCI_REMOTE_ERROR(0xD02), /* ESCI_NO_FREE_VC */ - - /* - * Adapter state related error codes: - */ - ESCI_SUSPENDED = _SCI_ERROR(0xD03), - ESCI_NOT_SUSPENDED = _SCI_ERROR(0xD04), - ESCI_NOT_READY = _SCI_ERROR(0xD05), - ESCI_NOT_CONFIGURED = _SCI_ERROR(0xD06), - ESCI_INVALID_ADAPTERID = _SCI_ERROR(0xD07), /* if an adapter-id is out of range */ - ESCI_NONEXIST_ADAPTERID = _SCI_ERROR(0xD08), /* if adapter-id is valid but no adapter matches */ - ESCI_ADAPTERID_INUSE = _SCI_ERROR(0xD09), - - ESCI_INVALID_INSTANCE = _SCI_ERROR(0xD0A), - ESCI_NONEXIST_INSTANCE = _SCI_ERROR(0xD0B), - - ESCI_ADAPTER_INIT_FAILURE = _SCI_ERROR(0xD0C), - - ESCI_PAUSED = _SCI_ERROR(0xD0D), - ESCI_NOT_PAUSED = _SCI_ERROR(0xD0E), - ESCI_ADAPTER_NEED_RESET = _SCI_ERROR(0xD0F), - - ESCI_NONEXIST_SERIAL_NUMBER = _SCI_ERROR(0xD10), - ESCI_NOT_AVAILABLE = _SCI_ERROR(0xD11), - - ESCI_EACCESS = _SCI_ERROR(0xD12), - - /* - * Local error codes - */ - ESCI_NO_LOCAL_ACCESS = _SCI_ERROR(0xE00), - ESCI_LRESOURCE_BUSY = _SCI_ERROR(0xE01), - ESCI_LRESOURCE_EXIST = _SCI_ERROR(0xE02), - ESCI_NO_LRESOURCE = _SCI_ERROR(0xE03), - ESCI_NOTCONN = _SCI_ERROR(0xE04), - ESCI_LOCAL_ERR = _SCI_ERROR(0xE05), - ESCI_NOVAL_NODEID = _SCI_ERROR(0xE06), - ESCI_NOT_SUPPORTED = _SCI_ERROR(0xE07), - ESCI_TIMEOUT = _SCI_ERROR(0xE08), - ESCI_NO_LOCAL_LC_ACCESS = _SCI_ERROR(0xE0A), - ESCI_INVALID_ATT = _SCI_ERROR(0xE0B), - ESCI_BAD_CHECKSUM = _SCI_ERROR(0xE0C), - ESCI_INTERRUPT_FLAG_DISABLED = _SCI_ERROR(0xE0D), - ESCI_COND_INT_RACE_PROBLEM = _SCI_ERROR(0xE0E), - ESCI_OVERFLOW = _SCI_ERROR(0xE0F), - ESCI_BLINK_PARITY_ERROR = _SCI_ERROR(0xE10), - ESCI_FIRMWARE_VERSION_MISMATCH = _SCI_ERROR(0xE11), - - /* - * Link error codes - */ - ESCI_NO_LINK_ACCESS = _SCI_ERROR(0xF00), - ESCI_NO_REMOTE_LINK_ACCESS = _SCI_REMOTE_ERROR(0xF00), /* ESCI_NO_LINK_ACCESS */ - - ESCI_NO_SUCH_NODE = _SCI_ERROR(0xF02), - ESCI_USR_ACCESS_DISABLED = _SCI_ERROR(0xF03), - ESCI_HW_AVOID_DEADLOCK = _SCI_ERROR(0xF04), - ESCI_POTENTIAL_ERROR = _SCI_ERROR(0xF05), - - ESCI_FENCED = _SCI_ERROR(0xF06), - ESCI_SWITCH_HW_FAILURE = _SCI_ERROR(0xF07), - ESCI_SWITCH_WRONG_BLINK_ID = _SCI_ERROR(0xF08), - ESCI_SWITCH_WRONG_PORT_NUMB = _SCI_ERROR(0xF09), - ESCI_SWITCH_WRONG_INIT_TYPE = _SCI_ERROR(0xF0A), /* It is determined that the swith initialization - * do not match the local adapter initialization - */ - ESCI_SWITCH_WRONG_SWITCH_NUMB = _SCI_ERROR(0xF0B), /* It is determined that we are operationg on the - * wrong switch port - */ - ESCI_SWITCH_NOT_CONNECTED = _SCI_ERROR(0xF0C), - ESCI_SWITCH_NOT_RECOGNIZED = _SCI_ERROR(0xF0D), - ESCI_SWITCH_INIT_IN_PROGRESS = _SCI_ERROR(0xF0E), /* Switch TINI initialization in progress */ - - - ESCI_NO_BACKBONE_LINK_ACCESS = _SCI_ERROR(0xF20), - ESCI_BACKBONE_FENCED = _SCI_ERROR(0xF21), - ESCI_NO_BACKBONE_ACCESS = _SCI_ERROR(0xF22), - ESCI_BACKBONE_CABLE_PROBLEM = _SCI_ERROR(0xF23), - ESCI_BACKBONE_BLINK_PROBLEM = _SCI_ERROR(0xF24), - ESCI_BACKBONE_HWINIT_PROBLEM = _SCI_ERROR(0xF25), - ESCI_BACKBONE_ID_PROBLEM = _SCI_ERROR(0xF26), - ESCI_BACKBONE_STATE_PROBLEM = _SCI_ERROR(0xF27), - ESCI_BACKBONE_REQ_LINK_PROBLEM = _SCI_ERROR(0xF28), - ESCI_BACKBONE_UNFENCING = _SCI_ERROR(0xF29), /* Unfencing in progress */ - - /* - * added for pci port - */ - ESCI_AGAIN = _SCI_ERROR(0xF15), - ESCI_ORANGE = _SCI_ERROR(0xF16), /* Out of range */ - ESCI_NOSYS = _SCI_ERROR(0xF17), /* Used instead of ENOSYS. Means function not implemented */ - ESCI_REMOTE_NOSYS = _SCI_REMOTE_ERROR(ESCI_NOSYS), - ESCI_INTR = _SCI_ERROR(0xF18), /* Used instead of EINTR from sys/errno.h */ - ESCI_IO = _SCI_ERROR(0xF19), /* Used instead of EIO from sys/errno.h */ - ESCI_FAULT = _SCI_ERROR(0xF1A), /* Used instead of EFAULT from sys/errno.h */ - ESCI_BUSY = _SCI_ERROR(0xF1B), /* Used instead of EBUST from sys/errno.h */ - ESCI_INVAL = _SCI_ERROR(0xF1C), /* Used instead of EINVAL from sys/errno.h */ - ESCI_NXIO = _SCI_ERROR(0xF1D), /* Used instead of ENXIO from sys/errno.h */ - ESCI_EXIST = _SCI_ERROR(0xF1E) /* Used instead of EEXIST from sys/errno.h */ - -} scierror_t; - -#endif /* _SCI_ERRNO_H_ */ - - - - diff --git a/ndb/src/external/LINUX.x86/sci/include/sci_types.h b/ndb/src/external/LINUX.x86/sci/include/sci_types.h deleted file mode 100644 index 740b3a45cfd..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sci_types.h +++ /dev/null @@ -1,300 +0,0 @@ -/* $Id: sci_types.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SCI_TYPES_H_ -#define _SCI_TYPES_H_ - -/* - * Remains for the time being for backward compatibility .... - */ - -/* #define UNIQUE(type) struct { type x; } * */ -#ifndef UNIQUE -#define UNIQUE(type) type -#endif -#include "os/inttypes.h" - -#if defined(WIN32) -#if defined(_KERNEL) -#include <ntddk.h> -#else -#include <WTYPES.H> -#endif /* _KERNEL */ -#else -#if defined(Linux) -#if defined(__KERNEL__) -#include <linux/types.h> -#else -#include <sys/types.h> -#endif -#else -#include <sys/types.h> -#endif -#ifdef SUNOS5 -#include <sys/ddi.h> -#include <sys/sunddi.h> -#endif -#ifdef OS_IS_TRU64 -#include <io/common/devdriver.h> -#endif -#ifdef OS_IS_HP_UX11 -#if defined(_KERNEL) -#include <../wsio/wsio.h> -#else -#include <sys/wsio.h> -#endif -#endif -#endif - -/* See comments about "UNCONFIGURED_ADAPTERS" in config.h */ -#define UNCONFIGURED_ADAPTERS 100 - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef IN -#define IN -#endif - -#ifndef NOT -#define NOT ! -#endif - -/* - * -------------------------------------------------------------------------------------- - * Basic types of various sizes. - * -------------------------------------------------------------------------------------- - */ - -typedef signed32 scibool; -#ifndef OS_IS_VXWORKS -typedef signed32 BOOL; -#else -/* VXWORKS has already defined BOOL */ -#endif -typedef unsigned32 node_t; /* This is the logical nodeid */ -typedef unsigned32 sciNodeId_t; /* This is the physical 16 bit SCI nodeid */ - -/* - * -------------------------------------------------------------------------------------- - * Various register types. - * -------------------------------------------------------------------------------------- - */ -typedef volatile unsigned32 register32; - - -/* -Temporary for Windows NT, until we use only the above types. -*/ - -#ifdef WIN32 - -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned long u_long; -typedef unsigned int u_int; -typedef char * caddr_t; - -typedef long off_t; -typedef unsigned int size_t; - -#endif -#ifdef OS_IS_VXWORKS -#include <vxWorks.h> -#endif - -/* - * -------------------------------------------------------------------------------------- - * Various address types. - * - * We are using a struct * instead of unsigned long (int) inorder to enforce strong - * type checking - * - * -------------------------------------------------------------------------------------- - */ -typedef UNIQUE(void *) vkaddr_t; /* Virtual kernel address */ -typedef UNIQUE(uptr_t) vuaddr_t; /* Virtual user address */ - -typedef UNIQUE(unsigned32) remaddr_t; /* Remote IO address (physical address on PCs) */ -typedef UNIQUE(unsigned32) sciofs_lo_t; /* Lower 32 bits of an SCI offset. */ -typedef UNIQUE(unsigned32) sciofs_hi_t; /* The upper 16 bits of an SCI offset. */ - -typedef UNIQUE(unsigned32) ioaddr_t; /* Local IO address (physical address on PCs) */ -typedef unsigned32 u_ioaddr_t; -typedef unsigned32 iooffset_t; -typedef unsigned32 iosize_t; - -typedef uptr_t vkoffset_t; -typedef uptr_t u_vkaddr_t; -typedef uptr_t u_vuaddr_t; -typedef unsigned32 u_sciofs_lo_t; -typedef unsigned32 u_sciofs_hi_t; -typedef unsigned32 u_remaddr_t; -typedef unsigned32 attOffset_t; /* Address displacement from start of ATT entry */ - -typedef unsigned32 adapterNo_t; - -typedef enum { - NO_NODE = 0, - AD_MEM_NODE = 1, - AD_ALT_NODE = 2, - AD_MBX_NODE = 3, - AD_LC_NODE = 4, - AD_LC_PORT_0 = 5, - AD_LC_PORT_1 = 6, - AD_LC_PORT_2 = 7, - PHYS_NODE = 8 -} node_type_t; - - -/* - * Currently we don't support more than 32 bit sizes. - */ -#define SIZEOF(x) ((unsigned32)sizeof(x)) - -#if defined(_KERNEL) - -/* - * -------------------------------------------------------------------------------------- - * Some small macros intended to ease the transition to more strongly typed address - * types. The intention is that they in the long run shall be removed ... - * -------------------------------------------------------------------------------------- - */ -#define P2SIZE_T(x) ((size_t)((uptr_t)(x))) /* Pointer to size_t */ -#define P2U32(x) ((unsigned32)((uptr_t)(x))) /* Pointer to Unsigned 32-bit int */ -#ifdef WIN32 -#define PHADDR(x) ((ioaddr_t)(x)) -#define HASV(x) (x) -#endif -#if 0 -static vkaddr_t VKPTR (void * ptr) { return (vkaddr_t)ptr; } -static vkaddr_t VKADDR(volatile void * ptr) { return (vkaddr_t)ptr; } -#else -#define VKPTR(ptr) (vkaddr_t)ptr -#define VKADDR(ptr) (vkaddr_t)ptr -#endif - -#ifdef KLOG -#define KLOG_LOG(n,m,v) ts_log((n),(m),(v)) -#else -#define KLOG_LOG(n,m,v) -#endif /* KLOG */ - - -/* - * -------------------------------------------------------------------------------------- - * - * M E M A R E A T - * - * Memory area descriptor. - * - * paddr -- Physical address (aligned) of memory area - * ual_vaddr -- (Kernel )Virtual address of the unaligned memory area - * vaddr -- (Kernel) Virtual address of memory area - * rsize -- Real (Physical) Size of memory area - * msize -- Mapped (Virtual) Size of memory area (Size of area mapped - * into virtual) memory - * - * -------------------------------------- - * | | <----- msize ----->| | - * |<------|------- rsize ------|------>| - * -------------------------------------- - * /|\ /|\ - * | | - * ual_vaddr vaddr/paddr - * - * -------------------------------------------------------------------------------------- - */ -struct _memarea_ { - ioaddr_t ioaddr; - vkaddr_t vaddr; - vkaddr_t ual_vaddr; - size_t rsize; - size_t msize; - char *id; - unsigned32 cookie; - - -#ifdef SUNOS5 -#ifdef _USE_NEW_SOLARIS_DDI_INTERFACE - ddi_acc_handle_t mem_handle; - ddi_dma_handle_t dma_handle; -#else - ddi_dma_handle_t handle; -#endif -#endif -#ifdef OS_IS_TRU64 - dma_handle_t dma_handle; -#endif - -#if OS_IS_LINUX - unsigned long ph_base_addr; -#endif - -#ifdef OS_IS_HP_UX11 - struct isc_table_type * isc; - wsio_shmem_attr_t type; -#endif -}; - -typedef struct _memarea_ memarea_t; - -#ifdef SCI_MALLOC_DEBUG -struct _maddr_ { - char *id; - size_t size; - struct _maddr_ *next; - struct _maddr_ **prev; - unsigned32 cookie; -}; - -typedef struct _maddr_ maddr_t; - -#define MALLOC_COOKIE 0xc3c3c3c3 - -#else - -typedef struct { void *p; } *maddr_t; - -#endif /* SCI_MALLOC_DEBUG */ - - -typedef struct { - scibool disabled; - unsigned32 disable_cnt; -} disable_info_t; - -#endif /* _KERNEL */ - -#endif /* _SCI_TYPES_H_ */ diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_api.h b/ndb/src/external/LINUX.x86/sci/include/sisci_api.h deleted file mode 100644 index 38fdf54125f..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_api.h +++ /dev/null @@ -1,2170 +0,0 @@ -/* $Id: sisci_api.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ -/******************************************************************************* - * * - * Copyright (C) 1993 - 2001 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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 _SISCI_API_H -#define _SISCI_API_H - -#include "sisci_types.h" -#include "sisci_error.h" - - -#ifdef WIN32 -#ifdef API_DLL -#define DLL __declspec(dllexport) -#elif CLIENT_DLL -#define DLL __declspec(dllimport) -#endif -#endif /* WIN32 */ - - -#ifndef DLL -#define DLL -#endif - -#if defined(_REENTRANT) -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_MT_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_MT_ ## name -#else -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_ST_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_ST_ ## name -#endif -#define _SISCI_EXPANDE_CONSTANT_NAME(name) _SISCI_PUBLIC_CONST_ ## name - -#if defined(CPLUSPLUS) || defined(__cplusplus) -extern "C" { -#endif - - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define SCI_FLAG_FIXED_INTNO _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_INTNO) -extern const unsigned int SCI_FLAG_FIXED_INTNO; - -#define SCI_FLAG_SHARED_INT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_INT) -extern const unsigned int SCI_FLAG_SHARED_INT; - -#define SCI_FLAG_FIXED_MAP_ADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_MAP_ADDR) -extern const unsigned int SCI_FLAG_FIXED_MAP_ADDR; - -#define SCI_FLAG_READONLY_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READONLY_MAP) -extern const unsigned int SCI_FLAG_READONLY_MAP; - -#define SCI_FLAG_USE_CALLBACK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_USE_CALLBACK) -extern const unsigned int SCI_FLAG_USE_CALLBACK; - -#define SCI_FLAG_BLOCK_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_BLOCK_READ) -extern const unsigned int SCI_FLAG_BLOCK_READ; - -#define SCI_FLAG_THREAD_SAFE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_THREAD_SAFE) -extern const unsigned int SCI_FLAG_THREAD_SAFE; - -#define SCI_FLAG_ASYNCHRONOUS_CONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ASYNCHRONOUS_CONNECT) -extern const unsigned int SCI_FLAG_ASYNCHRONOUS_CONNECT; - -#define SCI_FLAG_EMPTY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_EMPTY) -extern const unsigned int SCI_FLAG_EMPTY; - -#define SCI_FLAG_PRIVATE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_PRIVATE) -extern const unsigned int SCI_FLAG_PRIVATE; - -#define SCI_FLAG_FORCE_DISCONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FORCE_DISCONNECT) -extern const unsigned int SCI_FLAG_FORCE_DISCONNECT; - -#define SCI_FLAG_NOTIFY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NOTIFY) -extern const unsigned int SCI_FLAG_NOTIFY; - -#define SCI_FLAG_DMA_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_READ) -extern const unsigned int SCI_FLAG_DMA_READ; - -#define SCI_FLAG_DMA_POST _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_POST) -extern const unsigned int SCI_FLAG_DMA_POST; - -#define SCI_FLAG_DMA_WAIT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_WAIT) -extern const unsigned int SCI_FLAG_DMA_WAIT; - -#define SCI_FLAG_DMA_RESET _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_RESET) -extern const unsigned int SCI_FLAG_DMA_RESET; - -#define SCI_FLAG_NO_FLUSH _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_FLUSH) -extern const unsigned int SCI_FLAG_NO_FLUSH; - -#define SCI_FLAG_NO_STORE_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_STORE_BARRIER) -extern const unsigned int SCI_FLAG_NO_STORE_BARRIER; - -#define SCI_FLAG_FAST_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FAST_BARRIER) -extern const unsigned int SCI_FLAG_FAST_BARRIER; - -#define SCI_FLAG_ERROR_CHECK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ERROR_CHECK) -extern const unsigned int SCI_FLAG_ERROR_CHECK; - -#define SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) -extern const unsigned int SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY; - -/* the FLUSH_CPU_BUFFERS_ONLY flag is for backwards compabillity only and should never be used */ -#define FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) - -#define SCI_FLAG_LOCK_OPERATION _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_LOCK_OPERATION) -extern const unsigned int SCI_FLAG_LOCK_OPERATION; - -#define SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP; - -#define SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP; - -#define SCI_FLAG_IO_MAP_IOSPACE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_IO_MAP_IOSPACE) -extern const unsigned int SCI_FLAG_IO_MAP_IOSPACE; - -#define SCI_FLAG_DMOVE_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMOVE_MAP) -extern const unsigned int SCI_FLAG_DMOVE_MAP; - -#define SCI_FLAG_WRITES_DISABLE_GATHER_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_WRITES_DISABLE_GATHER_MAP) -extern const unsigned int SCI_FLAG_WRITES_DISABLE_GATHER_MAP; - -#define SCI_FLAG_DISABLE_128_BYTES_PACKETS _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DISABLE_128_BYTES_PACKETS) -extern const unsigned int SCI_FLAG_DISABLE_128_BYTES_PACKETS; - -#define SCI_FLAG_SHARED_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_MAP) -extern const unsigned int SCI_FLAG_SHARED_MAP; - -#define SCI_FLAG_DMA_SOURCE_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_SOURCE_ONLY) -extern const unsigned int SCI_FLAG_DMA_SOURCE_ONLY; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT_MAP; - -#define SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP; - -#define SCI_FLAG_NO_MEMORY_LOOPBACK_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_MEMORY_LOOPBACK_MAP) -extern const unsigned int SCI_FLAG_NO_MEMORY_LOOPBACK_MAP; - -#if defined(OS_IS_LYNXOS) || defined(OS_IS_VXWORKS) -#define SCI_FLAG_WRITE_BACK_CACHE_MAP _SISCI_EXPANDE_CONSTANT_NAME(WRITE_BACK_CACHE_MAP) -extern const unsigned int SCI_FLAG_WRITE_BACK_CACHE_MAP; -#endif - -#define SCI_FLAG_DMA_PHDMA _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_PHDMA) -extern const unsigned int SCI_FLAG_DMA_PHDMA; - -/*********************************************************************************/ -/* GENERAL VALUES */ -/*********************************************************************************/ -#define SCI_LOCAL_HOST _SISCI_EXPANDE_CONSTANT_NAME(SCI_LOCAL_HOST) -extern const unsigned int SCI_LOCAL_HOST; - -#define SCI_INFINITE_TIMEOUT _SISCI_EXPANDE_CONSTANT_NAME(SCI_INFINITE_TIMEOUT) -extern const unsigned int SCI_INFINITE_TIMEOUT; - -/*********************************************************************************/ -/* GENERAL ERROR CODES */ -/* */ -/* SCI_ERR_ILLEGAL_FLAG - Illegal flag value. */ -/* SCI_ERR_FLAG_NOT_IMPLEMENTED - Flag legal but flag feature not implemented. */ -/* SCI_ERR_NOT_IMPLEMENTED - Function not implemented. */ -/* SCI_ERR_SYSTEM - A system error. Check errno. */ -/* SCI_ERR_NOSPC - Unable to allocate OS resources. */ -/* SCI_ERR_API_NOSPC - Unable to allocate API resources. */ -/* SCI_ERR_HW_NOSPC - Unable to allocate HW resources (Hardware) */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "ADAPTER" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_ADAPTERNO - Adapter number is legal but does not exist. */ -/* SCI_ERR_ILLEGAL_ADAPTERNO - Illegal local adapter number (i.e. outside */ -/* legal range). */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "NODEID" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_NODEID - The remote adapter identified by nodeId does */ -/* not respond, but the intermediate link(s) */ -/* seem(s) to be operational. */ -/* SCI_ERR_ILLEGAL_NODEID - Illegal NodeId. */ -/* */ -/*********************************************************************************/ - - - -/********************************************************************************* - * * - * S C I I N I T I A L I Z E * - * * - * This function initializes the SISCI library. * - * The function must be called before SCIOpen(). * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCIInitialize _SISCI_EXPANDE_FUNCTION_NAME(SCIInitialize) -DLL void SCIInitialize(unsigned int flags, - sci_error_t *error); -#if 0 -unsigned int __Internal_SISCI_version_var; -#endif - -/********************************************************************************* - * * - * S C I T E R M I N A T E * - * * - * This function terminates the SISCI library. * - * The function must be called after SCIClose(). * - * * - * * - *********************************************************************************/ -#define SCITerminate _SISCI_EXPANDE_FUNCTION_NAME(SCITerminate) -DLL void SCITerminate(void); - -/********************************************************************************* - * * - * S C I O P E N * - * * - * * - * Opens a SCI virtual device. * - * Caller must supply a pointer to a variable of type sci_desc_t to be * - * initialized. * - * * - * Flags * - * SCI_FLAG_THREAD_SAFE - Operations on resources associated with this * - * descriptor will be performed in a multithread-safe * - * manner. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INCONSISTENT_VERSIONS - Inconsistency between the SISCI library * - * and the SISCI driver versions. * - * * - * * - *********************************************************************************/ -#define SCIOpen _SISCI_EXPANDE_FUNCTION_NAME(SCIOpen) -DLL void SCIOpen(sci_desc_t *sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C L O S E * - * * - * This function closes an open SCI virtual device. * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - All resources are not deallocated. * - * * - *********************************************************************************/ -#define SCIClose _SISCI_EXPANDE_FUNCTION_NAME(SCIClose) -DLL void SCIClose(sci_desc_t sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S E G M E N T * - * * - * Connects to a remote shared memory segment located at <nodeId> with the * - * identifier <segmentId>. * - * The user may then call SCIMapRemoteSegment() to map shared memory * - * into user space. * - * * - * Flags * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_ASYNCHRONOUS_CONNECT * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_SEGMENT - Could not find the remote segment with the * - * given segmentId. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIConnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSegment) -DLL void SCIConnectSegment(sci_desc_t sd, - sci_remote_segment_t *segment, - unsigned int nodeId, - unsigned int segmentId, - unsigned int localAdapterNo, - sci_cb_remote_segment_t callback, - void *callbackArg, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T S E G M E N T * - * * - * Disconnects from the give mapped shared memory segment * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The segment is currently mapped or in use. * - * * - *********************************************************************************/ -#define SCIDisconnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectSegment) -DLL void SCIDisconnectSegment(sci_remote_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T R E M O T E S E G M E N T S I Z E * - * * - *********************************************************************************/ -#define SCIGetRemoteSegmentSize _SISCI_EXPANDE_FUNCTION_NAME(SCIGetRemoteSegmentSize) -DLL unsigned int SCIGetRemoteSegmentSize(sci_remote_segment_t segment); - - - -/********************************************************************************* - * * - * S C I W A I T F O R R E M O T E S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du * - * to a SCIDisconnectSegment() on the same * - * handle. The handle is invalid when this * - * error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForRemoteSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForRemoteSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForRemoteSegmentEvent( - sci_remote_segment_t segment, - sci_error_t *status, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P R E M O T E S E G M E N T * - * * - * This function is used to include a shared memory segment in the virtual * - * address space of the application. * - * * - * Flags: * - * * - * SCI_FLAG_SHARED_MAP - The low level physical map may be shared by * - * other applications. * - * * - * SCI_FLAG_FIXED_MAP_ADDR - Map at the suggested virtual address * - * SCI_FLAG_READONLY_MAP - The segment is mapped in read-only mode * - * SCI_FLAG_LOCK_OPERATION - Enable Lock operations (fetch and add) * - * SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP * - * - Enable aggressive prefetch with speculative * - * hold. * - * * - * SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP * - * - The PSB66 will prefetch 64 bytes. As soon * - * as the PCI read retry has been accepted, * - * the stream will change state to FREE, even * - * if less than 64 bytes were actually read. * - * * - * SCI_FLAG_IO_MAP_IOSPACE - Enable No Prefetch, no speculative hold. * - * * - * SCI_FLAG_DMOVE_MAP - Enable DMOVE packet type. The stream will be * - * set into FREE state immediately. * - * * - * SCI_FLAG_WRITES_DISABLE_GATHER_MAP * - * - Disable use of gather. * - * * - * SCI_FLAG_DISABLE_128_BYTES_PACKETS * - * - Disable use of 128-Byte packets * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an atomic "fetch-and-add-one" operation on * - * remote memory, but in addition an interrupt * - * will be generated if the target memory * - * location contained a "null value" before the * - * add operation was carried out. * - * The conditional interrupt flag must also be * - * specified in the SCIRegisterInterruptFlag() * - * function. * - * * - * SCI_FLAG_UNCONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an interrupt for the remote adapter * - * "in addition to" updating the corresponding * - * remote memory location with the data being * - * written. * - * The unconditional interrupt flag must also * - * be specified in the * - * SCIRegisterInterruptFlag() function. * - * * - * SCI_FLAG_WRITE_BACK_CACHE_MAP * - * - Enable cacheing of the mapped region. * - * Writes through this map will be written to a * - * write back cache, hence no remote SCI updates* - * until the cache line is flushed. The * - * application is responsible for the cache * - * flush operation. * - * The SCImemCopy() function will handle this * - * correctly by doing cache flushes internally. * - * This feature is architechture dependent and * - * not be available on all plattforms. * - * * - * SCI_FLAG_NO_MEMORY_LOOPBACK_MAP * - * - Forces a map to a remote segment located * - * in the local machine to be mapped using * - * SCI loopback. This is useful i.e. if you * - * want to use a regular map access to be * - * serialized with lock operations. * - * The default behaviour is to access a remte * - * segment located in the local machine as a * - * local MMU operation. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapRemoteSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapRemoteSegment) -DLL volatile void *SCIMapRemoteSegment( - sci_remote_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P L O C A L S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_FIXED_MAP_ADDR * - * SCI_FLAG_READONLY_MAP * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapLocalSegment) -DLL void *SCIMapLocalSegment(sci_local_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I U N M A P S E G M E N T * - * * - * This function unmaps pages of shared memory from the callers virtual * - * address space. * - * * - * Flags * - * None. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The map is currently in use. * - * * - *********************************************************************************/ -#define SCIUnmapSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIUnmapSegment) -DLL void SCIUnmapSegment(sci_map_t map, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E S E G M E N T * - * * - * Make the specified segment available for connections via the specified * - * adapter. If successful, the segment can be accessed from remote nodes * - * via the specified adapter. * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events * - * on this segment. * - * SCI_FLAG_EMPTY - No memory will be allocated for the segment. * - * SCI_FLAG_PRIVATE - The segment will be private meaning it will never * - * be any connections to it. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SEGMENTID_USED - The segment with this segmentId is already used * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * * - *********************************************************************************/ -#define SCICreateSegment _SISCI_EXPANDE_FUNCTION_NAME(SCICreateSegment) -DLL void SCICreateSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I W A I T F O R L O C A L S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du to a * - * SCIRemoveSegment() on the same handle. * - * The handle is invalid when this error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForLocalSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForLocalSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForLocalSegmentEvent( - sci_local_segment_t segment, - unsigned int *sourcenodeId, - unsigned int *localAdapterNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P R E P A R E S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_DMA_SOURCE_ONLY - The segment will be used as a source segment * - * for DMA operations. On some system types this * - * will enable the SISCI driver to use performance * - * improving features. * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIPrepareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIPrepareSegment) -DLL void SCIPrepareSegment(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E G M E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - Unable to remove the segment. The segment is currently * - * in use. * - * * - *********************************************************************************/ -#define SCIRemoveSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSegment) -DLL void SCIRemoveSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T A V A I L A B L E * - * * - * Flags * - * None. * - * * - * * - * SCI_ERR_SEGMENT_NOT_PREPARED - The segment has not been prepared for access * - * from this adapter. * - * SCI_ERR_ILLEGAL_OPERATION - The segment is created with the * - * SCI_FLAG_PRIVATE flag specified and * - * therefore has no segmentId. * - * * - *********************************************************************************/ -#define SCISetSegmentAvailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentAvailable) -DLL void SCISetSegmentAvailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T U N A V A I L A B L E * - * * - * Flags * - * * - * SCI_FLAG_FORCE_DISCONNECT * - * SCI_FLAG_NOTIFY * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * * - *********************************************************************************/ -#define SCISetSegmentUnavailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentUnavailable) -DLL void SCISetSegmentUnavailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E M A P S E Q U E N C E * - * * - * Flags: * - * * - * SCI_FLAG_FAST_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateMapSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICreateMapSequence) -DLL void SCICreateMapSequence(sci_map_t map, - sci_sequence_t *sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E Q U E N C E * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSequence) -DLL void SCIRemoveSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T A R T S E Q U E N C E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIStartSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIStartSequence) -DLL sci_sequence_status_t SCIStartSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I C H E C K S E Q U E N CE * - * * - * Flags * - * * - * SCI_FLAG_NO_FLUSH * - * SCI_FLAG_NO_STORE_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICheckSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICheckSequence) -DLL sci_sequence_status_t SCICheckSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T O R E B A R R I E R * - * * - * Flags * - * None. * - * * - * * - * * - *********************************************************************************/ -#define SCIStoreBarrier _SISCI_EXPANDE_FUNCTION_NAME(SCIStoreBarrier) -DLL void SCIStoreBarrier(sci_sequence_t sequence, - unsigned int flags); - - - - -/********************************************************************************* - * * - * S C I F L U S H R E A D B U F F E R S * - * * - *********************************************************************************/ -#define SCIFlushReadBuffers _SISCI_EXPANDE_FUNCTION_NAME(SCIFlushReadBuffers) -DLL void SCIFlushReadBuffers(sci_sequence_t sequence); - - - - -/********************************************************************************* - * * - * S C I P R O B E N O D E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIProbeNode _SISCI_EXPANDE_FUNCTION_NAME(SCIProbeNode) -DLL int SCIProbeNode(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int nodeId, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIGetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCIGetCSRRegister) -DLL unsigned int SCIGetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCISetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCISetCSRRegister) -DLL void SCISetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I G E T L O C A L C S R * - * * - * SISCI Priveleged function * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIGetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCIGetLocalCSR) -DLL unsigned int SCIGetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T L O C A L C S R * - * * - * SISCI Priveleged function - * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCISetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCISetLocalCSR) -DLL void SCISetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A T T A C H P H Y S I C A L M E M O R Y * - * * - * SISCI Priveleged function * - * * - * Description: * - * * - * This function enables usage of physical devices and memory regions where the * - * Physical PCI bus address ( and mapped CPU address ) are already known. * - * The function will register the physical memory as a SISCI segment which can * - * be connected and mapped as a regular SISCI segment. * - * * - * Requirements: * - * * - * SCICreateSegment() with flag SCI_FLAG_EMPTY must have been called in advance * - * * - * Parameter description: * - * sci_ioaddr_t ioaddress : This is the address on the PCI bus that a PCI bus * - * master has to use to write to the specified memory * - * void * address : This is the (mapped) virtual address that the * - * application has to use to access the device. * - * This means that the device has to be mapped in * - * advance bye the devices own driver. * - * If the device is not to be accessed by the local * - * CPU, the address pointer shold be set to NULL * - * Flags * - * * - * None * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIAttachPhysicalMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachPhysicalMemory) -DLL void SCIAttachPhysicalMemory(sci_ioaddr_t ioaddress, - void *address, - unsigned int busNo, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I Q U E R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_QUERY - Unrecognized command. * - * * - *********************************************************************************/ -#define SCIQuery _SISCI_EXPANDE_FUNCTION_NAME(SCIQuery) -DLL void SCIQuery(unsigned int command, - void *data, - unsigned int flags, - sci_error_t *error); - - -/* MAJOR QUERY COMMANDS */ - -/* This command requires a pointer to a structure of type */ -/* "sci_query_string". The string will be filled in by the query. */ -#define SCI_Q_VENDORID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_VENDORID) -extern const unsigned int SCI_Q_VENDORID; - - -/* Same as for SCI_VENDOR_ID */ -#define SCI_Q_API _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_API) -extern const unsigned int SCI_Q_API; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_adapter" struct. */ -#define SCI_Q_ADAPTER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER) -extern const unsigned int SCI_Q_ADAPTER; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_system" struct. */ -#define SCI_Q_SYSTEM _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM) -extern const unsigned int SCI_Q_SYSTEM; - -#define SCI_Q_LOCAL_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT) -extern const unsigned int SCI_Q_LOCAL_SEGMENT; - -#define SCI_Q_REMOTE_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT) -extern const unsigned int SCI_Q_REMOTE_SEGMENT; - -#define SCI_Q_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP) -extern const unsigned int SCI_Q_MAP; - -typedef struct { - char *str; /* Pointer to a string of minimum "length" characters */ - unsigned int length; -} sci_query_string_t; - - -typedef struct { - unsigned int localAdapterNo; /* The adapter no. that the query concern. */ - unsigned int portNo; /* The SCI Link port number that the query concern. */ - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_adapter_t; - - -typedef struct { - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_system_t; - -typedef struct { - sci_local_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_local_segment_t; - -typedef struct { - sci_remote_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_remote_segment_t; - -typedef struct { - sci_map_t map; - unsigned int subcommand; - unsigned int data; -} sci_query_map_t; - -/* Minor query commands (sub-commands) for adapter specific information SCI_ADAPTER */ -#define SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_MTU _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_MTU) -extern const unsigned int SCI_Q_ADAPTER_DMA_MTU; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE; - -#define SCI_Q_ADAPTER_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NODEID) -extern const unsigned int SCI_Q_ADAPTER_NODEID; - -#define SCI_Q_ADAPTER_SERIAL_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SERIAL_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_SERIAL_NUMBER; - -#define SCI_Q_ADAPTER_CARD_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CARD_TYPE) -extern const unsigned int SCI_Q_ADAPTER_CARD_TYPE; - -#define SCI_Q_ADAPTER_NUMBER_OF_STREAMS _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER_OF_STREAMS) -extern const unsigned int SCI_Q_ADAPTER_NUMBER_OF_STREAMS; - -#define SCI_Q_ADAPTER_STREAM_BUFFER_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_STREAM_BUFFER_SIZE) -extern const unsigned int SCI_Q_ADAPTER_STREAM_BUFFER_SIZE; - -#define SCI_Q_ADAPTER_CONFIGURED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONFIGURED) -extern const unsigned int SCI_Q_ADAPTER_CONFIGURED; - -#define SCI_Q_ADAPTER_LINK_OPERATIONAL _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LINK_OPERATIONAL) -extern const unsigned int SCI_Q_ADAPTER_LINK_OPERATIONAL; - -#define SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK) -extern const unsigned int SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK; - -#define SCI_Q_ADAPTER_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_NUMBER; - -#define SCI_Q_ADAPTER_INSTANCE_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_INSTANCE_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_INSTANCE_NUMBER; - -#define SCI_Q_ADAPTER_FIRMWARE_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_FIRMWARE_OK) -extern const unsigned int SCI_Q_ADAPTER_FIRMWARE_OK; - -#define SCI_Q_ADAPTER_CONNECTED_TO_SWITCH _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_SWITCH) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_SWITCH; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER; - -#define SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT; - -#define SCI_Q_ADAPTER_ATT_PAGE_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_PAGE_SIZE) -extern const unsigned int SCI_Q_ADAPTER_ATT_PAGE_SIZE; - -#define SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES; - -#define SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES; - -#define SCI_Q_ADAPTER_PHYS_MEM_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MEM_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MEM_NODEID; - -#define SCI_Q_ADAPTER_PHYS_MBX_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MBX_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MBX_NODEID; - -#define SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID; - -#define SCI_Q_ADAPTER_SCI_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SCI_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_SCI_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_B_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_B_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_B_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_IO_BUS_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_IO_BUS_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_IO_BUS_FREQUENCY; - -/* Minor query commands (sub-commands) for adapter specific information SCI_SYSTEM */ -#define SCI_Q_SYSTEM_HOSTBRIDGE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_HOSTBRIDGE) -extern const unsigned int SCI_Q_SYSTEM_HOSTBRIDGE; - -#define SCI_Q_SYSTEM_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_POSTING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_POSTING_ENABLED; - -#define SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED; - -#define SCI_Q_LOCAL_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_LOCAL_SEGMENT_IOADDR; - -#define SCI_Q_REMOTE_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_REMOTE_SEGMENT_IOADDR; - -#define SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET; - -#define SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET; - -#define HOSTBRIDGE_NOT_AVAILABLE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_NOT_AVAILABLE) -extern const unsigned int HOSTBRIDGE_NOT_AVAILABLE; - -#define HOSTBRIDGE_UNKNOWN _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_UNKNOWN) -extern const unsigned int HOSTBRIDGE_UNKNOWN; - -#define HOSTBRIDGE_440FX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440FX) -extern const unsigned int HOSTBRIDGE_440FX; - -#define HOSTBRIDGE_440LX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440LX) -extern const unsigned int HOSTBRIDGE_440LX; - -#define HOSTBRIDGE_440BX_A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_A) -extern const unsigned int HOSTBRIDGE_440BX_A; - -#define HOSTBRIDGE_440BX_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_B) -extern const unsigned int HOSTBRIDGE_440BX_B; - -#define HOSTBRIDGE_440GX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440GX) -extern const unsigned int HOSTBRIDGE_440GX; - -#define HOSTBRIDGE_450KX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450KX) -extern const unsigned int HOSTBRIDGE_450KX; - -#define HOSTBRIDGE_430NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_430NX) -extern const unsigned int HOSTBRIDGE_430NX; - -#define HOSTBRIDGE_450NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX) -extern const unsigned int HOSTBRIDGE_450NX; - -#define HOSTBRIDGE_450NX_MICO _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_MICO) -extern const unsigned int HOSTBRIDGE_450NX_MICO; - -#define HOSTBRIDGE_450NX_PXB _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_PXB) -extern const unsigned int HOSTBRIDGE_450NX_PXB; - -#define HOSTBRIDGE_I810 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810) -extern const unsigned int HOSTBRIDGE_I810; - -#define HOSTBRIDGE_I810_DC100 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810_DC100) -extern const unsigned int HOSTBRIDGE_I810_DC100; - -#define HOSTBRIDGE_I810E _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810E) -extern const unsigned int HOSTBRIDGE_I810E; - -#define HOSTBRIDGE_I815 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I815) -extern const unsigned int HOSTBRIDGE_I815; - -#define HOSTBRIDGE_I840 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I840) -extern const unsigned int HOSTBRIDGE_I840; - -#define HOSTBRIDGE_I850 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I850) -extern const unsigned int HOSTBRIDGE_I850; - -#define HOSTBRIDGE_I860 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I860) -extern const unsigned int HOSTBRIDGE_I860; - -#define HOSTBRIDGE_INTEL_E7500 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_INTEL_E7500) -extern const unsigned int HOSTBRIDGE_INTEL_E7500; - -#define HOSTBRIDGE_VIA_KT133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KT133) -extern const unsigned int HOSTBRIDGE_VIA_KT133; - -#define HOSTBRIDGE_VIA_KX133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KX133) -extern const unsigned int HOSTBRIDGE_VIA_KX133; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_133A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_133A) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_133A; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_266 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_266) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_266; - -#define HOSTBRIDGE_AMD_760_MP _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_760_MP) -extern const unsigned int HOSTBRIDGE_AMD_760_MP; - -#define HOSTBRIDGE_AMD_HAMMER _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_HAMMER) -extern const unsigned int HOSTBRIDGE_AMD_HAMMER; - -#define HOSTBRIDGE_SERVERWORKS_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE; - -#define HOSTBRIDGE_SERVERWORKS_HE_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE_B) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE_B; - -#define HOSTBRIDGE_SERVERWORKS_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_LE; - -#define HOSTBRIDGE_SERVERWORKS_GC_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_HE; - -#define HOSTBRIDGE_SERVERWORKS_GC_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_LE; - -#define HOSTBRIDGE_SERVERWORKS_GC_WS _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_WS) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_WS; - -#define HOSTBRIDGE_SERVERWORKS_GC_SL _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_SL) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_SL; - - -#define HOSTBRIDGE_WRITE_POSTING_DISABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_DISABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_DISABLED; - -#define HOSTBRIDGE_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_ENABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_ENABLED; - - - - -/********************************************************************************* - * * - * S C I C R E A T E D M A Q U E U E * - * * - * Flags * - * * - * SCI_FLAG_DMA_PHDMA : Create physical DMA queue. Please note that this is an * - * priveleged operation. * - * * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCICreateDMAQueue) -DLL void SCICreateDMAQueue(sci_desc_t sd, - sci_dma_queue_t *dq, - unsigned int localAdapterNo, - unsigned int maxEntries, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Not allowed in this queue state. * - * * - *********************************************************************************/ -#define SCIRemoveDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveDMAQueue) -DLL void SCIRemoveDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I E N Q U E U E D M A T R A N S F E R * - * * - * Flags: * - * * - * SCI_FLAG_DMA_READ - The DMA will be remote --> local * - * (default is local --> remote) * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is larger * - * than the segment size or larger than max * - * DMA size. * - * SCI_ERR_MAX_ENTRIES - The DMA queue is full * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_SEGMENT_NOT_PREPARED - The local segment has not been prepared for * - * access from the adapter associated with the * - * queue. * - * SCI_ERR_SEGMENT_NOT_CONNECTED - The remote segment is not connected through * - * the adapter associated with the queue. * - *********************************************************************************/ -#define SCIEnqueueDMATransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIEnqueueDMATransfer) -DLL sci_dma_queue_state_t SCIEnqueueDMATransfer(sci_dma_queue_t dq, - sci_local_segment_t localSegment, - sci_remote_segment_t remoteSegment, - unsigned int localOffset, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P O S T D M A Q U E U E * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The end of the transfer will cause the callback * - * function to be invoked. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIPostDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIPostDMAQueue) -DLL void SCIPostDMAQueue(sci_dma_queue_t dq, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortDMAQueue) -DLL void SCIAbortDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I R E S E T D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIResetDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIResetDMAQueue) -DLL void SCIResetDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I D M A Q U E U E S T A T E * - * * - *********************************************************************************/ -#define SCIDMAQueueState _SISCI_EXPANDE_FUNCTION_NAME(SCIDMAQueueState) -DLL sci_dma_queue_state_t SCIDMAQueueState(sci_dma_queue_t dq); - - - -/********************************************************************************* - * * - * S C I W A I T F O R D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForDMAQueue) -DLL sci_dma_queue_state_t SCIWaitForDMAQueue(sci_dma_queue_t dq, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I P H D M A E N Q U E U E * - * * - * SISCI Priveleged function * - * * - * Flags * - * * - * SCI_FLAG_DMA_READ * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaEnqueue _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaEnqueue) -DLL void SCIphDmaEnqueue(sci_dma_queue_t dmaqueue, - unsigned int size, - sci_ioaddr_t localBusAddr, - unsigned int remote_nodeid, - unsigned int remote_highaddr, - unsigned int remote_lowaddr, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I P H D M A S T A R T * - * * - * Flags * - * * - * SCI_FLAG_DMA_WAIT * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_DMA_RESET * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaStart _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaStart) -DLL sci_dma_queue_state_t SCIphDmaStart(sci_dma_queue_t dmaqueue, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I C R E A T E I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_FIXED_INTNO * - * SCI_FLAG_SHARED_INT * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INTNO_USED - This interrupt number is already used. * - * * - *********************************************************************************/ -#define SCICreateInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCICreateInterrupt) -DLL void SCICreateInterrupt(sci_desc_t sd, - sci_local_interrupt_t *interrupt, - unsigned int localAdapterNo, - unsigned int *interruptNo, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveInterrupt) -DLL void SCIRemoveInterrupt(sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait was interrupted by a call to * - * SCIRemoveInterrupt. * - * The handle is invalid when this error code is returned.* - * * - *********************************************************************************/ -#define SCIWaitForInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForInterrupt) -DLL void SCIWaitForInterrupt(sci_local_interrupt_t interrupt, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_INTNO - No such interrupt number. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIConnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectInterrupt) -DLL void SCIConnectInterrupt(sci_desc_t sd, - sci_remote_interrupt_t *interrupt, - unsigned int nodeId, - unsigned int localAdapterNo, - unsigned int interruptNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisconnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectInterrupt) -DLL void SCIDisconnectInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R I G G E R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCITriggerInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCITriggerInterrupt) -DLL void SCITriggerInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I R E G I S T E R I N T E R R U P T F L A G * - * * - * * - * This function register an "interrupt flag" that is identified as an unique * - * location within a local segment. If successful, the resulting interrupt * - * handle will have been associated with the specified local segment. * - * * - * It is up to the (remote) client(s) to set up an "interrupt mapping" for the * - * corresponding segment offset using either the * - * * - * - SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * * - * or the * - * * - * - SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP * - * * - * option to "SCIMapRemoteSegment()". - I.e. after having established a * - * connection to the corresponding segment. A trigger operation can then * - * be implemented using a store operation via the relevant "interrupt map". * - * * - * * - * * - * * - * * - * Flags: * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT - Triggering is to take place using * - * "conditional interrupts". * - * * - * * - * * - * Specific error codes for this function: * - * None. * - * * - *********************************************************************************/ -#define SCIRegisterInterruptFlag _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterInterruptFlag) -DLL void SCIRegisterInterruptFlag( - unsigned int localAdapterNo, - sci_local_interrupt_t *interrupt, - sci_local_segment_t segment, - unsigned int offset, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I E N A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * This function make sure that another HW interrupt will take place the next * - * time the corresponding interrupt flag is triggered by a * - * "conditional interrupt" operation. * - * * - * Default semantics: * - * * - * When successful, the client can rely on that the first subsequent trigger * - * operation will cause a HW interrupt and subsequently cause the client * - * handler function to be invoked. * - * * - * If an interrupt was triggered in parallell with the enable operation, then * - * the operation will fail (SCI_ERR_COND_INT_RACE_PROBLEM), and the client can * - * not rely on another trigger operation will lead to handler invocation. * - * Hence, any state checking normally associated with handling the * - * corresponding interrupt should take place before attempting to enable * - * again. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_COND_INT_RACE_PROBLEM - The enable operation failed because an * - * incomming trigger operation happened * - * concurrently. * - * * - *********************************************************************************/ -#define SCIEnableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIEnableConditionalInterrupt) -DLL void SCIEnableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I D I S A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * Prevent subsequent "conditional interrupt"trigger operations for * - * the specified interupt flag from causing HW interrupt and handler * - * invocations. * - * * - * * - * Default semantics: * - * * - * If successful, no subsequent HW interrupts will take place, but handler * - * invocations that have already been scheduled may still take place. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisableConditionalInterrupt) -DLL void SCIDisableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C O N D I T I O N A L I N T E R R U P T C O U N T E R * - * * - * * - * Returns a value that indicates the number of times this flag has * - * been trigged since the last time it was enabled or disabled. * - * Calling the SCIEnableConditionalInterrupt / SCIDisableConditionalInterrupt * - * functions will reset the counter value. * - * * - * Default semantics: * - * * - * If successful, the current trig count is returned in the * - * interruptTrigCounter parameter. * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OVERFLOW - The number of trig operations have exceeded the range * - * that can be counted. * - *********************************************************************************/ -#define SCIGetConditionalInterruptTrigCounter _SISCI_EXPANDE_FUNCTION_NAME(SCIGetConditionalInterruptTrigCounter) -DLL void SCIGetConditionalInterruptTrigCounter( - sci_local_interrupt_t interrupt, - unsigned int *interruptTrigCounter, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlock _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlock) -DLL void SCITransferBlock(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K A S Y N C * - * * - * Flags * - * * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_USE_CALLBACK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger than * - * the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlockAsync _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlockAsync) -DLL void SCITransferBlockAsync(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - sci_block_transfer_t *block, - sci_cb_block_transfer_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForBlockTransfer) -DLL void SCIWaitForBlockTransfer(sci_block_transfer_t block, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortBlockTransfer) -DLL void SCIAbortBlockTransfer(sci_block_transfer_t block, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M E M C P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - -#define SCIMemCpy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCpy) -DLL void SCIMemCpy(sci_sequence_t sequence, - void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I M E M C O P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - - -#define SCIMemCopy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCopy) -DLL void SCIMemCopy(void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E G I S T E R S E G M E N T M E M O R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_ILLEGAL_ADDRESS - Illegal address. * - * SCI_ERR_OUT_OF_RANGE - Size is larger than the maximum size for the * - * local segment. * - * * - *********************************************************************************/ -#define SCIRegisterSegmentMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterSegmentMemory) -DLL void SCIRegisterSegmentMemory(void *address, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S C I S P A C E * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * * - *********************************************************************************/ -#define SCIConnectSCISpace _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSCISpace) -DLL void SCIConnectSCISpace(sci_desc_t sd, - unsigned int localAdapterNo, - sci_remote_segment_t *segment, - sci_address_t address, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/* - * ===================================================================================== - * - * S C I A T T A C H L O C A L S E G M E N T - * Description: - * - * SCIAttachLocalSegment() permits an application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events - * on this segment. - * - * - * Specific error codes for this function: - * - * SCI_ERR_ACCESS - No such shared segment - * SCI_ERR_NO_SUCH_SEGMENT - No such segment - * Note: Current implenentation will return SCI_ERR_ACCESS for both cases. This will - * change from next release. Application should handle both cases. - * - * ===================================================================================== - */ -#define SCIAttachLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachLocalSegment) - -DLL void -SCIAttachLocalSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int *size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); -/* - * ===================================================================================== - * - * S C I S H A R E S E G M E N T - * - * Description: - * - * SCIShareSegment() permits other application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * none - * - * Specific error codes for this function: - * - * - * - * ===================================================================================== - */ -#define SCIShareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIShareSegment) - -DLL void -SCIShareSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I F L U S H * - * * - * This function will flush the CPU buffers and the PSB buffers. * - * * - * Flags * - * SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY : * - * Only flush CPU buffers ( Write combining * - * etc buffers). * - * * - *********************************************************************************/ - -#define SCIFlush _SISCI_EXPANDE_FUNCTION_NAME(SCIFlush) -DLL void SCIFlush(sci_sequence_t sequence, - unsigned int flags); - -#if defined(CPLUSPLUS) || defined(__cplusplus) -} -#endif - - -#endif - - - - - - - - - - - diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_demolib.h b/ndb/src/external/LINUX.x86/sci/include/sisci_demolib.h deleted file mode 100644 index 4284fc5585c..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_demolib.h +++ /dev/null @@ -1,226 +0,0 @@ -/* $Id: sisci_demolib.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SISCI_DEMOLIB_H -#define _SISCI_DEMOLIB_H - - -#if defined(_REENTRANT) - -#define _SISCI_DEMOLIB_EXPAND_NAME(name) _SISCI_DEMOLIB_MT_ ## name - -#else - -#define _SISCI_DEMOLIB_EXPAND_NAME(name) _SISCI_DEMOLIB_ST_ ## name - -#endif - -/*********************************************************************************/ -/* Q U E R Y A D A P T E R */ -/* */ -/*********************************************************************************/ - -#define QueryAdapter _SISCI_DEMOLIB_EXPAND_NAME(QueryAdapter) - -sci_error_t QueryAdapter( - unsigned int subcommand, - unsigned int localAdapterNo, - unsigned int portNo, - unsigned int *data); - - -/*********************************************************************************/ -/* Q U E R Y S Y S T E M */ -/* */ -/*********************************************************************************/ - -#define QuerySystem _SISCI_DEMOLIB_EXPAND_NAME(QuerySystem) - -sci_error_t QuerySystem( - unsigned int subcommand, - unsigned int *data); - - -/*********************************************************************************/ -/* D E T E C T F I R S T A D A P T E R C A R D */ -/* */ -/*********************************************************************************/ - -#define DetectFirstAdapterCard _SISCI_DEMOLIB_EXPAND_NAME(DetectFirstAdapterCard) - -sci_error_t DetectFirstAdapterCard( - unsigned int *localAdapterNo, - unsigned int *localNodeId); - - -/*********************************************************************************/ -/* G E T A D A P T E R T Y P E */ -/* */ -/*********************************************************************************/ - -#define GetAdapterType _SISCI_DEMOLIB_EXPAND_NAME(GetAdapterType) - -sci_error_t GetAdapterType(unsigned int localAdapterNo, - unsigned int *adapterType); - - -/*********************************************************************************/ -/* G E T L O C A L N O D E I D */ -/* */ -/*********************************************************************************/ - -#define GetLocalNodeId _SISCI_DEMOLIB_EXPAND_NAME(GetLocalNodeId) - -sci_error_t GetLocalNodeId( - unsigned int localAdapterNo, - unsigned int *localNodeId); - - -/*********************************************************************************/ -/* G E T A D A P T E R S E R I A L N U M B E R */ -/* */ -/*********************************************************************************/ - -#define GetAdapterSerialNumber _SISCI_DEMOLIB_EXPAND_NAME(GetAdapterSerialNumber) - -sci_error_t GetAdapterSerialNumber( - unsigned int localAdapterNo, - unsigned int *serialNo); - - - -/*********************************************************************************/ -/* G E T H O S T B R I D G E T Y P E */ -/* */ -/*********************************************************************************/ - -#define GetHostbridgeType _SISCI_DEMOLIB_EXPAND_NAME(GetHostbridgeType) - -sci_error_t GetHostbridgeType(unsigned int *hostbridgeType); - - - -/*********************************************************************************/ -/* P R I N T H O S T B R I D G E T Y P E */ -/* */ -/*********************************************************************************/ - -#define PrintHostbridgeType _SISCI_DEMOLIB_EXPAND_NAME(PrintHostbridgeType) - -void PrintHostbridgeType(unsigned int hostbridge); - - - -/*********************************************************************************/ -/* G E T A P I V E R S I O N S T R I N G */ -/* */ -/*********************************************************************************/ - -#define GetAPIVersionString _SISCI_DEMOLIB_EXPAND_NAME(GetAPIVersionString) - -sci_error_t GetAPIVersionString(char str[], unsigned int strLength); - - - -/*********************************************************************************/ -/* G E T A D A P T E R I O B U S F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterIoBusFrequency(unsigned int localAdapterNo, - unsigned int *ioBusFrequency); - - - -/*********************************************************************************/ -/* G E T A D A P T E R S C I L I N K F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterSciLinkFrequency(unsigned int localAdapterNo, - unsigned int *sciLinkFrequency); - - - -/*********************************************************************************/ -/* G E T A D A P T E R B L I N K F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterBlinkFrequency(unsigned int localAdapterNo, - unsigned int *bLinkFrequency); - - -/*********************************************************************************/ -/* S E N D I N T E R R U P T */ -/* */ -/*********************************************************************************/ - -#define SendInterrupt _SISCI_DEMOLIB_EXPAND_NAME(SendInterrupt) - -sci_error_t SendInterrupt( - sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int localNodeId, - unsigned int remoteNodeId, - unsigned int interruptNo); - - -/*********************************************************************************/ -/* R E C E I V E I N T E R R U P T */ -/* */ -/*********************************************************************************/ - -#define ReceiveInterrupt _SISCI_DEMOLIB_EXPAND_NAME(ReceiveInterrupt) - -sci_error_t ReceiveInterrupt( - sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int localNodeId, - unsigned int interruptNo); - - -/*********************************************************************************/ -/* E N D I A N S W A P */ -/* */ -/*********************************************************************************/ - -#define EndianSwap _SISCI_DEMOLIB_EXPAND_NAME(EndianSwap) - -unsigned int EndianSwap (unsigned int value); - - -/*********************************************************************************/ -/* S L E E P M I L L I S E C O N D S */ -/* */ -/*********************************************************************************/ - -#define SleepMilliseconds _SISCI_DEMOLIB_EXPAND_NAME(SleepMilliseconds) - -void SleepMilliseconds(int milliseconds); - - - - -#endif diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_error.h b/ndb/src/external/LINUX.x86/sci/include/sisci_error.h deleted file mode 100644 index c53fe8ad5d9..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_error.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $Id: sisci_error.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SISCI_ERROR_H_ -#define _SISCI_ERROR_H_ - - -/* SCI Error return values always have 30 bit set */ -#define SCI_ERR_MASK 0x40000000 -#define SCI_ERR_REMOTE_MASK 0x01 /* Remote errors should have bit 0 set */ - -#define SCI_ERR(u) ((unsigned32)(u)&0x7FFFFFFF ) - -/* Error codes */ -typedef enum { - SCI_ERR_OK = 0x000, - - - SCI_ERR_BUSY = (0x900 | SCI_ERR_MASK), - SCI_ERR_FLAG_NOT_IMPLEMENTED = (0x901 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_FLAG = (0x902 | SCI_ERR_MASK), - SCI_ERR_NOSPC = (0x904 | SCI_ERR_MASK), - SCI_ERR_API_NOSPC = (0x905 | SCI_ERR_MASK), - SCI_ERR_HW_NOSPC = (0x906 | SCI_ERR_MASK), - SCI_ERR_NOT_IMPLEMENTED = (0x907 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADAPTERNO = (0x908 | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_ADAPTERNO = (0x909 | SCI_ERR_MASK), - SCI_ERR_TIMEOUT = (0x90A | SCI_ERR_MASK), - SCI_ERR_OUT_OF_RANGE = (0x90B | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_SEGMENT = (0x90C | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_NODEID = (0x90D | SCI_ERR_MASK), - SCI_ERR_CONNECTION_REFUSED = (0x90E | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_CONNECTED = (0x90F | SCI_ERR_MASK), - SCI_ERR_SIZE_ALIGNMENT = (0x910 | SCI_ERR_MASK), - SCI_ERR_OFFSET_ALIGNMENT = (0x911 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_PARAMETER = (0x912 | SCI_ERR_MASK), - SCI_ERR_MAX_ENTRIES = (0x913 | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_PREPARED = (0x914 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADDRESS = (0x915 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_OPERATION = (0x916 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_QUERY = (0x917 | SCI_ERR_MASK), - SCI_ERR_SEGMENTID_USED = (0x918 | SCI_ERR_MASK), - SCI_ERR_SYSTEM = (0x919 | SCI_ERR_MASK), - SCI_ERR_CANCELLED = (0x91A | SCI_ERR_MASK), - SCI_ERR_NOT_CONNECTED = (0x91B | SCI_ERR_MASK), - SCI_ERR_NOT_AVAILABLE = (0x91C | SCI_ERR_MASK), - SCI_ERR_INCONSISTENT_VERSIONS = (0x91D | SCI_ERR_MASK), - SCI_ERR_COND_INT_RACE_PROBLEM = (0x91E | SCI_ERR_MASK), - SCI_ERR_OVERFLOW = (0x91F | SCI_ERR_MASK), - SCI_ERR_NOT_INITIALIZED = (0x920 | SCI_ERR_MASK), - - SCI_ERR_ACCESS = (0x921 | SCI_ERR_MASK), - - SCI_ERR_NO_SUCH_NODEID = (0xA00 | SCI_ERR_MASK), - SCI_ERR_NODE_NOT_RESPONDING = (0xA02 | SCI_ERR_MASK), - SCI_ERR_NO_REMOTE_LINK_ACCESS = (0xA04 | SCI_ERR_MASK), - SCI_ERR_NO_LINK_ACCESS = (0xA05 | SCI_ERR_MASK), - SCI_ERR_TRANSFER_FAILED = (0xA06 | SCI_ERR_MASK) -} sci_error_t; - - -#endif /* _SCI_ERROR_H_ */ - - - diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_types.h b/ndb/src/external/LINUX.x86/sci/include/sisci_types.h deleted file mode 100644 index f4125fdec69..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_types.h +++ /dev/null @@ -1,133 +0,0 @@ -/* $Id: sisci_types.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SISCI_TYPES_H -#define _SISCI_TYPES_H - -#include "sisci_error.h" - -#ifndef IN -#define IN -#endif - -#ifndef OUT -#define OUT -#endif - -#ifndef IN_OUT -#define IN_OUT -#endif - -/* Opaque data types for descriptors/handles */ -typedef struct sci_desc *sci_desc_t; -typedef struct sci_local_segment *sci_local_segment_t; -typedef struct sci_remote_segment *sci_remote_segment_t; - -typedef struct sci_map *sci_map_t; -typedef struct sci_sequence *sci_sequence_t; -#ifndef KERNEL -typedef struct sci_dma_queue *sci_dma_queue_t; -#endif -typedef struct sci_remote_interrupt *sci_remote_interrupt_t; -typedef struct sci_local_interrupt *sci_local_interrupt_t; -typedef struct sci_block_transfer *sci_block_transfer_t; - -/* - * Constants defining reasons for segment callbacks: - */ - -typedef enum { - SCI_CB_CONNECT = 1, - SCI_CB_DISCONNECT, - SCI_CB_NOT_OPERATIONAL, - SCI_CB_OPERATIONAL, - SCI_CB_LOST -} sci_segment_cb_reason_t; - -#define MAX_CB_REASON SCI_CB_LOST - -/* dma_queue_states is identical to the dma_queue_state_t in genif.h, they must be consistent.*/ -typedef enum { - SCI_DMAQUEUE_IDLE, - SCI_DMAQUEUE_GATHER, - SCI_DMAQUEUE_POSTED, - SCI_DMAQUEUE_DONE, - SCI_DMAQUEUE_ABORTED, - SCI_DMAQUEUE_ERROR -} sci_dma_queue_state_t; - - -typedef enum { - SCI_SEQ_OK, - SCI_SEQ_RETRIABLE, - SCI_SEQ_NOT_RETRIABLE, - SCI_SEQ_PENDING -} sci_sequence_status_t; - - -typedef struct { - unsigned short nodeId; /* SCI Address bit 63 - 48 */ - unsigned short offsHi; /* SCI Address bit 47 - 32 */ - unsigned int offsLo; /* SCI Address bit 31 - 0 */ -} sci_address_t; - - -typedef unsigned int sci_ioaddr_t; - -typedef enum { - SCI_CALLBACK_CANCEL = 1, - SCI_CALLBACK_CONTINUE -} sci_callback_action_t; - -#ifndef KERNEL -typedef sci_callback_action_t (*sci_cb_local_segment_t)(void *arg, - sci_local_segment_t segment, - sci_segment_cb_reason_t reason, - unsigned int nodeId, - unsigned int localAdapterNo, - sci_error_t error); - -typedef sci_callback_action_t (*sci_cb_remote_segment_t)(void *arg, - sci_remote_segment_t segment, - sci_segment_cb_reason_t reason, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_dma_t)(void IN *arg, - sci_dma_queue_t queue, - sci_error_t status); - - -typedef int (*sci_cb_block_transfer_t)(void *arg, - sci_block_transfer_t block, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_interrupt_t)(void *arg, - sci_local_interrupt_t interrupt, - sci_error_t status); - -#endif /* KERNEL */ -#endif diff --git a/ndb/src/external/LINUX.x86/sci/include/sisci_version.h b/ndb/src/external/LINUX.x86/sci/include/sisci_version.h deleted file mode 100644 index f1807c33aa5..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/sisci_version.h +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id: sisci_version.h,v 1.1 2002/12/13 12:17:21 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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 SISCI_VERSION_H -#define SISCI_VERSION_H - - -#define SISCI_API_VER_MAJOR 0x01 -#define SISCI_API_VER_MAJORC "1" - -#define SISCI_API_VER_MINOR 0x010 -#define SISCI_API_VER_MINORC "10" -#define SISCI_API_VER_MICRO 0x005 -#define SISCI_API_VER_MICROC "5" - -#define SISCI_SIGN_VERSION_MASK 0xfffff000 /* used to mask off API_VER_MICRO */ - -#define SISCI_API_VERSION (SISCI_API_VER_MAJOR << 24 | SISCI_API_VER_MINOR << 12 | SISCI_API_VER_MICRO) - -/* the rules are: - * - * Changes in API_VER_MICRO should be binary compatible, New flags, functions added. No changes to user code - * required if new features is not needed. - * - * Changes in API_VER_MINOR requires recompilation of user code. - * - * Changes in the API_VER_MAJOR will most likely require changes to user code. This should not happen very - * often... - * - */ - -#ifndef BUILD_DATE -#define BUILD_DATE __DATE__ -#endif - -#ifndef BUILD_NAME -#define BUILD_NAME "" -#endif - -#define API_VERSION "SISCI API version " SISCI_API_VER_MAJORC "." SISCI_API_VER_MINORC "."SISCI_API_VER_MICROC " ( "BUILD_NAME" "BUILD_DATE" )" - -#endif - - -/* Version info: */ -/* */ -/* 1.5.2 First SISCI version */ -/* 1.5.3 Some bug fixes */ -/* 1.5.4 Some bug fixes */ -/* 1.5.5 No release */ -/* 1.5.6 Lock flag implemented in function SCIConnectSegment */ -/* 1.5.7 Expanded query functionality */ -/* 1.5.8 Updated error checking (sequence) functionality for D320 */ -/* 1.6.0 Updated error checking (sequence) D320 and IRM 1.9 support */ -/* 1.9.0 Ported to Solaris_sparc, Solaris_x86 and Linux. IRM 1.9. */ -/* 1.9.1 Some bug fixes */ -/* 1.9.2 Added more adapter queries */ -/* 1.9.3 Bug fix in SCIMapLocalSegment and SCIMapRemoteSegment */ -/* 1.9.4 NT Release Developers Kit 2.40 */ -/* 1.9.5 Added flush after data transfer in SCIMemCopy() */ -/* 1.9.5 NT Release Developers Kit 2.44 */ -/* 1.10.0: - * New SCIInitialize(), SCITerminate() functions. - * Support for D330 - * - * - */ - - diff --git a/ndb/src/external/LINUX.x86/sci/include/version.h b/ndb/src/external/LINUX.x86/sci/include/version.h deleted file mode 100644 index a0e1fa6c5cd..00000000000 --- a/ndb/src/external/LINUX.x86/sci/include/version.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _VERSION_H -#define _VERSION_H - - -/* -#define DEMO_VER_MAJOR "1" -#define DEMO_VER_MINOR "5" -#define DEMO_VER_MICRO "0" -*/ - -#ifndef BUILD_DATE -#define BUILD_DATE __DATE__ -#endif - -#ifndef BUILD_NAME -#define BUILD_NAME "" -#endif - -/* -#define DEMO_VERSION "version " DEMO_VER_MAJOR "." DEMO_VER_MINOR "."DEMO_VER_MICRO " ("BUILD_NAME" "BUILD_DATE" )" -*/ -#define DEMO_VERSION " ("BUILD_NAME" "BUILD_DATE" )" - - -#endif diff --git a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_api.h b/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_api.h deleted file mode 100644 index d02d3aafe7f..00000000000 --- a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_api.h +++ /dev/null @@ -1,2148 +0,0 @@ -/* $Id: sisci_api.h,v 1.1 2002/12/13 12:17:22 hin Exp $ */ -/******************************************************************************* - * * - * Copyright (C) 1993 - 2001 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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 _SISCI_API_H -#define _SISCI_API_H - -#include "sisci_types.h" -#include "sisci_error.h" - - -#ifdef WIN32 -#ifdef API_DLL -#define DLL __declspec(dllexport) -#elif CLIENT_DLL -#define DLL __declspec(dllimport) -#endif -#endif /* WIN32 */ - - -#ifndef DLL -#define DLL -#endif - -#if defined(_REENTRANT) -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_MT_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_MT_ ## name -#else -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_ST_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_ST_ ## name -#endif -#define _SISCI_EXPANDE_CONSTANT_NAME(name) _SISCI_PUBLIC_CONST_ ## name - -#if defined(CPLUSPLUS) || defined(__cplusplus) -extern "C" { -#endif - - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define SCI_FLAG_FIXED_INTNO _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_INTNO) -extern const unsigned int SCI_FLAG_FIXED_INTNO; - -#define SCI_FLAG_SHARED_INT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_INT) -extern const unsigned int SCI_FLAG_SHARED_INT; - -#define SCI_FLAG_FIXED_MAP_ADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_MAP_ADDR) -extern const unsigned int SCI_FLAG_FIXED_MAP_ADDR; - -#define SCI_FLAG_READONLY_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READONLY_MAP) -extern const unsigned int SCI_FLAG_READONLY_MAP; - -#define SCI_FLAG_USE_CALLBACK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_USE_CALLBACK) -extern const unsigned int SCI_FLAG_USE_CALLBACK; - -#define SCI_FLAG_BLOCK_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_BLOCK_READ) -extern const unsigned int SCI_FLAG_BLOCK_READ; - -#define SCI_FLAG_THREAD_SAFE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_THREAD_SAFE) -extern const unsigned int SCI_FLAG_THREAD_SAFE; - -#define SCI_FLAG_ASYNCHRONOUS_CONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ASYNCHRONOUS_CONNECT) -extern const unsigned int SCI_FLAG_ASYNCHRONOUS_CONNECT; - -#define SCI_FLAG_EMPTY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_EMPTY) -extern const unsigned int SCI_FLAG_EMPTY; - -#define SCI_FLAG_PRIVATE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_PRIVATE) -extern const unsigned int SCI_FLAG_PRIVATE; - -#define SCI_FLAG_FORCE_DISCONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FORCE_DISCONNECT) -extern const unsigned int SCI_FLAG_FORCE_DISCONNECT; - -#define SCI_FLAG_NOTIFY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NOTIFY) -extern const unsigned int SCI_FLAG_NOTIFY; - -#define SCI_FLAG_DMA_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_READ) -extern const unsigned int SCI_FLAG_DMA_READ; - -#define SCI_FLAG_DMA_POST _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_POST) -extern const unsigned int SCI_FLAG_DMA_POST; - -#define SCI_FLAG_DMA_WAIT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_WAIT) -extern const unsigned int SCI_FLAG_DMA_WAIT; - -#define SCI_FLAG_DMA_RESET _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_RESET) -extern const unsigned int SCI_FLAG_DMA_RESET; - -#define SCI_FLAG_NO_FLUSH _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_FLUSH) -extern const unsigned int SCI_FLAG_NO_FLUSH; - -#define SCI_FLAG_NO_STORE_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_STORE_BARRIER) -extern const unsigned int SCI_FLAG_NO_STORE_BARRIER; - -#define SCI_FLAG_FAST_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FAST_BARRIER) -extern const unsigned int SCI_FLAG_FAST_BARRIER; - -#define SCI_FLAG_ERROR_CHECK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ERROR_CHECK) -extern const unsigned int SCI_FLAG_ERROR_CHECK; - -#define SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) -extern const unsigned int SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY; - -/* the FLUSH_CPU_BUFFERS_ONLY flag is for backwards compabillity only and should never be used */ -#define FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) - -#define SCI_FLAG_LOCK_OPERATION _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_LOCK_OPERATION) -extern const unsigned int SCI_FLAG_LOCK_OPERATION; - -#define SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP; - -#define SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP; - -#define SCI_FLAG_IO_MAP_IOSPACE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_IO_MAP_IOSPACE) -extern const unsigned int SCI_FLAG_IO_MAP_IOSPACE; - -#define SCI_FLAG_DMOVE_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMOVE_MAP) -extern const unsigned int SCI_FLAG_DMOVE_MAP; - -#define SCI_FLAG_WRITES_DISABLE_GATHER_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_WRITES_DISABLE_GATHER_MAP) -extern const unsigned int SCI_FLAG_WRITES_DISABLE_GATHER_MAP; - -#define SCI_FLAG_DISABLE_128_BYTES_PACKETS _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DISABLE_128_BYTES_PACKETS) -extern const unsigned int SCI_FLAG_DISABLE_128_BYTES_PACKETS; - -#define SCI_FLAG_DMA_SOURCE_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_SOURCE_ONLY) -extern const unsigned int SCI_FLAG_DMA_SOURCE_ONLY; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT_MAP; - -#define SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP; - -#define SCI_FLAG_NO_MEMORY_LOOPBACK_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_MEMORY_LOOPBACK_MAP) -extern const unsigned int SCI_FLAG_NO_MEMORY_LOOPBACK_MAP; - -#if defined(OS_IS_LYNXOS) || defined(OS_IS_VXWORKS) -#define SCI_FLAG_WRITE_BACK_CACHE_MAP _SISCI_EXPANDE_CONSTANT_NAME(WRITE_BACK_CACHE_MAP) -extern const unsigned int SCI_FLAG_WRITE_BACK_CACHE_MAP; -#endif - -#define SCI_FLAG_DMA_PHDMA _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_PHDMA) -extern const unsigned int SCI_FLAG_DMA_PHDMA; - -/*********************************************************************************/ -/* GENERAL VALUES */ -/*********************************************************************************/ -#define SCI_LOCAL_HOST _SISCI_EXPANDE_CONSTANT_NAME(SCI_LOCAL_HOST) -extern const unsigned int SCI_LOCAL_HOST; - -#define SCI_INFINITE_TIMEOUT _SISCI_EXPANDE_CONSTANT_NAME(SCI_INFINITE_TIMEOUT) -extern const unsigned int SCI_INFINITE_TIMEOUT; - -/*********************************************************************************/ -/* GENERAL ERROR CODES */ -/* */ -/* SCI_ERR_ILLEGAL_FLAG - Illegal flag value. */ -/* SCI_ERR_FLAG_NOT_IMPLEMENTED - Flag legal but flag feature not implemented. */ -/* SCI_ERR_NOT_IMPLEMENTED - Function not implemented. */ -/* SCI_ERR_SYSTEM - A system error. Check errno. */ -/* SCI_ERR_NOSPC - Unable to allocate OS resources. */ -/* SCI_ERR_API_NOSPC - Unable to allocate API resources. */ -/* SCI_ERR_HW_NOSPC - Unable to allocate HW resources (Hardware) */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "ADAPTER" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_ADAPTERNO - Adapter number is legal but does not exist. */ -/* SCI_ERR_ILLEGAL_ADAPTERNO - Illegal local adapter number (i.e. outside */ -/* legal range). */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "NODEID" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_NODEID - The remote adapter identified by nodeId does */ -/* not respond, but the intermediate link(s) */ -/* seem(s) to be operational. */ -/* SCI_ERR_ILLEGAL_NODEID - Illegal NodeId. */ -/* */ -/*********************************************************************************/ - - - -/********************************************************************************* - * * - * S C I I N I T I A L I Z E * - * * - * This function initializes the SISCI library. * - * The function must be called before SCIOpen(). * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCIInitialize _SISCI_EXPANDE_FUNCTION_NAME(SCIInitialize) -DLL void SCIInitialize(unsigned int flags, - sci_error_t *error); -#if 0 -unsigned int __Internal_SISCI_version_var; -#endif - -/********************************************************************************* - * * - * S C I T E R M I N A T E * - * * - * This function terminates the SISCI library. * - * The function must be called after SCIClose(). * - * * - * * - *********************************************************************************/ -#define SCITerminate _SISCI_EXPANDE_FUNCTION_NAME(SCITerminate) -DLL void SCITerminate(void); - -/********************************************************************************* - * * - * S C I O P E N * - * * - * * - * Opens a SCI virtual device. * - * Caller must supply a pointer to a variable of type sci_desc_t to be * - * initialized. * - * * - * Flags * - * SCI_FLAG_THREAD_SAFE - Operations on resources associated with this * - * descriptor will be performed in a multithread-safe * - * manner. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INCONSISTENT_VERSIONS - Inconsistency between the SISCI library * - * and the SISCI driver versions. * - * * - * * - *********************************************************************************/ -#define SCIOpen _SISCI_EXPANDE_FUNCTION_NAME(SCIOpen) -DLL void SCIOpen(sci_desc_t *sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C L O S E * - * * - * This function closes an open SCI virtual device. * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - All resources are not deallocated. * - * * - *********************************************************************************/ -#define SCIClose _SISCI_EXPANDE_FUNCTION_NAME(SCIClose) -DLL void SCIClose(sci_desc_t sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S E G M E N T * - * * - * Connects to a remote shared memory segment located at <nodeId> with the * - * identifier <segmentId>. * - * The user may then call SCIMapRemoteSegment() to map shared memory * - * into user space. * - * * - * Flags * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_ASYNCHRONOUS_CONNECT * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_SEGMENT - Could not find the remote segment with the * - * given segmentId. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIConnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSegment) -DLL void SCIConnectSegment(sci_desc_t sd, - sci_remote_segment_t *segment, - unsigned int nodeId, - unsigned int segmentId, - unsigned int localAdapterNo, - sci_cb_remote_segment_t callback, - void *callbackArg, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T S E G M E N T * - * * - * Disconnects from the give mapped shared memory segment * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The segment is currently mapped or in use. * - * * - *********************************************************************************/ -#define SCIDisconnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectSegment) -DLL void SCIDisconnectSegment(sci_remote_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T R E M O T E S E G M E N T S I Z E * - * * - *********************************************************************************/ -#define SCIGetRemoteSegmentSize _SISCI_EXPANDE_FUNCTION_NAME(SCIGetRemoteSegmentSize) -DLL unsigned int SCIGetRemoteSegmentSize(sci_remote_segment_t segment); - - - -/********************************************************************************* - * * - * S C I W A I T F O R R E M O T E S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du * - * to a SCIDisconnectSegment() on the same * - * handle. The handle is invalid when this * - * error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForRemoteSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForRemoteSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForRemoteSegmentEvent( - sci_remote_segment_t segment, - sci_error_t *status, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P R E M O T E S E G M E N T * - * * - * This function is used to include a shared memory segment in the virtual * - * address space of the application. * - * * - * Flags: * - * * - * SCI_FLAG_FIXED_MAP_ADDR - Map at the suggested virtual address * - * SCI_FLAG_READONLY_MAP - The segment is mapped in read-only mode * - * SCI_FLAG_LOCK_OPERATION - Enable Lock operations (fetch and add) * - * SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP * - * - Enable aggressive prefetch with speculative * - * hold. * - * * - * SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP * - * - The PSB66 will prefetch 64 bytes. As soon * - * as the PCI read retry has been accepted, * - * the stream will change state to FREE, even * - * if less than 64 bytes were actually read. * - * * - * SCI_FLAG_IO_MAP_IOSPACE - Enable No Prefetch, no speculative hold. * - * * - * SCI_FLAG_DMOVE_MAP - Enable DMOVE packet type. The stream will be * - * set into FREE state immediately. * - * * - * SCI_FLAG_WRITES_DISABLE_GATHER_MAP * - * - Disable use of gather. * - * * - * SCI_FLAG_DISABLE_128_BYTES_PACKETS * - * - Disable use of 128-Byte packets * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an atomic "fetch-and-add-one" operation on * - * remote memory, but in addition an interrupt * - * will be generated if the target memory * - * location contained a "null value" before the * - * add operation was carried out. * - * The conditional interrupt flag must also be * - * specified in the SCIRegisterInterruptFlag() * - * function. * - * * - * SCI_FLAG_UNCONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an interrupt for the remote adapter * - * "in addition to" updating the corresponding * - * remote memory location with the data being * - * written. * - * The unconditional interrupt flag must also * - * be specified in the * - * SCIRegisterInterruptFlag() function. * - * * - * SCI_FLAG_WRITE_BACK_CACHE_MAP * - * - Enable cacheing of the mapped region. * - * Writes through this map will be written to a * - * write back cache, hence no remote SCI updates* - * until the cache line is flushed. The * - * application is responsible for the cache * - * flush operation. * - * The SCImemCopy() function will handle this * - * correctly by doing cache flushes internally. * - * This feature is architechture dependent and * - * not be available on all plattforms. * - * * - * SCI_FLAG_NO_MEMORY_LOOPBACK_MAP * - * - Forces a map to a remote segment located * - * in the local machine to be mapped using * - * SCI loopback. This is useful i.e. if you * - * want to use a regular map access to be * - * serialized with lock operations. * - * The default behaviour is to access a remte * - * segment located in the local machine as a * - * local MMU operation. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapRemoteSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapRemoteSegment) -DLL volatile void *SCIMapRemoteSegment( - sci_remote_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P L O C A L S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_FIXED_MAP_ADDR * - * SCI_FLAG_READONLY_MAP * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapLocalSegment) -DLL void *SCIMapLocalSegment(sci_local_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I U N M A P S E G M E N T * - * * - * This function unmaps pages of shared memory from the callers virtual * - * address space. * - * * - * Flags * - * None. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The map is currently in use. * - * * - *********************************************************************************/ -#define SCIUnmapSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIUnmapSegment) -DLL void SCIUnmapSegment(sci_map_t map, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E S E G M E N T * - * * - * Make the specified segment available for connections via the specified * - * adapter. If successful, the segment can be accessed from remote nodes * - * via the specified adapter. * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events * - * on this segment. * - * SCI_FLAG_EMPTY - No memory will be allocated for the segment. * - * SCI_FLAG_PRIVATE - The segment will be private meaning it will never * - * be any connections to it. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SEGMENTID_USED - The segment with this segmentId is already used * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * * - *********************************************************************************/ -#define SCICreateSegment _SISCI_EXPANDE_FUNCTION_NAME(SCICreateSegment) -DLL void SCICreateSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I W A I T F O R L O C A L S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du to a * - * SCIRemoveSegment() on the same handle. * - * The handle is invalid when this error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForLocalSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForLocalSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForLocalSegmentEvent( - sci_local_segment_t segment, - unsigned int *sourcenodeId, - unsigned int *localAdapterNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P R E P A R E S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_DMA_SOURCE_ONLY - The segment will be used as a source segment * - * for DMA operations. On some system types this * - * will enable the SISCI driver to use performance * - * improving features. * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIPrepareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIPrepareSegment) -DLL void SCIPrepareSegment(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E G M E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - Unable to remove the segment. The segment is currently * - * in use. * - * * - *********************************************************************************/ -#define SCIRemoveSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSegment) -DLL void SCIRemoveSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T A V A I L A B L E * - * * - * Flags * - * None. * - * * - * * - * SCI_ERR_SEGMENT_NOT_PREPARED - The segment has not been prepared for access * - * from this adapter. * - * SCI_ERR_ILLEGAL_OPERATION - The segment is created with the * - * SCI_FLAG_PRIVATE flag specified and * - * therefore has no segmentId. * - * * - *********************************************************************************/ -#define SCISetSegmentAvailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentAvailable) -DLL void SCISetSegmentAvailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T U N A V A I L A B L E * - * * - * Flags * - * * - * SCI_FLAG_FORCE_DISCONNECT * - * SCI_FLAG_NOTIFY * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * * - *********************************************************************************/ -#define SCISetSegmentUnavailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentUnavailable) -DLL void SCISetSegmentUnavailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E M A P S E Q U E N C E * - * * - * Flags: * - * * - * SCI_FLAG_FAST_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateMapSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICreateMapSequence) -DLL void SCICreateMapSequence(sci_map_t map, - sci_sequence_t *sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E Q U E N C E * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSequence) -DLL void SCIRemoveSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T A R T S E Q U E N C E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIStartSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIStartSequence) -DLL sci_sequence_status_t SCIStartSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I C H E C K S E Q U E N CE * - * * - * Flags * - * * - * SCI_FLAG_NO_FLUSH * - * SCI_FLAG_NO_STORE_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICheckSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICheckSequence) -DLL sci_sequence_status_t SCICheckSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T O R E B A R R I E R * - * * - * Flags * - * None. * - * * - * * - * * - *********************************************************************************/ -#define SCIStoreBarrier _SISCI_EXPANDE_FUNCTION_NAME(SCIStoreBarrier) -DLL void SCIStoreBarrier(sci_sequence_t sequence, - unsigned int flags); - - - - -/********************************************************************************* - * * - * S C I F L U S H R E A D B U F F E R S * - * * - *********************************************************************************/ -#define SCIFlushReadBuffers _SISCI_EXPANDE_FUNCTION_NAME(SCIFlushReadBuffers) -DLL void SCIFlushReadBuffers(sci_sequence_t sequence); - - - - -/********************************************************************************* - * * - * S C I P R O B E N O D E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIProbeNode _SISCI_EXPANDE_FUNCTION_NAME(SCIProbeNode) -DLL int SCIProbeNode(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int nodeId, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIGetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCIGetCSRRegister) -DLL unsigned int SCIGetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCISetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCISetCSRRegister) -DLL void SCISetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I G E T L O C A L C S R * - * * - * SISCI Priveleged function * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIGetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCIGetLocalCSR) -DLL unsigned int SCIGetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T L O C A L C S R * - * * - * SISCI Priveleged function - * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCISetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCISetLocalCSR) -DLL void SCISetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A T T A C H P H Y S I C A L M E M O R Y * - * * - * SISCI Priveleged function * - * * - * Description: * - * * - * This function enables usage of physical devices and memory regions where the * - * Physical PCI bus address ( and mapped CPU address ) are already known. * - * The function will register the physical memory as a SISCI segment which can * - * be connected and mapped as a regular SISCI segment. * - * * - * Requirements: * - * * - * SCICreateSegment() with flag SCI_FLAG_EMPTY must have been called in advance * - * * - * Parameter description: * - * sci_ioaddr_t ioaddress : This is the address on the PCI bus that a PCI bus * - * master has to use to write to the specified memory * - * void * address : This is the (mapped) virtual address that the * - * application has to use to access the device. * - * This means that the device has to be mapped in * - * advance bye the devices own driver. * - * If the device is not to be accessed by the local * - * CPU, the address pointer shold be set to NULL * - * Flags * - * * - * None * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIAttachPhysicalMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachPhysicalMemory) -DLL void SCIAttachPhysicalMemory(sci_ioaddr_t ioaddress, - void *address, - unsigned int busNo, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I Q U E R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_QUERY - Unrecognized command. * - * * - *********************************************************************************/ -#define SCIQuery _SISCI_EXPANDE_FUNCTION_NAME(SCIQuery) -DLL void SCIQuery(unsigned int command, - void *data, - unsigned int flags, - sci_error_t *error); - - -/* MAJOR QUERY COMMANDS */ - -/* This command requires a pointer to a structure of type */ -/* "sci_query_string". The string will be filled in by the query. */ -#define SCI_Q_VENDORID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_VENDORID) -extern const unsigned int SCI_Q_VENDORID; - - -/* Same as for SCI_VENDOR_ID */ -#define SCI_Q_API _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_API) -extern const unsigned int SCI_Q_API; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_adapter" struct. */ -#define SCI_Q_ADAPTER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER) -extern const unsigned int SCI_Q_ADAPTER; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_system" struct. */ -#define SCI_Q_SYSTEM _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM) -extern const unsigned int SCI_Q_SYSTEM; - -#define SCI_Q_LOCAL_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT) -extern const unsigned int SCI_Q_LOCAL_SEGMENT; - -#define SCI_Q_REMOTE_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT) -extern const unsigned int SCI_Q_REMOTE_SEGMENT; - -#define SCI_Q_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP) -extern const unsigned int SCI_Q_MAP; - -typedef struct { - char *str; /* Pointer to a string of minimum "length" characters */ - unsigned int length; -} sci_query_string_t; - - -typedef struct { - unsigned int localAdapterNo; /* The adapter no. that the query concern. */ - unsigned int portNo; /* The SCI Link port number that the query concern. */ - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_adapter_t; - - -typedef struct { - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_system_t; - -typedef struct { - sci_local_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_local_segment_t; - -typedef struct { - sci_remote_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_remote_segment_t; - -typedef struct { - sci_map_t map; - unsigned int subcommand; - unsigned int data; -} sci_query_map_t; - -/* Minor query commands (sub-commands) for adapter specific information SCI_ADAPTER */ -#define SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_MTU _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_MTU) -extern const unsigned int SCI_Q_ADAPTER_DMA_MTU; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE; - -#define SCI_Q_ADAPTER_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NODEID) -extern const unsigned int SCI_Q_ADAPTER_NODEID; - -#define SCI_Q_ADAPTER_SERIAL_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SERIAL_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_SERIAL_NUMBER; - -#define SCI_Q_ADAPTER_CARD_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CARD_TYPE) -extern const unsigned int SCI_Q_ADAPTER_CARD_TYPE; - -#define SCI_Q_ADAPTER_NUMBER_OF_STREAMS _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER_OF_STREAMS) -extern const unsigned int SCI_Q_ADAPTER_NUMBER_OF_STREAMS; - -#define SCI_Q_ADAPTER_STREAM_BUFFER_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_STREAM_BUFFER_SIZE) -extern const unsigned int SCI_Q_ADAPTER_STREAM_BUFFER_SIZE; - -#define SCI_Q_ADAPTER_CONFIGURED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONFIGURED) -extern const unsigned int SCI_Q_ADAPTER_CONFIGURED; - -#define SCI_Q_ADAPTER_LINK_OPERATIONAL _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LINK_OPERATIONAL) -extern const unsigned int SCI_Q_ADAPTER_LINK_OPERATIONAL; - -#define SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK) -extern const unsigned int SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK; - -#define SCI_Q_ADAPTER_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_NUMBER; - -#define SCI_Q_ADAPTER_INSTANCE_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_INSTANCE_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_INSTANCE_NUMBER; - -#define SCI_Q_ADAPTER_FIRMWARE_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_FIRMWARE_OK) -extern const unsigned int SCI_Q_ADAPTER_FIRMWARE_OK; - -#define SCI_Q_ADAPTER_CONNECTED_TO_SWITCH _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_SWITCH) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_SWITCH; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER; - -#define SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT; - -#define SCI_Q_ADAPTER_ATT_PAGE_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_PAGE_SIZE) -extern const unsigned int SCI_Q_ADAPTER_ATT_PAGE_SIZE; - -#define SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES; - -#define SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES; - -#define SCI_Q_ADAPTER_PHYS_MEM_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MEM_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MEM_NODEID; - -#define SCI_Q_ADAPTER_PHYS_MBX_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MBX_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MBX_NODEID; - -#define SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID; - -#define SCI_Q_ADAPTER_SCI_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SCI_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_SCI_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_B_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_B_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_B_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_IO_BUS_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_IO_BUS_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_IO_BUS_FREQUENCY; - -/* Minor query commands (sub-commands) for adapter specific information SCI_SYSTEM */ -#define SCI_Q_SYSTEM_HOSTBRIDGE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_HOSTBRIDGE) -extern const unsigned int SCI_Q_SYSTEM_HOSTBRIDGE; - -#define SCI_Q_SYSTEM_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_POSTING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_POSTING_ENABLED; - -#define SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED; - -#define SCI_Q_LOCAL_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_LOCAL_SEGMENT_IOADDR; - -#define SCI_Q_REMOTE_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_REMOTE_SEGMENT_IOADDR; - -#define SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET; - -#define SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET; - -#define HOSTBRIDGE_NOT_AVAILABLE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_NOT_AVAILABLE) -extern const unsigned int HOSTBRIDGE_NOT_AVAILABLE; - -#define HOSTBRIDGE_UNKNOWN _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_UNKNOWN) -extern const unsigned int HOSTBRIDGE_UNKNOWN; - -#define HOSTBRIDGE_440FX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440FX) -extern const unsigned int HOSTBRIDGE_440FX; - -#define HOSTBRIDGE_440LX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440LX) -extern const unsigned int HOSTBRIDGE_440LX; - -#define HOSTBRIDGE_440BX_A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_A) -extern const unsigned int HOSTBRIDGE_440BX_A; - -#define HOSTBRIDGE_440BX_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_B) -extern const unsigned int HOSTBRIDGE_440BX_B; - -#define HOSTBRIDGE_440GX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440GX) -extern const unsigned int HOSTBRIDGE_440GX; - -#define HOSTBRIDGE_450KX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450KX) -extern const unsigned int HOSTBRIDGE_450KX; - -#define HOSTBRIDGE_430NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_430NX) -extern const unsigned int HOSTBRIDGE_430NX; - -#define HOSTBRIDGE_450NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX) -extern const unsigned int HOSTBRIDGE_450NX; - -#define HOSTBRIDGE_450NX_MICO _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_MICO) -extern const unsigned int HOSTBRIDGE_450NX_MICO; - -#define HOSTBRIDGE_450NX_PXB _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_PXB) -extern const unsigned int HOSTBRIDGE_450NX_PXB; - -#define HOSTBRIDGE_I810 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810) -extern const unsigned int HOSTBRIDGE_I810; - -#define HOSTBRIDGE_I810_DC100 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810_DC100) -extern const unsigned int HOSTBRIDGE_I810_DC100; - -#define HOSTBRIDGE_I810E _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810E) -extern const unsigned int HOSTBRIDGE_I810E; - -#define HOSTBRIDGE_I815 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I815) -extern const unsigned int HOSTBRIDGE_I815; - -#define HOSTBRIDGE_I840 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I840) -extern const unsigned int HOSTBRIDGE_I840; - -#define HOSTBRIDGE_I850 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I850) -extern const unsigned int HOSTBRIDGE_I850; - -#define HOSTBRIDGE_I860 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I860) -extern const unsigned int HOSTBRIDGE_I860; - -#define HOSTBRIDGE_VIA_KT133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KT133) -extern const unsigned int HOSTBRIDGE_VIA_KT133; - -#define HOSTBRIDGE_VIA_KX133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KX133) -extern const unsigned int HOSTBRIDGE_VIA_KX133; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_133A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_133A) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_133A; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_266 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_266) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_266; - -#define HOSTBRIDGE_AMD_760_MP _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_760_MP) -extern const unsigned int HOSTBRIDGE_AMD_760_MP; - -#define HOSTBRIDGE_SERVERWORKS_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE; - -#define HOSTBRIDGE_SERVERWORKS_HE_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE_B) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE_B; - -#define HOSTBRIDGE_SERVERWORKS_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_LE; - - - -#define HOSTBRIDGE_WRITE_POSTING_DISABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_DISABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_DISABLED; - -#define HOSTBRIDGE_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_ENABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_ENABLED; - - - - -/********************************************************************************* - * * - * S C I C R E A T E D M A Q U E U E * - * * - * Flags * - * * - * SCI_FLAG_DMA_PHDMA : Create physical DMA queue. Please note that this is an * - * priveleged operation. * - * * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCICreateDMAQueue) -DLL void SCICreateDMAQueue(sci_desc_t sd, - sci_dma_queue_t *dq, - unsigned int localAdapterNo, - unsigned int maxEntries, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Not allowed in this queue state. * - * * - *********************************************************************************/ -#define SCIRemoveDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveDMAQueue) -DLL void SCIRemoveDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I E N Q U E U E D M A T R A N S F E R * - * * - * Flags: * - * * - * SCI_FLAG_DMA_READ - The DMA will be remote --> local * - * (default is local --> remote) * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is larger * - * than the segment size or larger than max * - * DMA size. * - * SCI_ERR_MAX_ENTRIES - The DMA queue is full * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_SEGMENT_NOT_PREPARED - The local segment has not been prepared for * - * access from the adapter associated with the * - * queue. * - * SCI_ERR_SEGMENT_NOT_CONNECTED - The remote segment is not connected through * - * the adapter associated with the queue. * - *********************************************************************************/ -#define SCIEnqueueDMATransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIEnqueueDMATransfer) -DLL sci_dma_queue_state_t SCIEnqueueDMATransfer(sci_dma_queue_t dq, - sci_local_segment_t localSegment, - sci_remote_segment_t remoteSegment, - unsigned int localOffset, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P O S T D M A Q U E U E * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The end of the transfer will cause the callback * - * function to be invoked. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIPostDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIPostDMAQueue) -DLL void SCIPostDMAQueue(sci_dma_queue_t dq, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortDMAQueue) -DLL void SCIAbortDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I R E S E T D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIResetDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIResetDMAQueue) -DLL void SCIResetDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I D M A Q U E U E S T A T E * - * * - *********************************************************************************/ -#define SCIDMAQueueState _SISCI_EXPANDE_FUNCTION_NAME(SCIDMAQueueState) -DLL sci_dma_queue_state_t SCIDMAQueueState(sci_dma_queue_t dq); - - - -/********************************************************************************* - * * - * S C I W A I T F O R D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForDMAQueue) -DLL sci_dma_queue_state_t SCIWaitForDMAQueue(sci_dma_queue_t dq, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I P H D M A E N Q U E U E * - * * - * SISCI Priveleged function * - * * - * Flags * - * * - * SCI_FLAG_DMA_READ * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaEnqueue _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaEnqueue) -DLL void SCIphDmaEnqueue(sci_dma_queue_t dmaqueue, - unsigned int size, - sci_ioaddr_t localBusAddr, - unsigned int remote_nodeid, - unsigned int remote_highaddr, - unsigned int remote_lowaddr, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I P H D M A S T A R T * - * * - * Flags * - * * - * SCI_FLAG_DMA_WAIT * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_DMA_RESET * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaStart _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaStart) -DLL sci_dma_queue_state_t SCIphDmaStart(sci_dma_queue_t dmaqueue, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I C R E A T E I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_FIXED_INTNO * - * SCI_FLAG_SHARED_INT * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INTNO_USED - This interrupt number is already used. * - * * - *********************************************************************************/ -#define SCICreateInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCICreateInterrupt) -DLL void SCICreateInterrupt(sci_desc_t sd, - sci_local_interrupt_t *interrupt, - unsigned int localAdapterNo, - unsigned int *interruptNo, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveInterrupt) -DLL void SCIRemoveInterrupt(sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait was interrupted by a call to * - * SCIRemoveInterrupt. * - * The handle is invalid when this error code is returned.* - * * - *********************************************************************************/ -#define SCIWaitForInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForInterrupt) -DLL void SCIWaitForInterrupt(sci_local_interrupt_t interrupt, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_INTNO - No such interrupt number. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIConnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectInterrupt) -DLL void SCIConnectInterrupt(sci_desc_t sd, - sci_remote_interrupt_t *interrupt, - unsigned int nodeId, - unsigned int localAdapterNo, - unsigned int interruptNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisconnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectInterrupt) -DLL void SCIDisconnectInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R I G G E R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCITriggerInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCITriggerInterrupt) -DLL void SCITriggerInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I R E G I S T E R I N T E R R U P T F L A G * - * * - * * - * This function register an "interrupt flag" that is identified as an unique * - * location within a local segment. If successful, the resulting interrupt * - * handle will have been associated with the specified local segment. * - * * - * It is up to the (remote) client(s) to set up an "interrupt mapping" for the * - * corresponding segment offset using either the * - * * - * - SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * * - * or the * - * * - * - SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP * - * * - * option to "SCIMapRemoteSegment()". - I.e. after having established a * - * connection to the corresponding segment. A trigger operation can then * - * be implemented using a store operation via the relevant "interrupt map". * - * * - * * - * * - * * - * * - * Flags: * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT - Triggering is to take place using * - * "conditional interrupts". * - * * - * * - * * - * Specific error codes for this function: * - * None. * - * * - *********************************************************************************/ -#define SCIRegisterInterruptFlag _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterInterruptFlag) -DLL void SCIRegisterInterruptFlag( - unsigned int localAdapterNo, - sci_local_interrupt_t *interrupt, - sci_local_segment_t segment, - unsigned int offset, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I E N A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * This function make sure that another HW interrupt will take place the next * - * time the corresponding interrupt flag is triggered by a * - * "conditional interrupt" operation. * - * * - * Default semantics: * - * * - * When successful, the client can rely on that the first subsequent trigger * - * operation will cause a HW interrupt and subsequently cause the client * - * handler function to be invoked. * - * * - * If an interrupt was triggered in parallell with the enable operation, then * - * the operation will fail (SCI_ERR_COND_INT_RACE_PROBLEM), and the client can * - * not rely on another trigger operation will lead to handler invocation. * - * Hence, any state checking normally associated with handling the * - * corresponding interrupt should take place before attempting to enable * - * again. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_COND_INT_RACE_PROBLEM - The enable operation failed because an * - * incomming trigger operation happened * - * concurrently. * - * * - *********************************************************************************/ -#define SCIEnableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIEnableConditionalInterrupt) -DLL void SCIEnableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I D I S A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * Prevent subsequent "conditional interrupt"trigger operations for * - * the specified interupt flag from causing HW interrupt and handler * - * invocations. * - * * - * * - * Default semantics: * - * * - * If successful, no subsequent HW interrupts will take place, but handler * - * invocations that have already been scheduled may still take place. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisableConditionalInterrupt) -DLL void SCIDisableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C O N D I T I O N A L I N T E R R U P T C O U N T E R * - * * - * * - * Returns a value that indicates the number of times this flag has * - * been trigged since the last time it was enabled or disabled. * - * Calling the SCIEnableConditionalInterrupt / SCIDisableConditionalInterrupt * - * functions will reset the counter value. * - * * - * Default semantics: * - * * - * If successful, the current trig count is returned in the * - * interruptTrigCounter parameter. * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OVERFLOW - The number of trig operations have exceeded the range * - * that can be counted. * - *********************************************************************************/ -#define SCIGetConditionalInterruptTrigCounter _SISCI_EXPANDE_FUNCTION_NAME(SCIGetConditionalInterruptTrigCounter) -DLL void SCIGetConditionalInterruptTrigCounter( - sci_local_interrupt_t interrupt, - unsigned int *interruptTrigCounter, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlock _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlock) -DLL void SCITransferBlock(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K A S Y N C * - * * - * Flags * - * * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_USE_CALLBACK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger than * - * the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlockAsync _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlockAsync) -DLL void SCITransferBlockAsync(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - sci_block_transfer_t *block, - sci_cb_block_transfer_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForBlockTransfer) -DLL void SCIWaitForBlockTransfer(sci_block_transfer_t block, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortBlockTransfer) -DLL void SCIAbortBlockTransfer(sci_block_transfer_t block, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M E M C P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - -#define SCIMemCpy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCpy) -DLL void SCIMemCpy(sci_sequence_t sequence, - void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I M E M C O P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - - -#define SCIMemCopy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCopy) -DLL void SCIMemCopy(void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E G I S T E R S E G M E N T M E M O R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_ILLEGAL_ADDRESS - Illegal address. * - * SCI_ERR_OUT_OF_RANGE - Size is larger than the maximum size for the * - * local segment. * - * * - *********************************************************************************/ -#define SCIRegisterSegmentMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterSegmentMemory) -DLL void SCIRegisterSegmentMemory(void *address, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S C I S P A C E * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * * - *********************************************************************************/ -#define SCIConnectSCISpace _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSCISpace) -DLL void SCIConnectSCISpace(sci_desc_t sd, - unsigned int localAdapterNo, - sci_remote_segment_t *segment, - sci_address_t address, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/* - * ===================================================================================== - * - * S C I A T T A C H L O C A L S E G M E N T - * Description: - * - * SCIAttachLocalSegment() permits an application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events - * on this segment. - * - * - * Specific error codes for this function: - * - * SCI_ERR_ACCESS - No such shared segment - * SCI_ERR_NO_SUCH_SEGMENT - No such segment - * Note: Current implenentation will return SCI_ERR_ACCESS for both cases. This will - * change from next release. Application should handle both cases. - * - * ===================================================================================== - */ -#define SCIAttachLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachLocalSegment) - -DLL void -SCIAttachLocalSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int *size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); -/* - * ===================================================================================== - * - * S C I S H A R E S E G M E N T - * - * Description: - * - * SCIShareSegment() permits other application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * none - * - * Specific error codes for this function: - * - * - * - * ===================================================================================== - */ -#define SCIShareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIShareSegment) - -DLL void -SCIShareSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I F L U S H * - * * - * This function will flush the CPU buffers and the PSB buffers. * - * * - * Flags * - * SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY : * - * Only flush CPU buffers ( Write combining * - * etc buffers). * - * * - *********************************************************************************/ - -#define SCIFlush _SISCI_EXPANDE_FUNCTION_NAME(SCIFlush) -DLL void SCIFlush(sci_sequence_t sequence, - unsigned int flags); - -#if defined(CPLUSPLUS) || defined(__cplusplus) -} -#endif - - -#endif - - - - - - - - - - - diff --git a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_error.h b/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_error.h deleted file mode 100644 index aab7c136d3a..00000000000 --- a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_error.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $Id: sisci_error.h,v 1.1 2002/12/13 12:17:22 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SISCI_ERROR_H_ -#define _SISCI_ERROR_H_ - - -/* SCI Error return values always have 30 bit set */ -#define SCI_ERR_MASK 0x40000000 -#define SCI_ERR_REMOTE_MASK 0x01 /* Remote errors should have bit 0 set */ - -#define SCI_ERR(u) ((unsigned32)(u)&0x7FFFFFFF ) - -/* Error codes */ -typedef enum { - SCI_ERR_OK = 0x000, - - - SCI_ERR_BUSY = (0x900 | SCI_ERR_MASK), - SCI_ERR_FLAG_NOT_IMPLEMENTED = (0x901 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_FLAG = (0x902 | SCI_ERR_MASK), - SCI_ERR_NOSPC = (0x904 | SCI_ERR_MASK), - SCI_ERR_API_NOSPC = (0x905 | SCI_ERR_MASK), - SCI_ERR_HW_NOSPC = (0x906 | SCI_ERR_MASK), - SCI_ERR_NOT_IMPLEMENTED = (0x907 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADAPTERNO = (0x908 | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_ADAPTERNO = (0x909 | SCI_ERR_MASK), - SCI_ERR_TIMEOUT = (0x90A | SCI_ERR_MASK), - SCI_ERR_OUT_OF_RANGE = (0x90B | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_SEGMENT = (0x90C | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_NODEID = (0x90D | SCI_ERR_MASK), - SCI_ERR_CONNECTION_REFUSED = (0x90E | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_CONNECTED = (0x90F | SCI_ERR_MASK), - SCI_ERR_SIZE_ALIGNMENT = (0x910 | SCI_ERR_MASK), - SCI_ERR_OFFSET_ALIGNMENT = (0x911 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_PARAMETER = (0x912 | SCI_ERR_MASK), - SCI_ERR_MAX_ENTRIES = (0x913 | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_PREPARED = (0x914 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADDRESS = (0x915 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_OPERATION = (0x916 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_QUERY = (0x917 | SCI_ERR_MASK), - SCI_ERR_SEGMENTID_USED = (0x918 | SCI_ERR_MASK), - SCI_ERR_SYSTEM = (0x919 | SCI_ERR_MASK), - SCI_ERR_CANCELLED = (0x91A | SCI_ERR_MASK), - SCI_ERR_NOT_CONNECTED = (0x91B | SCI_ERR_MASK), - SCI_ERR_NOT_AVAILABLE = (0x91C | SCI_ERR_MASK), - SCI_ERR_INCONSISTENT_VERSIONS = (0x91D | SCI_ERR_MASK), - SCI_ERR_COND_INT_RACE_PROBLEM = (0x91E | SCI_ERR_MASK), - SCI_ERR_OVERFLOW = (0x91F | SCI_ERR_MASK), - SCI_ERR_NOT_INITIALIZED = (0x920 | SCI_ERR_MASK), - - SCI_ERR_ACCESS = (0x921 | SCI_ERR_MASK), - - SCI_ERR_NO_SUCH_NODEID = (0xA00 | SCI_ERR_MASK), - SCI_ERR_NODE_NOT_RESPONDING = (0xA02 | SCI_ERR_MASK), - SCI_ERR_NO_REMOTE_LINK_ACCESS = (0xA04 | SCI_ERR_MASK), - SCI_ERR_NO_LINK_ACCESS = (0xA05 | SCI_ERR_MASK), - SCI_ERR_TRANSFER_FAILED = (0xA06 | SCI_ERR_MASK) -} sci_error_t; - - -#endif /* _SCI_ERROR_H_ */ - - - diff --git a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_types.h b/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_types.h deleted file mode 100644 index 77989ffca59..00000000000 --- a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_types.h +++ /dev/null @@ -1,133 +0,0 @@ -/* $Id: sisci_types.h,v 1.1 2002/12/13 12:17:22 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SISCI_TYPES_H -#define _SISCI_TYPES_H - -#include "sisci_error.h" - -#ifndef IN -#define IN -#endif - -#ifndef OUT -#define OUT -#endif - -#ifndef IN_OUT -#define IN_OUT -#endif - -/* Opaque data types for descriptors/handles */ -typedef struct sci_desc *sci_desc_t; -typedef struct sci_local_segment *sci_local_segment_t; -typedef struct sci_remote_segment *sci_remote_segment_t; - -typedef struct sci_map *sci_map_t; -typedef struct sci_sequence *sci_sequence_t; -#ifndef KERNEL -typedef struct sci_dma_queue *sci_dma_queue_t; -#endif -typedef struct sci_remote_interrupt *sci_remote_interrupt_t; -typedef struct sci_local_interrupt *sci_local_interrupt_t; -typedef struct sci_block_transfer *sci_block_transfer_t; - -/* - * Constants defining reasons for segment callbacks: - */ - -typedef enum { - SCI_CB_CONNECT = 1, - SCI_CB_DISCONNECT, - SCI_CB_NOT_OPERATIONAL, - SCI_CB_OPERATIONAL, - SCI_CB_LOST -} sci_segment_cb_reason_t; - -#define MAX_CB_REASON SCI_CB_LOST - -/* dma_queue_states is identical to the dma_queue_state_t in genif.h, they must be consistent.*/ -typedef enum { - SCI_DMAQUEUE_IDLE, - SCI_DMAQUEUE_GATHER, - SCI_DMAQUEUE_POSTED, - SCI_DMAQUEUE_DONE, - SCI_DMAQUEUE_ABORTED, - SCI_DMAQUEUE_ERROR -} sci_dma_queue_state_t; - - -typedef enum { - SCI_SEQ_OK, - SCI_SEQ_RETRIABLE, - SCI_SEQ_NOT_RETRIABLE, - SCI_SEQ_PENDING -} sci_sequence_status_t; - - -typedef struct { - unsigned short nodeId; /* SCI Address bit 63 - 48 */ - unsigned short offsHi; /* SCI Address bit 47 - 32 */ - unsigned int offsLo; /* SCI Address bit 31 - 0 */ -} sci_address_t; - - -typedef unsigned int sci_ioaddr_t; - -typedef enum { - SCI_CALLBACK_CANCEL = 1, - SCI_CALLBACK_CONTINUE -} sci_callback_action_t; - -#ifndef KERNEL -typedef sci_callback_action_t (*sci_cb_local_segment_t)(void *arg, - sci_local_segment_t segment, - sci_segment_cb_reason_t reason, - unsigned int nodeId, - unsigned int localAdapterNo, - sci_error_t error); - -typedef sci_callback_action_t (*sci_cb_remote_segment_t)(void *arg, - sci_remote_segment_t segment, - sci_segment_cb_reason_t reason, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_dma_t)(void IN *arg, - sci_dma_queue_t queue, - sci_error_t status); - - -typedef int (*sci_cb_block_transfer_t)(void *arg, - sci_block_transfer_t block, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_interrupt_t)(void *arg, - sci_local_interrupt_t interrupt, - sci_error_t status); - -#endif /* KERNEL */ -#endif diff --git a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_version.h b/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_version.h deleted file mode 100644 index c2fccb9ec33..00000000000 --- a/ndb/src/external/SOLARIS.SPARC/sci/include/sisci_version.h +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id: sisci_version.h,v 1.1 2002/12/13 12:17:22 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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 SISCI_VERSION_H -#define SISCI_VERSION_H - - -#define SISCI_API_VER_MAJOR 1 -#define SISCI_API_VER_MAJORC "1" - -#define SISCI_API_VER_MINOR 10 -#define SISCI_API_VER_MINORC "10" -#define SISCI_API_VER_MICRO 4 -#define SISCI_API_VER_MICROC "4" - -#define SISCI_SIGN_VERSION_MASK 0xfffff000 /* used to mask off API_VER_MICRO */ - -#define SISCI_API_VERSION (SISCI_API_VER_MAJOR << 24 | SISCI_API_VER_MINOR << 12 | SISCI_API_VER_MICRO) - -/* the rules are: - * - * Changes in API_VER_MICRO should be binary compatible, New flags, functions added. No changes to user code - * required if new features is not needed. - * - * Changes in API_VER_MINOR requires recompilation of user code. - * - * Changes in the API_VER_MAJOR will most likely require changes to user code. This should not happen very - * often... - * - */ - -#ifndef BUILD_DATE -#define BUILD_DATE __DATE__ -#endif - -#ifndef BUILD_NAME -#define BUILD_NAME "" -#endif - -#define API_VERSION "SISCI API version " SISCI_API_VER_MAJORC "." SISCI_API_VER_MINORC "."SISCI_API_VER_MICROC " ( "BUILD_NAME" "BUILD_DATE" )" - -#endif - - -/* Version info: */ -/* */ -/* 1.5.2 First SISCI version */ -/* 1.5.3 Some bug fixes */ -/* 1.5.4 Some bug fixes */ -/* 1.5.5 No release */ -/* 1.5.6 Lock flag implemented in function SCIConnectSegment */ -/* 1.5.7 Expanded query functionality */ -/* 1.5.8 Updated error checking (sequence) functionality for D320 */ -/* 1.6.0 Updated error checking (sequence) D320 and IRM 1.9 support */ -/* 1.9.0 Ported to Solaris_sparc, Solaris_x86 and Linux. IRM 1.9. */ -/* 1.9.1 Some bug fixes */ -/* 1.9.2 Added more adapter queries */ -/* 1.9.3 Bug fix in SCIMapLocalSegment and SCIMapRemoteSegment */ -/* 1.9.4 NT Release Developers Kit 2.40 */ -/* 1.9.5 Added flush after data transfer in SCIMemCopy() */ -/* 1.9.5 NT Release Developers Kit 2.44 */ -/* 1.10.0: - * New SCIInitialize(), SCITerminate() functions. - * Support for D330 - * - * - */ - - diff --git a/ndb/src/external/WIN32.x86/sci/include/rmlib.h b/ndb/src/external/WIN32.x86/sci/include/rmlib.h deleted file mode 100644 index 87ba20db99f..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/rmlib.h +++ /dev/null @@ -1,212 +0,0 @@ -/* $Id: rmlib.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/********************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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. * - * * - * * - *********************************************************************************/ - -/********************************************************************************/ -/* This header file contains the declarations of the SCI Reflective Memory */ -/* library rmlib. The implementation of the library functions is in rmlib.c. */ -/* The library contains all the functions that operate on the reflective */ -/* memory. */ -/* */ -/* NB! */ -/* */ -/* DOLPHIN'S SCI REFLECTIVE MEMORY FILES ARE UNDER DEVELOPMENT AND MAY CHANGE. */ -/* PLEASE CONTACT DOLPHIN FOR FURTHER INFORMATION. */ -/* */ -/* */ -/********************************************************************************/ - -#include "sisci_error.h" -#include "sisci_api.h" -#include "sisci_demolib.h" -#include "sisci_types.h" - -unsigned int seqerr, syncseqerr; - -#ifndef _RMLIB_H -#define _RMLIB_H - - -#if defined(_REENTRANT) - -#define _RMLIB_EXPAND_NAME(name) _RMLIB_MT_ ## name - -#else - -#define _RMLIB_EXPAND_NAME(name) _RMLIB_ST_ ## name - -#endif - -#ifdef __sparc -#define CACHE_SIZE 2097152 -#else -#define CACHE_SIZE 8192 -#endif - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define REFLECT_ERRCHECK 0x2 - -struct ReflectiveMemorySpace { - unsigned int localAdapterNo; - unsigned int localNodeId; - unsigned int remoteNodeId; - sci_desc_t sd; - sci_desc_t syncsd; - sci_map_t localMap; - sci_map_t remoteMap; - unsigned int localSegmentId; - unsigned int remoteSegmentId; - unsigned int syncSegmentId; - unsigned int sync_rSegmentId; - unsigned int segmentSize; - unsigned int *localMapAddr; - volatile unsigned int *remoteMapAddr; - sci_local_segment_t localSegment; - sci_remote_segment_t remoteSegment; - sci_local_segment_t syncSegment; - sci_remote_segment_t sync_rSegment; - sci_map_t syncMap; - sci_map_t sync_rMap; - sci_sequence_t syncsequence; - sci_sequence_t sequence; - unsigned int protection; - unsigned int retry_value; - sci_sequence_status_t sequenceStatus, syncsequenceStatus; - volatile unsigned int *syncMapAddr; - volatile unsigned int *sync_rMapAddr; -}; - -/*********************************************************************************/ -/* P R I N T R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectPrintParameters _RMLIB_EXPAND_NAME(ReflectPrintParameters) -void ReflectPrintParameters(FILE *stream, struct ReflectiveMemorySpace RM_space); - -/*********************************************************************************/ -/* R E F L E C T D M A S E T U P */ -/* */ -/*********************************************************************************/ -#define ReflectDmaSetup _RMLIB_EXPAND_NAME(ReflectDmaSetup) -sci_error_t ReflectDmaSetup(struct ReflectiveMemorySpace RM_space, sci_dma_queue_t *dmaQueue); - -/*********************************************************************************/ -/* R E F L E C T D M A R E M O V E */ -/* */ -/*********************************************************************************/ -#define ReflectDmaRemove _RMLIB_EXPAND_NAME(ReflectDmaRemove) -sci_error_t ReflectDmaRemove(sci_dma_queue_t dmaQueue); - -/*********************************************************************************/ -/* R E F L E C T D M A R U N */ -/* */ -/*********************************************************************************/ -#define ReflectDmaRun _RMLIB_EXPAND_NAME(ReflectDmaRun) -sci_error_t ReflectDmaRun(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset, - sci_dma_queue_t dmaQueue); -/*********************************************************************************/ -/* C L O S E R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectClose _RMLIB_EXPAND_NAME(ReflectClose) -sci_error_t ReflectClose(struct ReflectiveMemorySpace RM_space, unsigned int segment_no); - -/*********************************************************************************/ -/* O P E N R E F L E C T I V E M E M O R Y S P A C E */ -/* */ -/*********************************************************************************/ -#define ReflectOpen _RMLIB_EXPAND_NAME(ReflectOpen) -sci_error_t ReflectOpen(struct ReflectiveMemorySpace *RM_space, - unsigned int size, - unsigned int segment_no, - unsigned int localAdapterNo, - unsigned int remoteNodeId, - unsigned int protection, - unsigned int retry_value); - -/*********************************************************************************/ -/* R E F L E C T G E T A C C E S S */ -/* */ -/*********************************************************************************/ -#define ReflectGetAccess _RMLIB_EXPAND_NAME(ReflectGetAccess) -sci_error_t ReflectGetAccess(struct ReflectiveMemorySpace *RM_space); - -/*********************************************************************************/ -/* R E F L E C T R E L E A S E A C C E S S */ -/* */ -/*********************************************************************************/ -#define ReflectReleaseAccess _RMLIB_EXPAND_NAME(ReflectReleaseAccess) -sci_error_t ReflectReleaseAccess(struct ReflectiveMemorySpace *RM_space); - -/*********************************************************************************/ -/* R E F L E C T D M A */ -/* */ -/*********************************************************************************/ -#define ReflectDma _RMLIB_EXPAND_NAME(ReflectDma) -sci_error_t ReflectDma(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset); - -/*********************************************************************************/ -/* R E F L E C T M E M C O P Y */ -/* */ -/*********************************************************************************/ -#define ReflectMemCopy _RMLIB_EXPAND_NAME(ReflectMemCopy) -sci_error_t ReflectMemCopy(struct ReflectiveMemorySpace RM_space, - unsigned int* privateSrc, - unsigned int size, - unsigned int offset, - unsigned int flags); - -/*********************************************************************************/ -/* R E F L E C T S E T */ -/* */ -/*********************************************************************************/ -#define ReflectSet _RMLIB_EXPAND_NAME(ReflectSet) -sci_error_t ReflectSet(struct ReflectiveMemorySpace RM_space, - unsigned int value, - unsigned int size, - unsigned int offset, - unsigned int flags - ); - -/*********************************************************************************/ -/* R E F L E C T P R I N T */ -/* */ -/*********************************************************************************/ -#define ReflectPrint _RMLIB_EXPAND_NAME(ReflectPrint) -sci_error_t ReflectPrint(FILE *stream, - struct ReflectiveMemorySpace RM_space, - unsigned int size, - unsigned int offset - ); - - -#endif diff --git a/ndb/src/external/WIN32.x86/sci/include/scilib.h b/ndb/src/external/WIN32.x86/sci/include/scilib.h deleted file mode 100644 index d1501082bab..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/scilib.h +++ /dev/null @@ -1,330 +0,0 @@ -/* $Id: scilib.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 2002 * - * Dolphin Interconnect Solutions AS * - * * - *******************************************************************************/ - - -#if defined(_REENTRANT) -#define _SCIL_EXPANDE_FUNCTION_NAME(name) _SCIL_PUBLIC_FUNC_MT_ ## name -#define _SCIL_EXPANDE_VARIABLE_NAME(name) _SCIL_PUBLIC_VAR_MT_ ## name -#else -#define _SCIL_EXPANDE_FUNCTION_NAME(name) _SCIL_PUBLIC_FUNC_ST_ ## name -#define _SCIL_EXPANDE_VARIABLE_NAME(name) _SCIL_PUBLIC_VAR_ST_ ## name -#endif -#define _SCIL_EXPANDE_CONSTANT_NAME(name) _SCIL_PUBLIC_CONST_ ## name - -#include "sisci_api.h" - -#if defined(CPLUSPLUS) || defined(__cplusplus) -extern "C" { -#endif - - -/* - * SISCI segment id pollution: - * =========================== - * The SISCI library uses regular SISCI segmens internally. - * The MSG_QUEUE_LIB_IDENTIFIER_MASK is a mask which is used by the SISCI - * library to identify internal SISCI segments ids, from segments used directly - * by the user. - * - * Future versions of the library may have its own namespace. - * - */ - -#define MSG_QUEUE_LIB_IDENTIFIER_MASK 0x10000000 - - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define SCIL_FLAG_ERROR_CHECK_DATA _SCIL_EXPANDE_CONSTANT_NAME(SCIL_FLAG_ERROR_CHECK_DATA) -extern const unsigned int SCIL_FLAG_ERROR_CHECK_DATA; - -#define SCIL_FLAG_ERROR_CHECK_PROT _SCIL_EXPANDE_CONSTANT_NAME(SCIL_FLAG_ERROR_CHECK_PROT) -extern const unsigned int SCIL_FLAG_ERROR_CHECK_PROT; - -#define SCIL_FLAG_FULL_ERROR_CHECK _SCIL_EXPANDE_CONSTANT_NAME(SCIL_FLAG_FULL_ERROR_CHECK) -extern const unsigned int SCIL_FLAG_FULL_ERROR_CHECK; - - - - - -typedef struct sci_msq_queue *sci_msq_queue_t; - - -/********************************************************************************* - * * - * S C I L C r e a t e M s g Q u e u e * - * * - * Parameters: * - * * - * Creates a message queue. The message queue identifier object will be allocated* - * if the sci_msq_queue_t * msg pointer is NULL. The function will create a * - * remote connection. If this connection times out, the function shoud be * - * repeated until connection is established. SCILRemoveMsgQueue() must be called * - * to remove the connection and deallocate the message queue identifier. * - * * - * sci_msq_queue_t *msq : Message queue identifier * - * The function must be called with a null pointer * - * the first time. * - * unsigned int localAdapterNo: Local Adapter Number * - * unsigned int remoteNodeId : Remote nodeId * - * unsigned int msqId : Message queue number * - * unsigned int maxMsgCount : The maximum count of messages in queue * - * unsigned int maxMsgSize, : The maximum size of each messages in queue * - * unsigned int timeout : Time to wait for successful connection * - * unsigned int flags : Flags. * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None. Normal SISIC error codes. * - * * - *********************************************************************************/ -#define SCILCreateMsgQueue _SCIL_EXPANDE_FUNCTION_NAME(SCILCreateMsgQueue) -DLL sci_error_t SCILCreateMsgQueue(sci_msq_queue_t *msq, - unsigned int localAdapterNo, - unsigned int remoteNodeId, - unsigned int msqId, - unsigned int maxMsgCount, - unsigned int maxMsgSize, - unsigned int timeout, - unsigned int flags); - - -/********************************************************************************* - * * - * S C I L R e c e i v e M s g * - * * - * * - * Receives a message from the queue. * - * * - * Paremeters * - * * - * sci_msq_queue_t msq : message queue identifier * - * void *msg : Location to store received data * - * unsigned int size : Size of message to read * - * unsigned int *sizeLeft: Bytes left in buffer, after current receive. This is * - * just a hint. There may be more. * - * * - * Flags * - * * - * SCIL_FLAG_ERROR_CHECK_PROT: The internal buffer management is done using full* - * error checking. - * * - * Specific error codes for this function: * - * * - * SCI_ERR_EWOULD_BLOCK : There is not enough data in the message buffer * - * to read the specified number of bytes. * - * . * - * SCI_ERR_NOT_CONNECTED : The connection is not established. * - * * - *********************************************************************************/ -#define SCILReceiveMsg _SCIL_EXPANDE_FUNCTION_NAME(SCILReceiveMsg) -DLL sci_error_t SCILReceiveMsg( - sci_msq_queue_t msq, - void *msg, - unsigned int size, - unsigned int *sizeLeft, - unsigned int flags); - - - -/********************************************************************************* - * * - * S C I L S e n d M s g * - * * - * * - * Sends a message to the queue. * - * * - * Paremeters * - * * - * sci_msq_queue_t msq : Message queue identifier * - * void *msg : Send data * - * unsigned int size : Size of message to send * - * unsigned int *sizeFree: Bytes free in buffer, after current send. This is * - * just a hint. There may be more. * - * * - * Flags * - * * - * SCIL_FLAG_ERROR_CHECK_DATA: The data is transmitted using full error checking* - * SCIL_FLAG_ERROR_CHECK_PROT: The internal buffer management is done using full* - * error checking. * - * SCIL_FLSG_FULL_ERROR_CHECK: This flag is an combination of both above. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_EWOULD_BLOCK : There is not enough data in the message buffer * - * to send the specified number of bytes. * - * . * - * SCI_ERR_NOT_CONNECTED : The connection is not established. * - * * - *********************************************************************************/ -#define SCILSendMsg _SCIL_EXPANDE_FUNCTION_NAME(SCILSendMsg) -DLL sci_error_t SCILSendMsg( - sci_msq_queue_t msq, - void *msg, - unsigned int size, - unsigned int *sizeFree, - unsigned int flags); - - -/********************************************************************************* - * * - * S C I L R e m o v e M s g Q u e ue * - * * - * * - * Removes a message queue. * - * * - * sci_msq_queue_t msq : Message queue identifier * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCILRemoveMsgQueue _SCIL_EXPANDE_FUNCTION_NAME(SCILRemoveMsgQueue) -DLL sci_error_t SCILRemoveMsgQueue( - sci_msq_queue_t *msq, - unsigned int flags); - - - -/********************************************************************************* - * * - * S C I L I n i t * - * * - * * - * Initializes the SCI library. This function must be called before any other * - * function in the library. * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * . * - *********************************************************************************/ -#define SCILInit _SCIL_EXPANDE_FUNCTION_NAME(SCILInit) -DLL sci_error_t SCILInit(unsigned int flags); - - - -/********************************************************************************* - * * - * S C I L D e s t r o y * - * * - * * - * Removes internal resources allocated by the SCI Library. No other library * - * function should be called after this function. * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCILDestroy _SCIL_EXPANDE_FUNCTION_NAME(SCILDestroy) -DLL sci_error_t SCILDestroy(unsigned int flags); - - - -/********************************************************************************* - * * - * S C I L C o n n e c t M s g Q u e u e * - * * - * * - * Makes a connection to a remote message queue. This must be done before * - * SCILSendMsg() is called. * - * * - * Parameters: * - * * - * sci_msq_queue_t *msq : Message queue identifier * - * unsigned int localAdapterNo: Local Adapter Number * - * unsigned int remoteNodeId : Remote nodeId * - * unsigned int msqId : Message queue number * - * unsigned int maxMsgCount : The maximum count of messages in queue * - * unsigned int maxMsgSize, : The maximum size of each messages in queue * - * unsigned int timeout : Time to wait for successful connection * - * unsigned int flags : Flags. * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None. Normal SISIC error codes. * - * * - *********************************************************************************/ -#define SCILConnectMsgQueue _SCIL_EXPANDE_FUNCTION_NAME(SCILConnectMsgQueue) -DLL sci_error_t SCILConnectMsgQueue(sci_msq_queue_t *msq, - unsigned int localAdapterNo, - unsigned int remoteNodeId, - unsigned int rmsgId, - unsigned int maxMsgCount, - unsigned int maxMsgSize, - unsigned int timeout, - unsigned int flags); - - - - -/********************************************************************************* - * * - * S C I L D i s c o n n e c t M s g Q u e u e * - * * - * * - * Disconnects from a remote message queue. * - * * - * Parameters: * - * * - * sci_msq_queue_t *msq : Message queue identifier * - * * - * Flags * - * * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCILDisconnectMsgQueue _SCIL_EXPANDE_FUNCTION_NAME(SCILDisconnectMsgQueue) -DLL sci_error_t SCILDisconnectMsgQueue(sci_msq_queue_t *msq, - unsigned int flags); - - - -#if defined(CPLUSPLUS) || defined(__cplusplus) -} -#endif - - - - - - - - - - diff --git a/ndb/src/external/WIN32.x86/sci/include/sisci_api.h b/ndb/src/external/WIN32.x86/sci/include/sisci_api.h deleted file mode 100644 index 9f4a1ddffb3..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/sisci_api.h +++ /dev/null @@ -1,2217 +0,0 @@ -/* $Id: sisci_api.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ -/******************************************************************************* - * * - * Copyright (C) 1993 - 2001 * - * Dolphin Interconnect Solutions AS * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as published by * - * the Free Software Foundation; either version 2.1 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 Lesser 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 _SISCI_API_H -#define _SISCI_API_H - -#include "sisci_types.h" -#include "sisci_error.h" - - -#ifdef WIN32 -#ifdef API_DLL -#define DLL __declspec(dllexport) -#elif CLIENT_DLL -#define DLL __declspec(dllimport) -#endif -#endif /* WIN32 */ - - -#ifndef DLL -#define DLL -#endif - -#if defined(_REENTRANT) -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_MT_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_MT_ ## name -#else -#define _SISCI_EXPANDE_FUNCTION_NAME(name) _SISCI_PUBLIC_FUNC_ST_ ## name -#define _SISCI_EXPANDE_VARIABLE_NAME(name) _SISCI_PUBLIC_VAR_ST_ ## name -#endif -#define _SISCI_EXPANDE_CONSTANT_NAME(name) _SISCI_PUBLIC_CONST_ ## name - -#if defined(CPLUSPLUS) || defined(__cplusplus) -extern "C" { -#endif - - -/*********************************************************************************/ -/* FLAG VALUES */ -/*********************************************************************************/ - -#define SCI_FLAG_FIXED_INTNO _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_INTNO) -extern const unsigned int SCI_FLAG_FIXED_INTNO; - -#define SCI_FLAG_SHARED_INT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_INT) -extern const unsigned int SCI_FLAG_SHARED_INT; - -#define SCI_FLAG_COUNTING_INT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_COUNTING_INT) -extern const unsigned int SCI_FLAG_COUNTING_INT; - -#define SCI_FLAG_FIXED_MAP_ADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FIXED_MAP_ADDR) -extern const unsigned int SCI_FLAG_FIXED_MAP_ADDR; - -#define SCI_FLAG_READONLY_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READONLY_MAP) -extern const unsigned int SCI_FLAG_READONLY_MAP; - -#define SCI_FLAG_USE_CALLBACK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_USE_CALLBACK) -extern const unsigned int SCI_FLAG_USE_CALLBACK; - -#define SCI_FLAG_BLOCK_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_BLOCK_READ) -extern const unsigned int SCI_FLAG_BLOCK_READ; - -#define SCI_FLAG_THREAD_SAFE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_THREAD_SAFE) -extern const unsigned int SCI_FLAG_THREAD_SAFE; - -#define SCI_FLAG_ASYNCHRONOUS_CONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ASYNCHRONOUS_CONNECT) -extern const unsigned int SCI_FLAG_ASYNCHRONOUS_CONNECT; - -#define SCI_FLAG_EMPTY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_EMPTY) -extern const unsigned int SCI_FLAG_EMPTY; - -#define SCI_FLAG_PRIVATE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_PRIVATE) -extern const unsigned int SCI_FLAG_PRIVATE; - -#define SCI_FLAG_FORCE_DISCONNECT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FORCE_DISCONNECT) -extern const unsigned int SCI_FLAG_FORCE_DISCONNECT; - -#define SCI_FLAG_NOTIFY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NOTIFY) -extern const unsigned int SCI_FLAG_NOTIFY; - -#define SCI_FLAG_DMA_READ _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_READ) -extern const unsigned int SCI_FLAG_DMA_READ; - -#define SCI_FLAG_DMA_POST _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_POST) -extern const unsigned int SCI_FLAG_DMA_POST; - -#define SCI_FLAG_DMA_WAIT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_WAIT) -extern const unsigned int SCI_FLAG_DMA_WAIT; - -#define SCI_FLAG_DMA_RESET _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_RESET) -extern const unsigned int SCI_FLAG_DMA_RESET; - -#define SCI_FLAG_NO_FLUSH _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_FLUSH) -extern const unsigned int SCI_FLAG_NO_FLUSH; - -#define SCI_FLAG_NO_STORE_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_STORE_BARRIER) -extern const unsigned int SCI_FLAG_NO_STORE_BARRIER; - -#define SCI_FLAG_FAST_BARRIER _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FAST_BARRIER) -extern const unsigned int SCI_FLAG_FAST_BARRIER; - -#define SCI_FLAG_ERROR_CHECK _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_ERROR_CHECK) -extern const unsigned int SCI_FLAG_ERROR_CHECK; - -#define SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) -extern const unsigned int SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY; - -/* the FLUSH_CPU_BUFFERS_ONLY flag is for backwards compabillity only and should never be used */ -#define FLUSH_CPU_BUFFERS_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY) - -#define SCI_FLAG_LOCK_OPERATION _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_LOCK_OPERATION) -extern const unsigned int SCI_FLAG_LOCK_OPERATION; - -#define SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP; - -#define SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP) -extern const unsigned int SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP; - -#define SCI_FLAG_IO_MAP_IOSPACE _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_IO_MAP_IOSPACE) -extern const unsigned int SCI_FLAG_IO_MAP_IOSPACE; - -#define SCI_FLAG_DMOVE_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMOVE_MAP) -extern const unsigned int SCI_FLAG_DMOVE_MAP; - -#define SCI_FLAG_WRITES_DISABLE_GATHER_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_WRITES_DISABLE_GATHER_MAP) -extern const unsigned int SCI_FLAG_WRITES_DISABLE_GATHER_MAP; - -#define SCI_FLAG_DISABLE_128_BYTES_PACKETS _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DISABLE_128_BYTES_PACKETS) -extern const unsigned int SCI_FLAG_DISABLE_128_BYTES_PACKETS; - -#define SCI_FLAG_SHARED_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_SHARED_MAP) -extern const unsigned int SCI_FLAG_SHARED_MAP; - -#define SCI_FLAG_DMA_SOURCE_ONLY _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_SOURCE_ONLY) -extern const unsigned int SCI_FLAG_DMA_SOURCE_ONLY; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT; - -#define SCI_FLAG_CONDITIONAL_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_CONDITIONAL_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_CONDITIONAL_INTERRUPT_MAP; - -#define SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP) -extern const unsigned int SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP; - -#define SCI_FLAG_NO_MEMORY_LOOPBACK_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_NO_MEMORY_LOOPBACK_MAP) -extern const unsigned int SCI_FLAG_NO_MEMORY_LOOPBACK_MAP; - -#if defined(OS_IS_LYNXOS) || defined(OS_IS_VXWORKS) -#define SCI_FLAG_WRITE_BACK_CACHE_MAP _SISCI_EXPANDE_CONSTANT_NAME(WRITE_BACK_CACHE_MAP) -extern const unsigned int SCI_FLAG_WRITE_BACK_CACHE_MAP; -#endif - -#define SCI_FLAG_DMA_PHDMA _SISCI_EXPANDE_CONSTANT_NAME(SCI_FLAG_DMA_PHDMA) -extern const unsigned int SCI_FLAG_DMA_PHDMA; - -/*********************************************************************************/ -/* GENERAL VALUES */ -/*********************************************************************************/ -#define SCI_LOCAL_HOST _SISCI_EXPANDE_CONSTANT_NAME(SCI_LOCAL_HOST) -extern const unsigned int SCI_LOCAL_HOST; - -#define SCI_INFINITE_TIMEOUT _SISCI_EXPANDE_CONSTANT_NAME(SCI_INFINITE_TIMEOUT) -extern const unsigned int SCI_INFINITE_TIMEOUT; - -/*********************************************************************************/ -/* GENERAL ERROR CODES */ -/* */ -/* SCI_ERR_ILLEGAL_FLAG - Illegal flag value. */ -/* SCI_ERR_FLAG_NOT_IMPLEMENTED - Flag legal but flag feature not implemented. */ -/* SCI_ERR_NOT_IMPLEMENTED - Function not implemented. */ -/* SCI_ERR_SYSTEM - A system error. Check errno. */ -/* SCI_ERR_NOSPC - Unable to allocate OS resources. */ -/* SCI_ERR_API_NOSPC - Unable to allocate API resources. */ -/* SCI_ERR_HW_NOSPC - Unable to allocate HW resources (Hardware) */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "ADAPTER" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_ADAPTERNO - Adapter number is legal but does not exist. */ -/* SCI_ERR_ILLEGAL_ADAPTERNO - Illegal local adapter number (i.e. outside */ -/* legal range). */ -/* */ -/*********************************************************************************/ - - -/*********************************************************************************/ -/* GENERAL "NODEID" ERROR CODES */ -/* */ -/* SCI_ERR_NO_SUCH_NODEID - The remote adapter identified by nodeId does */ -/* not respond, but the intermediate link(s) */ -/* seem(s) to be operational. */ -/* SCI_ERR_ILLEGAL_NODEID - Illegal NodeId. */ -/* */ -/*********************************************************************************/ - - - -/********************************************************************************* - * * - * S C I I N I T I A L I Z E * - * * - * This function initializes the SISCI library. * - * The function must be called before SCIOpen(). * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * None * - * * - *********************************************************************************/ -#define SCIInitialize _SISCI_EXPANDE_FUNCTION_NAME(SCIInitialize) -DLL void SCIInitialize(unsigned int flags, - sci_error_t *error); -#if 0 -unsigned int __Internal_SISCI_version_var; -#endif - -/********************************************************************************* - * * - * S C I T E R M I N A T E * - * * - * This function terminates the SISCI library. * - * The function must be called after SCIClose(). * - * * - * * - *********************************************************************************/ -#define SCITerminate _SISCI_EXPANDE_FUNCTION_NAME(SCITerminate) -DLL void SCITerminate(void); - -/********************************************************************************* - * * - * S C I O P E N * - * * - * * - * Opens a SCI virtual device. * - * Caller must supply a pointer to a variable of type sci_desc_t to be * - * initialized. * - * * - * Flags * - * SCI_FLAG_THREAD_SAFE - Operations on resources associated with this * - * descriptor will be performed in a multithread-safe * - * manner. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INCONSISTENT_VERSIONS - Inconsistency between the SISCI library * - * and the SISCI driver versions. * - * * - * * - *********************************************************************************/ -#define SCIOpen _SISCI_EXPANDE_FUNCTION_NAME(SCIOpen) -DLL void SCIOpen(sci_desc_t *sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C L O S E * - * * - * This function closes an open SCI virtual device. * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - All resources are not deallocated. * - * * - *********************************************************************************/ -#define SCIClose _SISCI_EXPANDE_FUNCTION_NAME(SCIClose) -DLL void SCIClose(sci_desc_t sd, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S E G M E N T * - * * - * Connects to a remote shared memory segment located at <nodeId> with the * - * identifier <segmentId>. * - * The user may then call SCIMapRemoteSegment() to map shared memory * - * into user space. * - * * - * Flags * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_ASYNCHRONOUS_CONNECT * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_SEGMENT - Could not find the remote segment with the * - * given segmentId. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIConnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSegment) -DLL void SCIConnectSegment(sci_desc_t sd, - sci_remote_segment_t *segment, - unsigned int nodeId, - unsigned int segmentId, - unsigned int localAdapterNo, - sci_cb_remote_segment_t callback, - void *callbackArg, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T S E G M E N T * - * * - * Disconnects from the give mapped shared memory segment * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The segment is currently mapped or in use. * - * * - *********************************************************************************/ -#define SCIDisconnectSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectSegment) -DLL void SCIDisconnectSegment(sci_remote_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T R E M O T E S E G M E N T S I Z E * - * * - *********************************************************************************/ -#define SCIGetRemoteSegmentSize _SISCI_EXPANDE_FUNCTION_NAME(SCIGetRemoteSegmentSize) -DLL unsigned int SCIGetRemoteSegmentSize(sci_remote_segment_t segment); - - - -/********************************************************************************* - * * - * S C I W A I T F O R R E M O T E S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du * - * to a SCIDisconnectSegment() on the same * - * handle. The handle is invalid when this * - * error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForRemoteSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForRemoteSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForRemoteSegmentEvent( - sci_remote_segment_t segment, - sci_error_t *status, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P R E M O T E S E G M E N T * - * * - * This function is used to include a shared memory segment in the virtual * - * address space of the application. * - * * - * Flags: * - * * - * SCI_FLAG_SHARED_MAP - The low level physical map may be shared by * - * other applications. * - * * - * SCI_FLAG_FIXED_MAP_ADDR - Map at the suggested virtual address * - * SCI_FLAG_READONLY_MAP - The segment is mapped in read-only mode * - * SCI_FLAG_LOCK_OPERATION - Enable Lock operations (fetch and add) * - * SCI_FLAG_READ_PREFETCH_AGGR_HOLD_MAP * - * - Enable aggressive prefetch with speculative * - * hold. * - * * - * SCI_FLAG_READ_PREFETCH_NO_HOLD_MAP * - * - The PSB66 will prefetch 64 bytes. As soon * - * as the PCI read retry has been accepted, * - * the stream will change state to FREE, even * - * if less than 64 bytes were actually read. * - * * - * SCI_FLAG_IO_MAP_IOSPACE - Enable No Prefetch, no speculative hold. * - * * - * SCI_FLAG_DMOVE_MAP - Enable DMOVE packet type. The stream will be * - * set into FREE state immediately. * - * * - * SCI_FLAG_WRITES_DISABLE_GATHER_MAP * - * - Disable use of gather. * - * * - * SCI_FLAG_DISABLE_128_BYTES_PACKETS * - * - Disable use of 128-Byte packets * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an atomic "fetch-and-add-one" operation on * - * remote memory, but in addition an interrupt * - * will be generated if the target memory * - * location contained a "null value" before the * - * add operation was carried out. * - * The conditional interrupt flag must also be * - * specified in the SCIRegisterInterruptFlag() * - * function. * - * * - * SCI_FLAG_UNCONDITIONAL_INTERRUPT_MAP * - * - Write operations through this map will cause * - * an interrupt for the remote adapter * - * "in addition to" updating the corresponding * - * remote memory location with the data being * - * written. * - * The unconditional interrupt flag must also * - * be specified in the * - * SCIRegisterInterruptFlag() function. * - * * - * SCI_FLAG_WRITE_BACK_CACHE_MAP * - * - Enable cacheing of the mapped region. * - * Writes through this map will be written to a * - * write back cache, hence no remote SCI updates* - * until the cache line is flushed. The * - * application is responsible for the cache * - * flush operation. * - * The SCImemCopy() function will handle this * - * correctly by doing cache flushes internally. * - * This feature is architechture dependent and * - * not be available on all plattforms. * - * * - * SCI_FLAG_NO_MEMORY_LOOPBACK_MAP * - * - Forces a map to a remote segment located * - * in the local machine to be mapped using * - * SCI loopback. This is useful i.e. if you * - * want to use a regular map access to be * - * serialized with lock operations. * - * The default behaviour is to access a remte * - * segment located in the local machine as a * - * local MMU operation. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapRemoteSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapRemoteSegment) -DLL volatile void *SCIMapRemoteSegment( - sci_remote_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M A P L O C A L S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_FIXED_MAP_ADDR * - * SCI_FLAG_READONLY_MAP * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is * - * larger than the segment size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as * - * required by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as * - * required by the implementation. * - * * - *********************************************************************************/ -#define SCIMapLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIMapLocalSegment) -DLL void *SCIMapLocalSegment(sci_local_segment_t segment, - sci_map_t *map, - unsigned int offset, - unsigned int size, - void *addr, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I U N M A P S E G M E N T * - * * - * This function unmaps pages of shared memory from the callers virtual * - * address space. * - * * - * Flags * - * None. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - The map is currently in use. * - * * - *********************************************************************************/ -#define SCIUnmapSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIUnmapSegment) -DLL void SCIUnmapSegment(sci_map_t map, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E S E G M E N T * - * * - * Make the specified segment available for connections via the specified * - * adapter. If successful, the segment can be accessed from remote nodes * - * via the specified adapter. * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events * - * on this segment. * - * SCI_FLAG_EMPTY - No memory will be allocated for the segment. * - * SCI_FLAG_PRIVATE - The segment will be private meaning it will never * - * be any connections to it. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SEGMENTID_USED - The segment with this segmentId is already used * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * * - *********************************************************************************/ -#define SCICreateSegment _SISCI_EXPANDE_FUNCTION_NAME(SCICreateSegment) -DLL void SCICreateSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I W A I T F O R L O C A L S E G M E N T E V E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait operation has been cancelled du to a * - * SCIRemoveSegment() on the same handle. * - * The handle is invalid when this error is returned. * - * * - *********************************************************************************/ -#define SCIWaitForLocalSegmentEvent _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForLocalSegmentEvent) -DLL sci_segment_cb_reason_t SCIWaitForLocalSegmentEvent( - sci_local_segment_t segment, - unsigned int *sourcenodeId, - unsigned int *localAdapterNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P R E P A R E S E G M E N T * - * * - * Flags * - * * - * SCI_FLAG_DMA_SOURCE_ONLY - The segment will be used as a source segment * - * for DMA operations. On some system types this * - * will enable the SISCI driver to use performance * - * improving features. * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIPrepareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIPrepareSegment) -DLL void SCIPrepareSegment(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E G M E N T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_BUSY - Unable to remove the segment. The segment is currently * - * in use. * - * * - *********************************************************************************/ -#define SCIRemoveSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSegment) -DLL void SCIRemoveSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T A V A I L A B L E * - * * - * Flags * - * None. * - * * - * * - * SCI_ERR_SEGMENT_NOT_PREPARED - The segment has not been prepared for access * - * from this adapter. * - * SCI_ERR_ILLEGAL_OPERATION - The segment is created with the * - * SCI_FLAG_PRIVATE flag specified and * - * therefore has no segmentId. * - * * - *********************************************************************************/ -#define SCISetSegmentAvailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentAvailable) -DLL void SCISetSegmentAvailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T S E G M E N T U N A V A I L A B L E * - * * - * Flags * - * * - * SCI_FLAG_FORCE_DISCONNECT * - * SCI_FLAG_NOTIFY * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation. * - * * - *********************************************************************************/ -#define SCISetSegmentUnavailable _SISCI_EXPANDE_FUNCTION_NAME(SCISetSegmentUnavailable) -DLL void SCISetSegmentUnavailable(sci_local_segment_t segment, - unsigned int localAdapterNo, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C R E A T E M A P S E Q U E N C E * - * * - * Flags: * - * * - * SCI_FLAG_FAST_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateMapSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICreateMapSequence) -DLL void SCICreateMapSequence(sci_map_t map, - sci_sequence_t *sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E S E Q U E N C E * - * * - * Flags: * - * None * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveSequence) -DLL void SCIRemoveSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T A R T S E Q U E N C E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIStartSequence _SISCI_EXPANDE_FUNCTION_NAME(SCIStartSequence) -DLL sci_sequence_status_t SCIStartSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I C H E C K S E Q U E N CE * - * * - * Flags * - * * - * SCI_FLAG_NO_FLUSH * - * SCI_FLAG_NO_STORE_BARRIER * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICheckSequence _SISCI_EXPANDE_FUNCTION_NAME(SCICheckSequence) -DLL sci_sequence_status_t SCICheckSequence(sci_sequence_t sequence, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S T O R E B A R R I E R * - * * - * Flags * - * None. * - * * - * * - * * - *********************************************************************************/ -#define SCIStoreBarrier _SISCI_EXPANDE_FUNCTION_NAME(SCIStoreBarrier) -DLL void SCIStoreBarrier(sci_sequence_t sequence, - unsigned int flags); - - - - -/********************************************************************************* - * * - * S C I F L U S H R E A D B U F F E R S * - * * - *********************************************************************************/ -#define SCIFlushReadBuffers _SISCI_EXPANDE_FUNCTION_NAME(SCIFlushReadBuffers) -DLL void SCIFlushReadBuffers(sci_sequence_t sequence); - - - - -/********************************************************************************* - * * - * S C I P R O B E N O D E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIProbeNode _SISCI_EXPANDE_FUNCTION_NAME(SCIProbeNode) -DLL int SCIProbeNode(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int nodeId, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCIGetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCIGetCSRRegister) -DLL unsigned int SCIGetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T C S R R E G I S T E R * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_LINK_ACCESS - It was not possible to communicate via the * - * local adapter. * - * SCI_ERR_NO_REMOTE_LINK_ACCESS - It was not possible to communicate via a * - * remote switch port. * - * * - *********************************************************************************/ -#define SCISetCSRRegister _SISCI_EXPANDE_FUNCTION_NAME(SCISetCSRRegister) -DLL void SCISetCSRRegister(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int SCINodeId, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I G E T L O C A L C S R * - * * - * SISCI Priveleged function * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIGetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCIGetLocalCSR) -DLL unsigned int SCIGetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I S E T L O C A L C S R * - * * - * SISCI Priveleged function - * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCISetLocalCSR _SISCI_EXPANDE_FUNCTION_NAME(SCISetLocalCSR) -DLL void SCISetLocalCSR(sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int CSROffset, - unsigned int CSRValue, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A T T A C H P H Y S I C A L M E M O R Y * - * * - * SISCI Priveleged function * - * * - * Description: * - * * - * This function enables usage of physical devices and memory regions where the * - * Physical PCI bus address ( and mapped CPU address ) are already known. * - * The function will register the physical memory as a SISCI segment which can * - * be connected and mapped as a regular SISCI segment. * - * * - * Requirements: * - * * - * SCICreateSegment() with flag SCI_FLAG_EMPTY must have been called in advance * - * * - * Parameter description: * - * sci_ioaddr_t ioaddress : This is the address on the PCI bus that a PCI bus * - * master has to use to write to the specified memory * - * void * address : This is the (mapped) virtual address that the * - * application has to use to access the device. * - * This means that the device has to be mapped in * - * advance bye the devices own driver. * - * If the device is not to be accessed by the local * - * CPU, the address pointer shold be set to NULL * - * Flags * - * * - * None * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIAttachPhysicalMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachPhysicalMemory) -DLL void SCIAttachPhysicalMemory(sci_ioaddr_t ioaddress, - void *address, - unsigned int busNo, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I Q U E R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_QUERY - Unrecognized command. * - * * - *********************************************************************************/ -#define SCIQuery _SISCI_EXPANDE_FUNCTION_NAME(SCIQuery) -DLL void SCIQuery(unsigned int command, - void *data, - unsigned int flags, - sci_error_t *error); - - -/* MAJOR QUERY COMMANDS */ - -/* This command requires a pointer to a structure of type */ -/* "sci_query_string". The string will be filled in by the query. */ -#define SCI_Q_VENDORID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_VENDORID) -extern const unsigned int SCI_Q_VENDORID; - - -/* Same as for SCI_VENDOR_ID */ -#define SCI_Q_API _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_API) -extern const unsigned int SCI_Q_API; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_adapter" struct. */ -#define SCI_Q_ADAPTER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER) -extern const unsigned int SCI_Q_ADAPTER; - - -/* User passes a pointer to an allocated object of the */ -/* "sci_query_system" struct. */ -#define SCI_Q_SYSTEM _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM) -extern const unsigned int SCI_Q_SYSTEM; - -#define SCI_Q_LOCAL_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT) -extern const unsigned int SCI_Q_LOCAL_SEGMENT; - -#define SCI_Q_REMOTE_SEGMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT) -extern const unsigned int SCI_Q_REMOTE_SEGMENT; - -#define SCI_Q_MAP _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP) -extern const unsigned int SCI_Q_MAP; - -typedef char* sci_semaphoreId_t; - -#ifdef WIN32 -struct _semaphoreid { - char *semaphoreName; -}; -#endif /*WIN32*/ - -typedef struct { - char *str; /* Pointer to a string of minimum "length" characters */ - unsigned int length; -} sci_query_string_t; - - -typedef struct { - unsigned int localAdapterNo; /* The adapter no. that the query concern. */ - unsigned int portNo; /* The SCI Link port number that the query concern. */ - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_adapter_t; - - -typedef struct { - unsigned int subcommand; /* A subcommand as specified below. */ - void *data; /* A pointer to an unsigned int that will return */ - /* the response to the query. */ -} sci_query_system_t; - -typedef struct { - sci_local_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_local_segment_t; - -typedef struct { - sci_remote_segment_t segment; - unsigned int subcommand; - union { - sci_ioaddr_t ioaddr; - } data; -} sci_query_remote_segment_t; - -typedef struct { - sci_map_t map; - unsigned int subcommand; - unsigned int data; -} sci_query_map_t; - -/* Minor query commands (sub-commands) for adapter specific information SCI_ADAPTER */ -#define SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_SIZE_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT) -extern const unsigned int SCI_Q_ADAPTER_DMA_OFFSET_ALIGNMENT; - -#define SCI_Q_ADAPTER_DMA_MTU _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_DMA_MTU) -extern const unsigned int SCI_Q_ADAPTER_DMA_MTU; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_DMA_SIZE; - -#define SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE) -extern const unsigned int SCI_Q_ADAPTER_SUGGESTED_MIN_BLOCK_SIZE; - -#define SCI_Q_ADAPTER_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NODEID) -extern const unsigned int SCI_Q_ADAPTER_NODEID; - -#define SCI_Q_ADAPTER_SERIAL_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SERIAL_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_SERIAL_NUMBER; - -#define SCI_Q_ADAPTER_CARD_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CARD_TYPE) -extern const unsigned int SCI_Q_ADAPTER_CARD_TYPE; - -#define SCI_Q_ADAPTER_NUMBER_OF_STREAMS _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER_OF_STREAMS) -extern const unsigned int SCI_Q_ADAPTER_NUMBER_OF_STREAMS; - -#define SCI_Q_ADAPTER_STREAM_BUFFER_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_STREAM_BUFFER_SIZE) -extern const unsigned int SCI_Q_ADAPTER_STREAM_BUFFER_SIZE; - -#define SCI_Q_ADAPTER_CONFIGURED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONFIGURED) -extern const unsigned int SCI_Q_ADAPTER_CONFIGURED; - -#define SCI_Q_ADAPTER_LINK_OPERATIONAL _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LINK_OPERATIONAL) -extern const unsigned int SCI_Q_ADAPTER_LINK_OPERATIONAL; - -#define SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK) -extern const unsigned int SCI_Q_ADAPTER_HW_LINK_STATUS_IS_OK; - -#define SCI_Q_ADAPTER_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_NUMBER; - -#define SCI_Q_ADAPTER_INSTANCE_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_INSTANCE_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_INSTANCE_NUMBER; - -#define SCI_Q_ADAPTER_FIRMWARE_OK _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_FIRMWARE_OK) -extern const unsigned int SCI_Q_ADAPTER_FIRMWARE_OK; - -#define SCI_Q_ADAPTER_CONNECTED_TO_SWITCH _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_SWITCH) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_SWITCH; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_TYPE; - -#define SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER) -extern const unsigned int SCI_Q_ADAPTER_LOCAL_SWITCH_PORT_NUMBER; - -#define SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT) -extern const unsigned int SCI_Q_ADAPTER_CONNECTED_TO_EXPECTED_SWITCH_PORT; - -#define SCI_Q_ADAPTER_ATT_PAGE_SIZE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_PAGE_SIZE) -extern const unsigned int SCI_Q_ADAPTER_ATT_PAGE_SIZE; - -#define SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_NUMBER_OF_ENTRIES; - -#define SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES) -extern const unsigned int SCI_Q_ADAPTER_ATT_AVAILABLE_ENTRIES; - -#define SCI_Q_ADAPTER_PHYS_MEM_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MEM_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MEM_NODEID; - -#define SCI_Q_ADAPTER_PHYS_MBX_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SCI_Q_ADAPTER_PHYS_MBX_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_MBX_NODEID; - -#define SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID) -extern const unsigned int SCI_Q_ADAPTER_PHYS_LINK_PORT_NODEID; - -#define SCI_Q_ADAPTER_SCI_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_SCI_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_SCI_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_B_LINK_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_B_LINK_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_B_LINK_FREQUENCY; - -#define SCI_Q_ADAPTER_IO_BUS_FREQUENCY _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_ADAPTER_IO_BUS_FREQUENCY) -extern const unsigned int SCI_Q_ADAPTER_IO_BUS_FREQUENCY; - -/* Minor query commands (sub-commands) for adapter specific information SCI_SYSTEM */ -#define SCI_Q_SYSTEM_HOSTBRIDGE _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_HOSTBRIDGE) -extern const unsigned int SCI_Q_SYSTEM_HOSTBRIDGE; - -#define SCI_Q_SYSTEM_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_POSTING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_POSTING_ENABLED; - -#define SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED) -extern const unsigned int SCI_Q_SYSTEM_WRITE_COMBINING_ENABLED; - -#define SCI_Q_LOCAL_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_LOCAL_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_LOCAL_SEGMENT_IOADDR; - -#define SCI_Q_REMOTE_SEGMENT_IOADDR _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_REMOTE_SEGMENT_IOADDR) -extern const unsigned int SCI_Q_REMOTE_SEGMENT_IOADDR; - -#define SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_MAPPED_TO_LOCAL_TARGET; - -#define SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET _SISCI_EXPANDE_CONSTANT_NAME(SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET) -extern const unsigned int SCI_Q_MAP_QUERY_REMOTE_MAPPED_TO_LOCAL_TARGET; - -#define HOSTBRIDGE_NOT_AVAILABLE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_NOT_AVAILABLE) -extern const unsigned int HOSTBRIDGE_NOT_AVAILABLE; - -#define HOSTBRIDGE_UNKNOWN _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_UNKNOWN) -extern const unsigned int HOSTBRIDGE_UNKNOWN; - -#define HOSTBRIDGE_440FX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440FX) -extern const unsigned int HOSTBRIDGE_440FX; - -#define HOSTBRIDGE_440LX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440LX) -extern const unsigned int HOSTBRIDGE_440LX; - -#define HOSTBRIDGE_440BX_A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_A) -extern const unsigned int HOSTBRIDGE_440BX_A; - -#define HOSTBRIDGE_440BX_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440BX_B) -extern const unsigned int HOSTBRIDGE_440BX_B; - -#define HOSTBRIDGE_440GX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_440GX) -extern const unsigned int HOSTBRIDGE_440GX; - -#define HOSTBRIDGE_450KX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450KX) -extern const unsigned int HOSTBRIDGE_450KX; - -#define HOSTBRIDGE_430NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_430NX) -extern const unsigned int HOSTBRIDGE_430NX; - -#define HOSTBRIDGE_450NX _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX) -extern const unsigned int HOSTBRIDGE_450NX; - -#define HOSTBRIDGE_450NX_MICO _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_MICO) -extern const unsigned int HOSTBRIDGE_450NX_MICO; - -#define HOSTBRIDGE_450NX_PXB _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_450NX_PXB) -extern const unsigned int HOSTBRIDGE_450NX_PXB; - -#define HOSTBRIDGE_I810 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810) -extern const unsigned int HOSTBRIDGE_I810; - -#define HOSTBRIDGE_I810_DC100 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810_DC100) -extern const unsigned int HOSTBRIDGE_I810_DC100; - -#define HOSTBRIDGE_I810E _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I810E) -extern const unsigned int HOSTBRIDGE_I810E; - -#define HOSTBRIDGE_I815 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I815) -extern const unsigned int HOSTBRIDGE_I815; - -#define HOSTBRIDGE_I840 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I840) -extern const unsigned int HOSTBRIDGE_I840; - -#define HOSTBRIDGE_I850 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I850) -extern const unsigned int HOSTBRIDGE_I850; - -#define HOSTBRIDGE_I860 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_I860) -extern const unsigned int HOSTBRIDGE_I860; - -#define HOSTBRIDGE_INTEL_E7500 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_INTEL_E7500) -extern const unsigned int HOSTBRIDGE_INTEL_E7500; - -#define HOSTBRIDGE_VIA_KT133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KT133) -extern const unsigned int HOSTBRIDGE_VIA_KT133; - -#define HOSTBRIDGE_VIA_KX133 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_KX133) -extern const unsigned int HOSTBRIDGE_VIA_KX133; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_133A _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_133A) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_133A; - -#define HOSTBRIDGE_VIA_APOLLO_PRO_266 _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_VIA_APOLLO_PRO_266) -extern const unsigned int HOSTBRIDGE_VIA_APOLLO_PRO_266; - -#define HOSTBRIDGE_AMD_760_MP _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_760_MP) -extern const unsigned int HOSTBRIDGE_AMD_760_MP; - -#define HOSTBRIDGE_AMD_HAMMER _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_AMD_HAMMER) -extern const unsigned int HOSTBRIDGE_AMD_HAMMER; - -#define HOSTBRIDGE_SERVERWORKS_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE; - -#define HOSTBRIDGE_SERVERWORKS_HE_B _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_HE_B) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_HE_B; - -#define HOSTBRIDGE_SERVERWORKS_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_LE; - -#define HOSTBRIDGE_SERVERWORKS_GC_HE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_HE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_HE; - -#define HOSTBRIDGE_SERVERWORKS_GC_LE _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_LE) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_LE; - -#define HOSTBRIDGE_SERVERWORKS_GC_WS _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_WS) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_WS; - -#define HOSTBRIDGE_SERVERWORKS_GC_SL _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_SERVERWORKS_GC_SL) -extern const unsigned int HOSTBRIDGE_SERVERWORKS_GC_SL; - - -#define HOSTBRIDGE_WRITE_POSTING_DISABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_DISABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_DISABLED; - -#define HOSTBRIDGE_WRITE_POSTING_ENABLED _SISCI_EXPANDE_CONSTANT_NAME(HOSTBRIDGE_WRITE_POSTING_ENABLED) -extern const unsigned int HOSTBRIDGE_WRITE_POSTING_ENABLED; - - - - -/********************************************************************************* - * * - * S C I C R E A T E D M A Q U E U E * - * * - * Flags * - * * - * SCI_FLAG_DMA_PHDMA : Create physical DMA queue. Please note that this is an * - * priveleged operation. * - * * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCICreateDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCICreateDMAQueue) -DLL void SCICreateDMAQueue(sci_desc_t sd, - sci_dma_queue_t *dq, - unsigned int localAdapterNo, - unsigned int maxEntries, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Not allowed in this queue state. * - * * - *********************************************************************************/ -#define SCIRemoveDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveDMAQueue) -DLL void SCIRemoveDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I E N Q U E U E D M A T R A N S F E R * - * * - * Flags: * - * * - * SCI_FLAG_DMA_READ - The DMA will be remote --> local * - * (default is local --> remote) * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the offset and size is larger * - * than the segment size or larger than max * - * DMA size. * - * SCI_ERR_MAX_ENTRIES - The DMA queue is full * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_SEGMENT_NOT_PREPARED - The local segment has not been prepared for * - * access from the adapter associated with the * - * queue. * - * SCI_ERR_SEGMENT_NOT_CONNECTED - The remote segment is not connected through * - * the adapter associated with the queue. * - *********************************************************************************/ -#define SCIEnqueueDMATransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIEnqueueDMATransfer) -DLL sci_dma_queue_state_t SCIEnqueueDMATransfer(sci_dma_queue_t dq, - sci_local_segment_t localSegment, - sci_remote_segment_t remoteSegment, - unsigned int localOffset, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I P O S T D M A Q U E U E * - * * - * Flags: * - * * - * SCI_FLAG_USE_CALLBACK - The end of the transfer will cause the callback * - * function to be invoked. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIPostDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIPostDMAQueue) -DLL void SCIPostDMAQueue(sci_dma_queue_t dq, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortDMAQueue) -DLL void SCIAbortDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I R E S E T D M A Q U E U E * - * * - * Flags * - * None. * * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIResetDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIResetDMAQueue) -DLL void SCIResetDMAQueue(sci_dma_queue_t dq, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I D M A Q U E U E S T A T E * - * * - *********************************************************************************/ -#define SCIDMAQueueState _SISCI_EXPANDE_FUNCTION_NAME(SCIDMAQueueState) -DLL sci_dma_queue_state_t SCIDMAQueueState(sci_dma_queue_t dq); - - - -/********************************************************************************* - * * - * S C I W A I T F O R D M A Q U E U E * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForDMAQueue _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForDMAQueue) -DLL sci_dma_queue_state_t SCIWaitForDMAQueue(sci_dma_queue_t dq, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I P H D M A E N Q U E U E * - * * - * SISCI Priveleged function * - * * - * Flags * - * * - * SCI_FLAG_DMA_READ * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaEnqueue _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaEnqueue) -DLL void SCIphDmaEnqueue(sci_dma_queue_t dmaqueue, - unsigned int size, - sci_ioaddr_t localBusAddr, - unsigned int remote_nodeid, - unsigned int remote_highaddr, - unsigned int remote_lowaddr, - unsigned int flags, - sci_error_t *error); - -/********************************************************************************* - * * - * S C I P H D M A S T A R T * - * * - * Flags * - * * - * SCI_FLAG_DMA_WAIT * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_DMA_RESET * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIphDmaStart _SISCI_EXPANDE_FUNCTION_NAME(SCIphDmaStart) -DLL sci_dma_queue_state_t SCIphDmaStart(sci_dma_queue_t dmaqueue, - sci_cb_dma_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - -#ifdef WIN32 -/********************************************************************************* - * * - * S C I C R E A T E N A M E D I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_FIXED_INTNO * - * SCI_FLAG_SHARED_INT * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INTNO_USED - This interrupt number is already used. * - * * - *********************************************************************************/ -#define SCICreateNamedInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCICreateNamedInterrupt) -DLL void SCICreateNamedInterrupt(sci_desc_t sd, - sci_local_interrupt_t *interrupt, - unsigned int localAdapterNo, - unsigned int *interruptNo, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_semaphoreId_t semId, - sci_error_t *error); -#endif /*WIN32*/ - -/********************************************************************************* - * * - * S C I C R E A T E I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_USE_CALLBACK * - * SCI_FLAG_FIXED_INTNO * - * SCI_FLAG_SHARED_INT * - * SCI_FLAG_COUNTING_INT: This flag will enable counting interrupts. This means * - * that the number of trigged interrupts is equal to the * - * number of received interrupts. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_INTNO_USED - This interrupt number is already used. * - * * - *********************************************************************************/ -#define SCICreateInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCICreateInterrupt) -DLL void SCICreateInterrupt(sci_desc_t sd, - sci_local_interrupt_t *interrupt, - unsigned int localAdapterNo, - unsigned int *interruptNo, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E M O V E I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - *********************************************************************************/ -#define SCIRemoveInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIRemoveInterrupt) -DLL void SCIRemoveInterrupt(sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I W A I T F O R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_TIMEOUT - The function timed out after specified timeout value. * - * SCI_ERR_CANCELLED - The wait was interrupted by a call to * - * SCIRemoveInterrupt. * - * The handle is invalid when this error code is returned.* - * * - *********************************************************************************/ -#define SCIWaitForInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForInterrupt) -DLL void SCIWaitForInterrupt(sci_local_interrupt_t interrupt, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I C O N N E C T I N T E R R U P T * - * * - * Flags * - * * - * SCI_FLAG_COUNTING_INT: This flag will enable counting interrupts. This means * - * that the number of trigged interrupts is equal to the * - * number of received interrupts. * - * if SCI_FLAG_COUNTING_INT is not used, the interface * - * guarentees that there always will be an remote * - * interrupt generated after the first and after the last* - * trigger. If interupts is triggered faster than the * - * remote interrupt handler can handle, interrupts may be* - * lost. * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_NO_SUCH_INTNO - No such interrupt number. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIConnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectInterrupt) -DLL void SCIConnectInterrupt(sci_desc_t sd, - sci_remote_interrupt_t *interrupt, - unsigned int nodeId, - unsigned int localAdapterNo, - unsigned int interruptNo, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I D I S C O N N E C T I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisconnectInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisconnectInterrupt) -DLL void SCIDisconnectInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I T R I G G E R I N T E R R U P T * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCITriggerInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCITriggerInterrupt) -DLL void SCITriggerInterrupt(sci_remote_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I R E G I S T E R I N T E R R U P T F L A G * - * * - * * - * This function register an "interrupt flag" that is identified as an unique * - * location within a local segment. If successful, the resulting interrupt * - * handle will have been associated with the specified local segment. * - * * - * It is up to the (remote) client(s) to set up an "interrupt mapping" for the * - * corresponding segment offset using either the * - * * - * - SCI_FLAG_CONDITIONAL_INTERRUPT_MAP * - * * - * or the * - * * - * - SCI_FLAG_UNCONDITIONAL_DATA_INTERRUPT_MAP * - * * - * option to "SCIMapRemoteSegment()". - I.e. after having established a * - * connection to the corresponding segment. A trigger operation can then * - * be implemented using a store operation via the relevant "interrupt map". * - * * - * * - * * - * * - * * - * Flags: * - * * - * SCI_FLAG_CONDITIONAL_INTERRUPT - Triggering is to take place using * - * "conditional interrupts". * - * * - * * - * * - * Specific error codes for this function: * - * None. * - * * - *********************************************************************************/ -#define SCIRegisterInterruptFlag _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterInterruptFlag) -DLL void SCIRegisterInterruptFlag( - unsigned int localAdapterNo, - sci_local_interrupt_t *interrupt, - sci_local_segment_t segment, - unsigned int offset, - sci_cb_interrupt_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I E N A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * This function make sure that another HW interrupt will take place the next * - * time the corresponding interrupt flag is triggered by a * - * "conditional interrupt" operation. * - * * - * Default semantics: * - * * - * When successful, the client can rely on that the first subsequent trigger * - * operation will cause a HW interrupt and subsequently cause the client * - * handler function to be invoked. * - * * - * If an interrupt was triggered in parallell with the enable operation, then * - * the operation will fail (SCI_ERR_COND_INT_RACE_PROBLEM), and the client can * - * not rely on another trigger operation will lead to handler invocation. * - * Hence, any state checking normally associated with handling the * - * corresponding interrupt should take place before attempting to enable * - * again. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_COND_INT_RACE_PROBLEM - The enable operation failed because an * - * incomming trigger operation happened * - * concurrently. * - * * - *********************************************************************************/ -#define SCIEnableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIEnableConditionalInterrupt) -DLL void SCIEnableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I D I S A B L E C O N D I T I O N A L I N T E R R U P T * - * * - * * - * Prevent subsequent "conditional interrupt"trigger operations for * - * the specified interupt flag from causing HW interrupt and handler * - * invocations. * - * * - * * - * Default semantics: * - * * - * If successful, no subsequent HW interrupts will take place, but handler * - * invocations that have already been scheduled may still take place. * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * * - *********************************************************************************/ -#define SCIDisableConditionalInterrupt _SISCI_EXPANDE_FUNCTION_NAME(SCIDisableConditionalInterrupt) -DLL void SCIDisableConditionalInterrupt( - sci_local_interrupt_t interrupt, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I G E T C O N D I T I O N A L I N T E R R U P T C O U N T E R * - * * - * * - * Returns a value that indicates the number of times this flag has * - * been trigged since the last time it was enabled or disabled. * - * Calling the SCIEnableConditionalInterrupt / SCIDisableConditionalInterrupt * - * functions will reset the counter value. * - * * - * Default semantics: * - * * - * If successful, the current trig count is returned in the * - * interruptTrigCounter parameter. * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OVERFLOW - The number of trig operations have exceeded the range * - * that can be counted. * - *********************************************************************************/ -#define SCIGetConditionalInterruptTrigCounter _SISCI_EXPANDE_FUNCTION_NAME(SCIGetConditionalInterruptTrigCounter) -DLL void SCIGetConditionalInterruptTrigCounter( - sci_local_interrupt_t interrupt, - unsigned int *interruptTrigCounter, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlock _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlock) -DLL void SCITransferBlock(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I T R A N S F E R B L O C K A S Y N C * - * * - * Flags * - * * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_USE_CALLBACK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger than * - * the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ -#define SCITransferBlockAsync _SISCI_EXPANDE_FUNCTION_NAME(SCITransferBlockAsync) -DLL void SCITransferBlockAsync(sci_map_t sourceMap, - unsigned int sourceOffset, - sci_map_t destinationMap, - unsigned int destinationOffset, - unsigned int size, - sci_block_transfer_t *block, - sci_cb_block_transfer_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I W A I T F O R B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * SCI_ERR_TIMEOUT - The function timed out after specified * - * timeout value. * - * * - *********************************************************************************/ -#define SCIWaitForBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIWaitForBlockTransfer) -DLL void SCIWaitForBlockTransfer(sci_block_transfer_t block, - unsigned int timeout, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I A B O R T B L O C K T R A N S F E R * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_ILLEGAL_OPERATION - Illegal operation * - * * - *********************************************************************************/ -#define SCIAbortBlockTransfer _SISCI_EXPANDE_FUNCTION_NAME(SCIAbortBlockTransfer) -DLL void SCIAbortBlockTransfer(sci_block_transfer_t block, - unsigned int flags, - sci_error_t *error); - - - - -/********************************************************************************* - * * - * S C I M E M C P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - -#define SCIMemCpy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCpy) -DLL void SCIMemCpy(sci_sequence_t sequence, - void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I M E M C O P Y * - * * - * Flags: * - * SCI_FLAG_BLOCK_READ * - * SCI_FLAG_ERROR_CHECK * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_OUT_OF_RANGE - The sum of the size and offset is larger * - * than the corresponding map size. * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_OFFSET_ALIGNMENT - Offset is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_TRANSFER_FAILED - The data transfer failed. * - * * - *********************************************************************************/ - - -#define SCIMemCopy _SISCI_EXPANDE_FUNCTION_NAME(SCIMemCopy) -DLL void SCIMemCopy(void *memAddr, - sci_map_t remoteMap, - unsigned int remoteOffset, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/********************************************************************************* - * * - * S C I R E G I S T E R S E G M E N T M E M O R Y * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required by * - * the implementation. * - * SCI_ERR_ILLEGAL_ADDRESS - Illegal address. * - * SCI_ERR_OUT_OF_RANGE - Size is larger than the maximum size for the * - * local segment. * - * * - *********************************************************************************/ -#define SCIRegisterSegmentMemory _SISCI_EXPANDE_FUNCTION_NAME(SCIRegisterSegmentMemory) -DLL void SCIRegisterSegmentMemory(void *address, - unsigned int size, - sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - - - - -/********************************************************************************* - * * - * S C I C O N N E C T S C I S P A C E * - * * - * SISCI Priveleged function * - * * - * * - * Flags * - * None. * - * * - * * - * Specific error codes for this function: * - * * - * SCI_ERR_SIZE_ALIGNMENT - Size is not correctly aligned as required * - * by the implementation. * - * SCI_ERR_CONNECTION_REFUSED - Connection attempt refused by remote node. * - * * - *********************************************************************************/ -#define SCIConnectSCISpace _SISCI_EXPANDE_FUNCTION_NAME(SCIConnectSCISpace) -DLL void SCIConnectSCISpace(sci_desc_t sd, - unsigned int localAdapterNo, - sci_remote_segment_t *segment, - sci_address_t address, - unsigned int size, - unsigned int flags, - sci_error_t *error); - - - -/* - * ===================================================================================== - * - * S C I A T T A C H L O C A L S E G M E N T - * Description: - * - * SCIAttachLocalSegment() permits an application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * - * SCI_FLAG_USE_CALLBACK - The callback function will be invoked for events - * on this segment. - * - * - * Specific error codes for this function: - * - * SCI_ERR_ACCESS - No such shared segment - * SCI_ERR_NO_SUCH_SEGMENT - No such segment - * Note: Current implenentation will return SCI_ERR_ACCESS for both cases. This will - * change from next release. Application should handle both cases. - * - * ===================================================================================== - */ -#define SCIAttachLocalSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIAttachLocalSegment) - -DLL void -SCIAttachLocalSegment(sci_desc_t sd, - sci_local_segment_t *segment, - unsigned int segmentId, - unsigned int *size, - sci_cb_local_segment_t callback, - void *callbackArg, - unsigned int flags, - sci_error_t *error); -/* - * ===================================================================================== - * - * S C I S H A R E S E G M E N T - * - * Description: - * - * SCIShareSegment() permits other application to "attach" to an already existing - * local segment, implying that two or more application want - * share the same local segment. The prerequest, is that the - * application which originally created the segment ("owner") has - * preformed a SCIShareSegment() in order to mark the segment - * "shareable". - * - * - * Flags: - * none - * - * Specific error codes for this function: - * - * - * - * ===================================================================================== - */ -#define SCIShareSegment _SISCI_EXPANDE_FUNCTION_NAME(SCIShareSegment) - -DLL void -SCIShareSegment(sci_local_segment_t segment, - unsigned int flags, - sci_error_t *error); - - -/********************************************************************************* - * * - * S C I F L U S H * - * * - * This function will flush the CPU buffers and the PSB buffers. * - * * - * Flags * - * SCI_FLAG_FLUSH_CPU_BUFFERS_ONLY : * - * Only flush CPU buffers ( Write combining * - * etc buffers). * - * * - *********************************************************************************/ - -#define SCIFlush _SISCI_EXPANDE_FUNCTION_NAME(SCIFlush) -DLL void SCIFlush(sci_sequence_t sequence, - unsigned int flags); - -#if defined(CPLUSPLUS) || defined(__cplusplus) -} -#endif - - -#endif - - - - - - - - - - - diff --git a/ndb/src/external/WIN32.x86/sci/include/sisci_demolib.h b/ndb/src/external/WIN32.x86/sci/include/sisci_demolib.h deleted file mode 100644 index ce5bb2aec8e..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/sisci_demolib.h +++ /dev/null @@ -1,226 +0,0 @@ -/* $Id: sisci_demolib.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SISCI_DEMOLIB_H -#define _SISCI_DEMOLIB_H - - -#if defined(_REENTRANT) - -#define _SISCI_DEMOLIB_EXPAND_NAME(name) _SISCI_DEMOLIB_MT_ ## name - -#else - -#define _SISCI_DEMOLIB_EXPAND_NAME(name) _SISCI_DEMOLIB_ST_ ## name - -#endif - -/*********************************************************************************/ -/* Q U E R Y A D A P T E R */ -/* */ -/*********************************************************************************/ - -#define QueryAdapter _SISCI_DEMOLIB_EXPAND_NAME(QueryAdapter) - -sci_error_t QueryAdapter( - unsigned int subcommand, - unsigned int localAdapterNo, - unsigned int portNo, - unsigned int *data); - - -/*********************************************************************************/ -/* Q U E R Y S Y S T E M */ -/* */ -/*********************************************************************************/ - -#define QuerySystem _SISCI_DEMOLIB_EXPAND_NAME(QuerySystem) - -sci_error_t QuerySystem( - unsigned int subcommand, - unsigned int *data); - - -/*********************************************************************************/ -/* D E T E C T F I R S T A D A P T E R C A R D */ -/* */ -/*********************************************************************************/ - -#define DetectFirstAdapterCard _SISCI_DEMOLIB_EXPAND_NAME(DetectFirstAdapterCard) - -sci_error_t DetectFirstAdapterCard( - unsigned int *localAdapterNo, - unsigned int *localNodeId); - - -/*********************************************************************************/ -/* G E T A D A P T E R T Y P E */ -/* */ -/*********************************************************************************/ - -#define GetAdapterType _SISCI_DEMOLIB_EXPAND_NAME(GetAdapterType) - -sci_error_t GetAdapterType(unsigned int localAdapterNo, - unsigned int *adapterType); - - -/*********************************************************************************/ -/* G E T L O C A L N O D E I D */ -/* */ -/*********************************************************************************/ - -#define GetLocalNodeId _SISCI_DEMOLIB_EXPAND_NAME(GetLocalNodeId) - -sci_error_t GetLocalNodeId( - unsigned int localAdapterNo, - unsigned int *localNodeId); - - -/*********************************************************************************/ -/* G E T A D A P T E R S E R I A L N U M B E R */ -/* */ -/*********************************************************************************/ - -#define GetAdapterSerialNumber _SISCI_DEMOLIB_EXPAND_NAME(GetAdapterSerialNumber) - -sci_error_t GetAdapterSerialNumber( - unsigned int localAdapterNo, - unsigned int *serialNo); - - - -/*********************************************************************************/ -/* G E T H O S T B R I D G E T Y P E */ -/* */ -/*********************************************************************************/ - -#define GetHostbridgeType _SISCI_DEMOLIB_EXPAND_NAME(GetHostbridgeType) - -sci_error_t GetHostbridgeType(unsigned int *hostbridgeType); - - - -/*********************************************************************************/ -/* P R I N T H O S T B R I D G E T Y P E */ -/* */ -/*********************************************************************************/ - -#define PrintHostbridgeType _SISCI_DEMOLIB_EXPAND_NAME(PrintHostbridgeType) - -void PrintHostbridgeType(unsigned int hostbridge); - - - -/*********************************************************************************/ -/* G E T A P I V E R S I O N S T R I N G */ -/* */ -/*********************************************************************************/ - -#define GetAPIVersionString _SISCI_DEMOLIB_EXPAND_NAME(GetAPIVersionString) - -sci_error_t GetAPIVersionString(char str[], unsigned int strLength); - - - -/*********************************************************************************/ -/* G E T A D A P T E R I O B U S F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterIoBusFrequency(unsigned int localAdapterNo, - unsigned int *ioBusFrequency); - - - -/*********************************************************************************/ -/* G E T A D A P T E R S C I L I N K F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterSciLinkFrequency(unsigned int localAdapterNo, - unsigned int *sciLinkFrequency); - - - -/*********************************************************************************/ -/* G E T A D A P T E R B L I N K F R E Q U E N C Y */ -/* */ -/*********************************************************************************/ - -sci_error_t GetAdapterBlinkFrequency(unsigned int localAdapterNo, - unsigned int *bLinkFrequency); - - -/*********************************************************************************/ -/* S E N D I N T E R R U P T */ -/* */ -/*********************************************************************************/ - -#define SendInterrupt _SISCI_DEMOLIB_EXPAND_NAME(SendInterrupt) - -sci_error_t SendInterrupt( - sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int localNodeId, - unsigned int remoteNodeId, - unsigned int interruptNo); - - -/*********************************************************************************/ -/* R E C E I V E I N T E R R U P T */ -/* */ -/*********************************************************************************/ - -#define ReceiveInterrupt _SISCI_DEMOLIB_EXPAND_NAME(ReceiveInterrupt) - -sci_error_t ReceiveInterrupt( - sci_desc_t sd, - unsigned int localAdapterNo, - unsigned int localNodeId, - unsigned int interruptNo); - - -/*********************************************************************************/ -/* E N D I A N S W A P */ -/* */ -/*********************************************************************************/ - -#define EndianSwap _SISCI_DEMOLIB_EXPAND_NAME(EndianSwap) - -unsigned int EndianSwap (unsigned int value); - - -/*********************************************************************************/ -/* S L E E P M I L L I S E C O N D S */ -/* */ -/*********************************************************************************/ - -#define SleepMilliseconds _SISCI_DEMOLIB_EXPAND_NAME(SleepMilliseconds) - -void SleepMilliseconds(int milliseconds); - - - - -#endif diff --git a/ndb/src/external/WIN32.x86/sci/include/sisci_error.h b/ndb/src/external/WIN32.x86/sci/include/sisci_error.h deleted file mode 100644 index 56fa0d18b3a..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/sisci_error.h +++ /dev/null @@ -1,94 +0,0 @@ -/* $Id: sisci_error.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SISCI_ERROR_H_ -#define _SISCI_ERROR_H_ - - -/* SCI Error return values always have 30 bit set */ -#define SCI_ERR_MASK 0x40000000 -#define SCI_ERR_REMOTE_MASK 0x01 /* Remote errors should have bit 0 set */ - -#define SCI_ERR(u) ((unsigned32)(u)&0x7FFFFFFF ) - -/* Error codes */ -typedef enum { - SCI_ERR_OK = 0x000, - - - SCI_ERR_BUSY = (0x900 | SCI_ERR_MASK), - SCI_ERR_FLAG_NOT_IMPLEMENTED = (0x901 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_FLAG = (0x902 | SCI_ERR_MASK), - SCI_ERR_NOSPC = (0x904 | SCI_ERR_MASK), - SCI_ERR_API_NOSPC = (0x905 | SCI_ERR_MASK), - SCI_ERR_HW_NOSPC = (0x906 | SCI_ERR_MASK), - SCI_ERR_NOT_IMPLEMENTED = (0x907 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADAPTERNO = (0x908 | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_ADAPTERNO = (0x909 | SCI_ERR_MASK), - SCI_ERR_TIMEOUT = (0x90A | SCI_ERR_MASK), - SCI_ERR_OUT_OF_RANGE = (0x90B | SCI_ERR_MASK), - SCI_ERR_NO_SUCH_SEGMENT = (0x90C | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_NODEID = (0x90D | SCI_ERR_MASK), - SCI_ERR_CONNECTION_REFUSED = (0x90E | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_CONNECTED = (0x90F | SCI_ERR_MASK), - SCI_ERR_SIZE_ALIGNMENT = (0x910 | SCI_ERR_MASK), - SCI_ERR_OFFSET_ALIGNMENT = (0x911 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_PARAMETER = (0x912 | SCI_ERR_MASK), - SCI_ERR_MAX_ENTRIES = (0x913 | SCI_ERR_MASK), - SCI_ERR_SEGMENT_NOT_PREPARED = (0x914 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_ADDRESS = (0x915 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_OPERATION = (0x916 | SCI_ERR_MASK), - SCI_ERR_ILLEGAL_QUERY = (0x917 | SCI_ERR_MASK), - SCI_ERR_SEGMENTID_USED = (0x918 | SCI_ERR_MASK), - SCI_ERR_SYSTEM = (0x919 | SCI_ERR_MASK), - SCI_ERR_CANCELLED = (0x91A | SCI_ERR_MASK), - SCI_ERR_NOT_CONNECTED = (0x91B | SCI_ERR_MASK), - SCI_ERR_NOT_AVAILABLE = (0x91C | SCI_ERR_MASK), - SCI_ERR_INCONSISTENT_VERSIONS = (0x91D | SCI_ERR_MASK), - SCI_ERR_COND_INT_RACE_PROBLEM = (0x91E | SCI_ERR_MASK), - SCI_ERR_OVERFLOW = (0x91F | SCI_ERR_MASK), - SCI_ERR_NOT_INITIALIZED = (0x920 | SCI_ERR_MASK), - - SCI_ERR_ACCESS = (0x921 | SCI_ERR_MASK), - - SCI_ERR_NO_SUCH_NODEID = (0xA00 | SCI_ERR_MASK), - SCI_ERR_NODE_NOT_RESPONDING = (0xA02 | SCI_ERR_MASK), - SCI_ERR_NO_REMOTE_LINK_ACCESS = (0xA04 | SCI_ERR_MASK), - SCI_ERR_NO_LINK_ACCESS = (0xA05 | SCI_ERR_MASK), - SCI_ERR_TRANSFER_FAILED = (0xA06 | SCI_ERR_MASK), - - SCI_ERR_EWOULD_BLOCK = ( 0xB00 | SCI_ERR_MASK), - SCI_ERR_SEMAPHORE_COUNT_EXCEEDED = ( 0xB01 | SCI_ERR_MASK), - SCI_ERR_IRQL_ILLEGAL = ( 0xB02 | SCI_ERR_MASK) - -} sci_error_t; - - -#endif /* _SCI_ERROR_H_ */ - - - diff --git a/ndb/src/external/WIN32.x86/sci/include/sisci_types.h b/ndb/src/external/WIN32.x86/sci/include/sisci_types.h deleted file mode 100644 index 03e7957c3f2..00000000000 --- a/ndb/src/external/WIN32.x86/sci/include/sisci_types.h +++ /dev/null @@ -1,133 +0,0 @@ -/* $Id: sisci_types.h,v 1.1 2002/12/13 12:17:23 hin Exp $ */ - -/******************************************************************************* - * * - * Copyright (C) 1993 - 2000 * - * Dolphin Interconnect Solutions AS * - * * - * 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 _SISCI_TYPES_H -#define _SISCI_TYPES_H - -#include "sisci_error.h" - -#ifndef IN -#define IN -#endif - -#ifndef OUT -#define OUT -#endif - -#ifndef IN_OUT -#define IN_OUT -#endif - -/* Opaque data types for descriptors/handles */ -typedef struct sci_desc *sci_desc_t; -typedef struct sci_local_segment *sci_local_segment_t; -typedef struct sci_remote_segment *sci_remote_segment_t; - -typedef struct sci_map *sci_map_t; -typedef struct sci_sequence *sci_sequence_t; -#ifndef KERNEL -typedef struct sci_dma_queue *sci_dma_queue_t; -#endif -typedef struct sci_remote_interrupt *sci_remote_interrupt_t; -typedef struct sci_local_interrupt *sci_local_interrupt_t; -typedef struct sci_block_transfer *sci_block_transfer_t; - -/* - * Constants defining reasons for segment callbacks: - */ - -typedef enum { - SCI_CB_CONNECT = 1, - SCI_CB_DISCONNECT, - SCI_CB_NOT_OPERATIONAL, - SCI_CB_OPERATIONAL, - SCI_CB_LOST -} sci_segment_cb_reason_t; - -#define MAX_CB_REASON SCI_CB_LOST - -/* dma_queue_states is identical to the dma_queue_state_t in genif.h, they must be consistent.*/ -typedef enum { - SCI_DMAQUEUE_IDLE, - SCI_DMAQUEUE_GATHER, - SCI_DMAQUEUE_POSTED, - SCI_DMAQUEUE_DONE, - SCI_DMAQUEUE_ABORTED, - SCI_DMAQUEUE_ERROR -} sci_dma_queue_state_t; - - -typedef enum { - SCI_SEQ_OK, - SCI_SEQ_RETRIABLE, - SCI_SEQ_NOT_RETRIABLE, - SCI_SEQ_PENDING -} sci_sequence_status_t; - - -typedef struct { - unsigned short nodeId; /* SCI Address bit 63 - 48 */ - unsigned short offsHi; /* SCI Address bit 47 - 32 */ - unsigned int offsLo; /* SCI Address bit 31 - 0 */ -} sci_address_t; - - -typedef unsigned int sci_ioaddr_t; - -typedef enum { - SCI_CALLBACK_CANCEL = 1, - SCI_CALLBACK_CONTINUE -} sci_callback_action_t; - -#ifndef KERNEL -typedef sci_callback_action_t (*sci_cb_local_segment_t)(void *arg, - sci_local_segment_t segment, - sci_segment_cb_reason_t reason, - unsigned int nodeId, - unsigned int localAdapterNo, - sci_error_t error); - -typedef sci_callback_action_t (*sci_cb_remote_segment_t)(void *arg, - sci_remote_segment_t segment, - sci_segment_cb_reason_t reason, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_dma_t)(void IN *arg, - sci_dma_queue_t queue, - sci_error_t status); - - -typedef int (*sci_cb_block_transfer_t)(void *arg, - sci_block_transfer_t block, - sci_error_t status); - - -typedef sci_callback_action_t (*sci_cb_interrupt_t)(void *arg, - sci_local_interrupt_t interrupt, - sci_error_t status); - -#endif /* KERNEL */ -#endif diff --git a/ndb/src/kernel/Makefile.am b/ndb/src/kernel/Makefile.am index 493ab4f9982..55d3c5a578f 100644 --- a/ndb/src/kernel/Makefile.am +++ b/ndb/src/kernel/Makefile.am @@ -59,3 +59,17 @@ LDADD += \ # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: ndbd.dsp + +ndbd.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(ndbbin_PROGRAMS) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndbd_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) diff --git a/ndb/src/kernel/Makefile_old b/ndb/src/kernel/Makefile_old deleted file mode 100644 index d1f1741aca4..00000000000 --- a/ndb/src/kernel/Makefile_old +++ /dev/null @@ -1,5 +0,0 @@ -include .defs.mk - -DIRS := error vm ndb-main blocks - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/ERROR_codes.txt b/ndb/src/kernel/blocks/ERROR_codes.txt index 70f11c33cd7..5193d3eae9d 100644 --- a/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/ndb/src/kernel/blocks/ERROR_codes.txt @@ -1,8 +1,8 @@ Next QMGR 1 Next NDBCNTR 1000 Next NDBFS 2000 -Next DBACC 3001 -Next DBTUP 4007 +Next DBACC 3002 +Next DBTUP 4013 Next DBLQH 5042 Next DBDICT 6006 Next DBDIH 7174 @@ -10,7 +10,7 @@ Next DBTC 8035 Next CMVMI 9000 Next BACKUP 10022 Next DBUTIL 11002 -Next DBTUX 12001 +Next DBTUX 12007 Next SUMA 13001 TESTING NODE FAILURE, ARBITRATION @@ -393,6 +393,13 @@ Failed Create Table: -------------------- 7173: Create table failed due to not sufficient number of fragment or replica records. +3001: Fail create 1st fragment +4007 12001: Fail create 1st fragment +4008 12002: Fail create 2nd fragment +4009 12003: Fail create 1st attribute in 1st fragment +4010 12004: Fail create last attribute in 1st fragment +4011 12005: Fail create 1st attribute in 2nd fragment +4012 12006: Fail create last attribute in 2nd fragment Drop Table/Index: ----------------- diff --git a/ndb/src/kernel/blocks/Makefile.am b/ndb/src/kernel/blocks/Makefile.am index 0b2bc3b8c88..7ee90e6239f 100644 --- a/ndb/src/kernel/blocks/Makefile.am +++ b/ndb/src/kernel/blocks/Makefile.am @@ -15,3 +15,5 @@ SUBDIRS = \ suma \ grep \ dbtux + +windoze-dsp: diff --git a/ndb/src/kernel/blocks/Makefile_old b/ndb/src/kernel/blocks/Makefile_old deleted file mode 100644 index ce554dfc3b8..00000000000 --- a/ndb/src/kernel/blocks/Makefile_old +++ /dev/null @@ -1,28 +0,0 @@ -#-------------------------------------------------------------------------- -# -# Name Makefile -# -# -# -# List subdirectories to be travered -include .defs.mk - -DIRS := \ - cmvmi \ - dbacc \ - dbdict \ - dbdih \ - dblqh \ - dbtc \ - dbtup \ - ndbfs \ - ndbcntr \ - qmgr \ - trix \ - backup \ - dbutil \ - suma \ - grep \ - dbtux - -include ${NDB_TOP}/Epilogue.mk diff --git a/ndb/src/kernel/blocks/backup/Backup.cpp b/ndb/src/kernel/blocks/backup/Backup.cpp index e6fe63d9014..2e62979ce8e 100644 --- a/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/ndb/src/kernel/blocks/backup/Backup.cpp @@ -863,6 +863,13 @@ Backup::execBACKUP_REQ(Signal* signal) sendBackupRef(senderRef, signal, senderData, BackupRef::IAmNotMaster); return; }//if + + if (m_diskless) + { + sendBackupRef(senderRef, signal, senderData, + BackupRef::CannotBackupDiskless); + return; + } if(dataLen32 != 0) { jam(); @@ -985,7 +992,11 @@ Backup::execUTIL_SEQUENCE_CONF(Signal* signal) }//if ndbrequire(ptr.p->masterData.state.getState() == DEFINING); - ptr.p->backupId = conf->sequenceValue[0]; + { + Uint64 backupId; + memcpy(&backupId,conf->sequenceValue,8); + ptr.p->backupId= (Uint32)backupId; + } ptr.p->backupKey[0] = (getOwnNodeId() << 16) | (ptr.p->backupId & 0xFFFF); ptr.p->backupKey[1] = NdbTick_CurrentMillisecond(); @@ -1265,10 +1276,6 @@ Backup::createAttributeMask(TablePtr tabPtr, jam(); AttributePtr attr; table.attributes.getPtr(attr, i); - if(attr.p->data.key != 0){ - jam(); - continue; - } mask.set(i); } } @@ -2954,12 +2961,9 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len) tabPtr.p->schemaVersion = tmpTab.TableVersion; tabPtr.p->noOfAttributes = tmpTab.NoOfAttributes; - tabPtr.p->noOfKeys = tmpTab.NoOfKeyAttr; tabPtr.p->noOfNull = 0; tabPtr.p->noOfVariable = 0; // Computed while iterating over attribs - tabPtr.p->sz_FixedKeys = 0; // Computed while iterating over attribs tabPtr.p->sz_FixedAttributes = 0; // Computed while iterating over attribs - tabPtr.p->variableKeyId = RNIL; // Computed while iterating over attribs tabPtr.p->triggerIds[0] = ILLEGAL_TRIGGER_ID; tabPtr.p->triggerIds[1] = ILLEGAL_TRIGGER_ID; tabPtr.p->triggerIds[2] = ILLEGAL_TRIGGER_ID; @@ -2994,7 +2998,6 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len) attrPtr.p->data.nullable = tmp.AttributeNullableFlag; attrPtr.p->data.fixed = (tmp.AttributeArraySize != 0); - attrPtr.p->data.key = tmp.AttributeKeyFlag; attrPtr.p->data.sz32 = sz32; /** @@ -3002,50 +3005,26 @@ Backup::parseTableDescription(Signal* signal, BackupRecordPtr ptr, Uint32 len) * 1) Fixed * 2) Nullable * 3) Variable - * 4) Fixed key - * 5) Variable key */ - if(attrPtr.p->data.key == false) { + if(attrPtr.p->data.fixed == true && attrPtr.p->data.nullable == false) { jam(); - - if(attrPtr.p->data.fixed == true && attrPtr.p->data.nullable == false) { - jam(); - attrPtr.p->data.offset = tabPtr.p->sz_FixedAttributes; - tabPtr.p->sz_FixedAttributes += sz32; - }//if - - if(attrPtr.p->data.fixed == true && attrPtr.p->data.nullable == true) { - jam(); - attrPtr.p->data.offset = 0; - - attrPtr.p->data.offsetNull = tabPtr.p->noOfNull; - tabPtr.p->noOfNull++; - tabPtr.p->noOfVariable++; - }//if - - if(attrPtr.p->data.fixed == false) { - jam(); - tabPtr.p->noOfVariable++; - ndbrequire(0); - }//if - - } else if(attrPtr.p->data.key == true) { + attrPtr.p->data.offset = tabPtr.p->sz_FixedAttributes; + tabPtr.p->sz_FixedAttributes += sz32; + }//if + + if(attrPtr.p->data.fixed == true && attrPtr.p->data.nullable == true) { jam(); - ndbrequire(attrPtr.p->data.nullable == false); + attrPtr.p->data.offset = 0; - if(attrPtr.p->data.fixed == true) { // Fixed key - jam(); - tabPtr.p->sz_FixedKeys += sz32; - }//if - - if(attrPtr.p->data.fixed == false) { // Variable key - jam(); - attrPtr.p->data.offset = 0; - tabPtr.p->noOfVariable++; - ndbrequire(tabPtr.p->variableKeyId == RNIL); // Only one variable key - tabPtr.p->variableKeyId = attrPtr.i; - ndbrequire(0); - }//if + attrPtr.p->data.offsetNull = tabPtr.p->noOfNull; + tabPtr.p->noOfNull++; + tabPtr.p->noOfVariable++; + }//if + + if(attrPtr.p->data.fixed == false) { + jam(); + tabPtr.p->noOfVariable++; + ndbrequire(0); }//if it.next(); // Move Past EndOfAttribute @@ -3222,7 +3201,7 @@ Backup::execSTART_BACKUP_REQ(Signal* signal) return; }//if - tabPtr.p->triggerAllocated[i] = true; + tabPtr.p->triggerAllocated[j] = true; trigPtr.p->backupPtr = ptr.i; trigPtr.p->tableId = tabPtr.p->tableId; trigPtr.p->tab_ptr_i = tabPtr.i; @@ -3355,7 +3334,7 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal) Table & table = * tabPtr.p; ScanFragReq * req = (ScanFragReq *)signal->getDataPtrSend(); const Uint32 parallelism = 16; - const Uint32 attrLen = 5 + table.noOfAttributes - table.noOfKeys; + const Uint32 attrLen = 5 + table.noOfAttributes; req->senderData = filePtr.i; req->resultRef = reference(); @@ -3366,7 +3345,7 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal) req->tableId = table.tableId; ScanFragReq::setLockMode(req->requestInfo, 0); ScanFragReq::setHoldLockFlag(req->requestInfo, 0); - ScanFragReq::setKeyinfoFlag(req->requestInfo, 1); + ScanFragReq::setKeyinfoFlag(req->requestInfo, 0); ScanFragReq::setAttrLen(req->requestInfo,attrLen); req->transId1 = 0; req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8); @@ -3381,7 +3360,7 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal) signal->theData[2] = (BACKUP << 20) + (getOwnNodeId() << 8); // Return all - signal->theData[3] = table.noOfAttributes - table.noOfKeys; + signal->theData[3] = table.noOfAttributes; signal->theData[4] = 0; signal->theData[5] = 0; signal->theData[6] = 0; @@ -3393,10 +3372,6 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* signal) jam(); AttributePtr attr; table.attributes.getPtr(attr, i); - if(attr.p->data.key != 0) { - jam(); - continue; - }//if AttributeHeader::init(&signal->theData[dataPos], i, 0); dataPos++; @@ -3506,64 +3481,19 @@ Backup::execTRANSID_AI(Signal* signal) } } -void -Backup::execKEYINFO20(Signal* signal) -{ - jamEntry(); - - const Uint32 filePtrI = signal->theData[0]; - const Uint32 keyLen = signal->theData[1]; - //const Uint32 scanInfo = signal->theData[2]; - //const Uint32 transId1 = signal->theData[3]; - //const Uint32 transId2 = signal->theData[4]; - const Uint32 dataLen = signal->length() - 5; - - BackupFilePtr filePtr; - c_backupFilePool.getPtr(filePtr, filePtrI); - - OperationRecord & op = filePtr.p->operation; - - /** - * Unpack data - */ - ndbrequire(keyLen == dataLen); - const Uint32 * src = &signal->theData[5]; - const Uint32 klFixed = op.getFixedKeySize(); - ndbrequire(keyLen >= klFixed); - - Uint32 * dst = op.newKey(); - memcpy(dst, src, klFixed << 2); - - const Uint32 szLeft = (keyLen - klFixed); - if(szLeft > 0) { - jam(); - src += klFixed; - dst = op.newVariableKey(szLeft); - memcpy(dst, src, (szLeft << 2)); - ndbrequire(0); - }//if - - if(op.finished()){ - jam(); - op.newRecord(op.dst); - } -} - void Backup::OperationRecord::init(const TablePtr & ptr) { tablePtr = ptr.i; - noOfAttributes = (ptr.p->noOfAttributes - ptr.p->noOfKeys) + 1; - variableKeyId = ptr.p->variableKeyId; + noOfAttributes = ptr.p->noOfAttributes; sz_Bitmask = (ptr.p->noOfNull + 31) >> 5; - sz_FixedKeys = ptr.p->sz_FixedKeys; sz_FixedAttribs = ptr.p->sz_FixedAttributes; if(ptr.p->noOfVariable == 0) { jam(); - maxRecordSize = 1 + sz_Bitmask + sz_FixedKeys + sz_FixedAttribs; + maxRecordSize = 1 + sz_Bitmask + sz_FixedAttribs; } else { jam(); maxRecordSize = diff --git a/ndb/src/kernel/blocks/backup/Backup.hpp b/ndb/src/kernel/blocks/backup/Backup.hpp index 4dc2cd13ae0..1a5d6c7a925 100644 --- a/ndb/src/kernel/blocks/backup/Backup.hpp +++ b/ndb/src/kernel/blocks/backup/Backup.hpp @@ -76,7 +76,6 @@ protected: */ void execSCAN_HBREP(Signal* signal); void execTRANSID_AI(Signal* signal); - void execKEYINFO20(Signal* signal); void execSCAN_FRAGREF(Signal* signal); void execSCAN_FRAGCONF(Signal* signal); @@ -172,8 +171,8 @@ public: struct Data { Uint8 nullable; Uint8 fixed; - Uint8 key; - Uint8 unused; + Uint8 unused; + Uint8 unused2; Uint32 sz32; // No of 32 bit words Uint32 offset; // Relative DataFixedAttributes/DataFixedKeys Uint32 offsetNull; // In NullBitmask @@ -199,12 +198,9 @@ public: Uint32 frag_mask; Uint32 tableType; Uint32 noOfNull; - Uint32 noOfKeys; Uint32 noOfAttributes; Uint32 noOfVariable; - Uint32 sz_FixedKeys; Uint32 sz_FixedAttributes; - Uint32 variableKeyId; Uint32 triggerIds[3]; bool triggerAllocated[3]; @@ -224,7 +220,6 @@ public: * Once per table */ void init(const TablePtr & ptr); - inline Uint32 getFixedKeySize() const { return sz_FixedKeys; } /** * Once per fragment @@ -247,23 +242,19 @@ public: /** * Per attribute */ - Uint32 * newKey(); void nullAttribute(Uint32 nullOffset); Uint32 * newNullable(Uint32 attrId, Uint32 sz); Uint32 * newAttrib(Uint32 offset, Uint32 sz); Uint32 * newVariable(Uint32 id, Uint32 sz); - Uint32 * newVariableKey(Uint32 sz); private: Uint32* base; Uint32* dst_Length; Uint32* dst_Bitmask; - Uint32* dst_FixedKeys; Uint32* dst_FixedAttribs; BackupFormat::DataFile::VariableData* dst_VariableData; Uint32 noOfAttributes; // No of Attributes - Uint32 variableKeyId; // Id of variable key Uint32 attrLeft; // No of attributes left Uint32 opNoDone; @@ -289,7 +280,6 @@ public: * sizes of part */ Uint32 sz_Bitmask; - Uint32 sz_FixedKeys; Uint32 sz_FixedAttribs; public: @@ -526,6 +516,7 @@ public: NdbNodeBitmask c_aliveNodes; DLList<BackupRecord> c_backups; Config c_defaults; + Uint32 m_diskless; STATIC_CONST(NO_OF_PAGES_META_FILE = 2); @@ -628,7 +619,6 @@ Backup::OperationRecord::newRecord(Uint32 * p){ base = p; dst_Length = p; p += 1; dst_Bitmask = p; p += sz_Bitmask; - dst_FixedKeys = p; p += sz_FixedKeys; dst_FixedAttribs = p; p += sz_FixedAttribs; dst_VariableData = (BackupFormat::DataFile::VariableData*)p; BitmaskImpl::clear(sz_Bitmask, dst_Bitmask); @@ -646,14 +636,6 @@ Backup::OperationRecord::newAttrib(Uint32 offset, Uint32 sz){ } inline -Uint32 * -Backup::OperationRecord::newKey(){ - attrLeft --; - attrSzLeft = 0; - return dst_FixedKeys; -} - -inline void Backup::OperationRecord::nullAttribute(Uint32 offsetNull){ attrLeft --; @@ -692,28 +674,13 @@ Backup::OperationRecord::newVariable(Uint32 id, Uint32 sz){ } inline -Uint32 * -Backup::OperationRecord::newVariableKey(Uint32 sz){ - attrLeft--; - attrSzLeft = 0; - attrSzTotal += sz; - - dst = &dst_VariableData->Data[0]; - dst_VariableData->Sz = htonl(sz); - dst_VariableData->Id = htonl(variableKeyId); - - dst_VariableData = (BackupFormat::DataFile::VariableData *)(dst + sz); - return dst; -} - -inline bool Backup::OperationRecord::finished(){ if(attrLeft != 0 || attrSzLeft != 0){ return false; } - opLen += attrSzTotal + sz_FixedKeys; + opLen += attrSzTotal; opNoDone++; scanStop = dst = (Uint32 *)dst_VariableData; diff --git a/ndb/src/kernel/blocks/backup/BackupInit.cpp b/ndb/src/kernel/blocks/backup/BackupInit.cpp index 8daad05558b..08fa089a9c0 100644 --- a/ndb/src/kernel/blocks/backup/BackupInit.cpp +++ b/ndb/src/kernel/blocks/backup/BackupInit.cpp @@ -22,7 +22,6 @@ //=========================================================================== #include "Backup.hpp" -#include <new> #include <Properties.hpp> #include <Configuration.hpp> @@ -42,8 +41,10 @@ Backup::Backup(const Configuration & conf) : ndbrequire(p != 0); Uint32 noBackups = 0, noTables = 0, noAttribs = 0; + ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &m_diskless)); ndb_mgm_get_int_parameter(p, CFG_DB_PARALLEL_BACKUPS, &noBackups); - ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_TABLES, &noTables)); + // ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_TABLES, &noTables)); + ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DICT_TABLE, &noTables)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_ATTRIBUTES, &noAttribs)); noAttribs++; //RT 527 bug fix @@ -126,7 +127,6 @@ Backup::Backup(const Configuration & conf) : addRecSignal(GSN_SCAN_HBREP, &Backup::execSCAN_HBREP); addRecSignal(GSN_TRANSID_AI, &Backup::execTRANSID_AI); - addRecSignal(GSN_KEYINFO20, &Backup::execKEYINFO20); addRecSignal(GSN_SCAN_FRAGREF, &Backup::execSCAN_FRAGREF); addRecSignal(GSN_SCAN_FRAGCONF, &Backup::execSCAN_FRAGCONF); @@ -204,7 +204,7 @@ Backup::~Backup() { } -BLOCK_FUNCTIONS(Backup); +BLOCK_FUNCTIONS(Backup) template class ArrayPool<Backup::Page32>; template class ArrayPool<Backup::Attribute>; diff --git a/ndb/src/kernel/blocks/backup/Makefile.am b/ndb/src/kernel/blocks/backup/Makefile.am index 85bf5b12415..c8f44f31292 100644 --- a/ndb/src/kernel/blocks/backup/Makefile.am +++ b/ndb/src/kernel/blocks/backup/Makefile.am @@ -1,6 +1,4 @@ -SUBDIRS = restore - noinst_LIBRARIES = libbackup.a libbackup_a_SOURCES = Backup.cpp BackupInit.cpp @@ -10,3 +8,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libbackup.dsp + +libbackup.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libbackup_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/backup/Makefile_old b/ndb/src/kernel/blocks/backup/Makefile_old deleted file mode 100644 index 989199cbe02..00000000000 --- a/ndb/src/kernel/blocks/backup/Makefile_old +++ /dev/null @@ -1,18 +0,0 @@ -include .defs.mk - -TYPE := kernel - -#ifneq ($(MYSQLCLUSTER_TOP),) -DIRS := restore -#endif - -ARCHIVE_TARGET := backup - -SOURCES = Backup.cpp BackupInit.cpp - -include $(NDB_TOP)/Epilogue.mk - -$(NDB_TOP)/bin/readBackupFile: read.o - $(C++) -o $@ read.o \ - $(NDB_TOP)/lib/libportlib.a $(NDB_TOP)/lib/libgeneral.a - diff --git a/ndb/src/kernel/blocks/backup/restore/Makefile.am b/ndb/src/kernel/blocks/backup/restore/Makefile.am deleted file mode 100644 index 16550f13546..00000000000 --- a/ndb/src/kernel/blocks/backup/restore/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ - -ndbtools_PROGRAMS = ndb_restore - -ndb_restore_SOURCES = main.cpp consumer.cpp consumer_restore.cpp consumer_printer.cpp Restore.cpp - -LDADD_LOC = \ - $(top_builddir)/ndb/src/libndbclient.la \ - $(top_builddir)/dbug/libdbug.a \ - $(top_builddir)/mysys/libmysys.a \ - $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@ - -include $(top_srcdir)/ndb/config/common.mk.am - -INCLUDES += -I.. -I$(top_srcdir)/include -I$(top_srcdir)/ndb/include -I$(top_srcdir)/ndb/src/ndbapi -I$(top_srcdir)/ndb/include/ndbapi -I$(top_srcdir)/ndb/include/util -I$(top_srcdir)/ndb/include/portlib -I$(top_srcdir)/ndb/include/kernel - -ndb_restore_LDFLAGS = @ndb_bin_am_ldflags@ diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 234d832655c..dfae180ae71 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -39,7 +39,6 @@ #include <EventLogger.hpp> #include <TimeQueue.hpp> -#include <new> #include <NdbSleep.h> #include <SafeCounter.hpp> @@ -150,6 +149,7 @@ void Cmvmi::execNDB_TAMPER(Signal* signal) ndbrequire(false); } +#ifndef NDB_WIN32 if(ERROR_INSERTED(9996)){ simulate_error_during_shutdown= SIGSEGV; ndbrequire(false); @@ -159,6 +159,7 @@ void Cmvmi::execNDB_TAMPER(Signal* signal) simulate_error_during_shutdown= SIGSEGV; kill(getpid(), SIGABRT); } +#endif }//execNDB_TAMPER() void Cmvmi::execSET_LOGLEVELORD(Signal* signal) @@ -193,21 +194,11 @@ void Cmvmi::execEVENT_REP(Signal* signal) /** * If entry is not found */ - Uint32 threshold = 16; - LogLevel::EventCategory eventCategory = (LogLevel::EventCategory)0; - - for(unsigned int i = 0; i< EventLoggerBase::matrixSize; i++){ - if(EventLoggerBase::matrix[i].eventType == eventType){ - eventCategory = EventLoggerBase::matrix[i].eventCategory; - threshold = EventLoggerBase::matrix[i].threshold; - break; - } - } - - if(threshold > 15){ - // No entry found in matrix (or event that should never be printed) + Uint32 threshold; + LogLevel::EventCategory eventCategory; + Logger::LoggerLevel severity; + if (EventLoggerBase::event_lookup(eventType,eventCategory,threshold,severity)) return; - } SubscriberPtr ptr; for(subscribers.first(ptr); ptr.i != RNIL; subscribers.next(ptr)){ @@ -225,14 +216,15 @@ void Cmvmi::execEVENT_REP(Signal* signal) // Print the event info g_eventLogger.log(eventReport->getEventType(), signal->theData); + return; }//execEVENT_REP() void Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){ EventSubscribeReq * subReq = (EventSubscribeReq *)&signal->theData[0]; SubscriberPtr ptr; - jamEntry(); + DBUG_ENTER("Cmvmi::execEVENT_SUBSCRIBE_REQ"); /** * Search for subcription @@ -269,11 +261,13 @@ Cmvmi::execEVENT_SUBSCRIBE_REQ(Signal * signal){ category = (LogLevel::EventCategory)(subReq->theData[i] >> 16); level = subReq->theData[i] & 0xFFFF; ptr.p->logLevel.setLogLevel(category, level); + DBUG_PRINT("info",("entry %d: level=%d, category= %d", i, level, category)); } } signal->theData[0] = ptr.i; sendSignal(ptr.p->blockRef, GSN_EVENT_SUBSCRIBE_CONF, signal, 1, JBB); + DBUG_VOID_RETURN; } void @@ -1117,7 +1111,7 @@ Cmvmi::execDUMP_STATE_ORD(Signal* signal) }//Cmvmi::execDUMP_STATE_ORD() -BLOCK_FUNCTIONS(Cmvmi); +BLOCK_FUNCTIONS(Cmvmi) static Uint32 g_print; static LinearSectionPtr g_test[3]; diff --git a/ndb/src/kernel/blocks/cmvmi/Makefile.am b/ndb/src/kernel/blocks/cmvmi/Makefile.am index fdd43932682..dc2e12746fd 100644 --- a/ndb/src/kernel/blocks/cmvmi/Makefile.am +++ b/ndb/src/kernel/blocks/cmvmi/Makefile.am @@ -8,3 +8,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libcmvmi.dsp + +libcmvmi.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libcmvmi_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/cmvmi/Makefile_old b/ndb/src/kernel/blocks/cmvmi/Makefile_old deleted file mode 100644 index d75e5dbf08b..00000000000 --- a/ndb/src/kernel/blocks/cmvmi/Makefile_old +++ /dev/null @@ -1,9 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := cmvmi - -SOURCES = Cmvmi.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp b/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp index 2705f95f6dd..95b336a0a65 100644 --- a/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp +++ b/ndb/src/kernel/blocks/dbacc/DbaccInit.cpp @@ -264,4 +264,4 @@ Dbacc::~Dbacc() }//Dbacc::~Dbacc() -BLOCK_FUNCTIONS(Dbacc); +BLOCK_FUNCTIONS(Dbacc) diff --git a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp index 9a1bbd86562..a82c96beebd 100644 --- a/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp +++ b/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp @@ -1062,7 +1062,21 @@ void Dbacc::execACCFRAGREQ(Signal* signal) { const AccFragReq * const req = (AccFragReq*)&signal->theData[0]; jamEntry(); + if (ERROR_INSERTED(3001)) { + jam(); + addFragRefuse(signal, 1); + CLEAR_ERROR_INSERT_VALUE; + return; + } tabptr.i = req->tableId; +#ifndef VM_TRACE + // config mismatch - do not crash if release compiled + if (tabptr.i >= ctablesize) { + jam(); + addFragRefuse(signal, 800); + return; + } +#endif ptrCheckGuard(tabptr, ctablesize, tabrec); ndbrequire((req->reqInfo & 0xF) == ZADDFRAG); ndbrequire(!getrootfragmentrec(signal, rootfragrecptr, req->fragId)); @@ -4501,6 +4515,17 @@ void Dbacc::getdirindex(Signal* signal) /* BUCKET, AND SERCH FOR ELEMENT.THE PRIMARY KEYS WHICH IS SAVED */ /* IN THE OPERATION REC ARE THE CHECK ITEMS IN THE SEARCHING. */ /* --------------------------------------------------------------------------------- */ + +#if __ia64 == 1 +#if __INTEL_COMPILER == 810 +int ndb_acc_ia64_icc810_dummy_var = 0; +void ndb_acc_ia64_icc810_dummy_func() +{ + ndb_acc_ia64_icc810_dummy_var++; +} +#endif +#endif + void Dbacc::getElement(Signal* signal) { DirRangePtr geOverflowrangeptr; @@ -4595,6 +4620,12 @@ void Dbacc::getElement(Signal* signal) /* WE HAVE FOUND THE ELEMENT. GET THE LOCK INDICATOR AND RETURN FOUND. */ /* --------------------------------------------------------------------------------- */ jam(); +#if __ia64 == 1 +#if __INTEL_COMPILER == 810 + // prevents SIGSEGV under icc -O1 + ndb_acc_ia64_icc810_dummy_func(); +#endif +#endif tgeLocked = ElementHeader::getLocked(gePageptr.p->word32[tgeElementptr]); tgeResult = ZTRUE; TdataIndex = tgeElementptr + tgeForward; @@ -5673,7 +5704,8 @@ void Dbacc::commitOperation(Signal* signal) Uint32 tmp2Olq; if ((operationRecPtr.p->commitDeleteCheckFlag == ZFALSE) && - (operationRecPtr.p->operation != ZSCAN_OP)) { + (operationRecPtr.p->operation != ZSCAN_OP) && + (operationRecPtr.p->operation != ZREAD)) { jam(); /* This method is used to check whether the end result of the transaction will be to delete the tuple. In this case all operation will be marked diff --git a/ndb/src/kernel/blocks/dbacc/Makefile.am b/ndb/src/kernel/blocks/dbacc/Makefile.am index 7ccfbe22f76..e44524c3edd 100644 --- a/ndb/src/kernel/blocks/dbacc/Makefile.am +++ b/ndb/src/kernel/blocks/dbacc/Makefile.am @@ -8,3 +8,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libdbacc.dsp + +libdbacc.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libdbacc_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/dbacc/Makefile_old b/ndb/src/kernel/blocks/dbacc/Makefile_old deleted file mode 100644 index 93a830cec95..00000000000 --- a/ndb/src/kernel/blocks/dbacc/Makefile_old +++ /dev/null @@ -1,11 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := dbacc - -SOURCES = \ - DbaccInit.cpp \ - DbaccMain.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index d1a8128ea7f..b1e573e1cc8 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -239,7 +239,11 @@ Dbdict::packTableIntoPagesImpl(SimpleProperties::Writer & w, w.add(DictTabInfo::TableName, tablePtr.p->tableName); w.add(DictTabInfo::TableId, tablePtr.i); +#ifdef HAVE_TABLE_REORG w.add(DictTabInfo::SecondTableId, tablePtr.p->secondTable); +#else + w.add(DictTabInfo::SecondTableId, (Uint32)0); +#endif w.add(DictTabInfo::TableVersion, tablePtr.p->tableVersion); w.add(DictTabInfo::NoOfKeyAttr, tablePtr.p->noOfPrimkey); w.add(DictTabInfo::NoOfAttributes, tablePtr.p->noOfAttributes); @@ -528,7 +532,7 @@ Dbdict::writeTableFile(Signal* signal, Uint32 tableId, Uint32 sz = tabInfoPtr.sz + ZPAGE_HEADER_SIZE; c_writeTableRecord.noOfPages = DIV(sz, ZSIZE_OF_PAGES_IN_WORDS); - c_writeTableRecord.tableWriteState = WriteTableRecord::CALLBACK; + c_writeTableRecord.tableWriteState = WriteTableRecord::TWR_CALLBACK; c_writeTableRecord.m_callback = * callback; c_writeTableRecord.pageId = 0; @@ -647,7 +651,7 @@ void Dbdict::closeWriteTableConf(Signal* signal, case WriteTableRecord::WRITE_RESTART_FROM_OWN : ndbrequire(false); break; - case WriteTableRecord::CALLBACK: + case WriteTableRecord::TWR_CALLBACK: jam(); execute(signal, c_writeTableRecord.m_callback, 0); return; @@ -1188,7 +1192,7 @@ Dbdict::~Dbdict() { }//Dbdict::~Dbdict() -BLOCK_FUNCTIONS(Dbdict); +BLOCK_FUNCTIONS(Dbdict) void Dbdict::initCommonData() { @@ -1436,6 +1440,7 @@ Uint32 Dbdict::getFreeTableRecord(Uint32 primaryTableId) jam(); return RNIL; }//if +#ifdef HAVE_TABLE_REORG bool secondFound = false; for (tablePtr.i = firstTablePtr.i + 1; tablePtr.i < tabSize ; tablePtr.i++) { jam(); @@ -1455,6 +1460,7 @@ Uint32 Dbdict::getFreeTableRecord(Uint32 primaryTableId) firstTablePtr.p->tabState = TableRecord::NOT_DEFINED; return RNIL; }//if +#endif return firstTablePtr.i; }//Dbdict::getFreeTableRecord() @@ -2381,7 +2387,7 @@ Dbdict::restartCreateTab_readTableConf(Signal* signal, ndbrequire(c_writeTableRecord.tableWriteState == WriteTableRecord::IDLE); c_writeTableRecord.noOfPages = c_readTableRecord.noOfPages; c_writeTableRecord.pageId = c_readTableRecord.pageId; - c_writeTableRecord.tableWriteState = WriteTableRecord::CALLBACK; + c_writeTableRecord.tableWriteState = WriteTableRecord::TWR_CALLBACK; c_writeTableRecord.m_callback.m_callbackData = callbackData; c_writeTableRecord.m_callback.m_callbackFunction = safe_cast(&Dbdict::restartCreateTab_writeTableConf); @@ -3661,9 +3667,8 @@ Dbdict::execCREATE_FRAGMENTATION_CONF(Signal* signal){ req->tableId = tabPtr.i; req->tableVersion = tabEntry->m_tableVersion + 1; - sendSignal(rg, GSN_CREATE_TAB_REQ, signal, - CreateTabReq::SignalLength, JBB); - + sendFragmentedSignal(rg, GSN_CREATE_TAB_REQ, signal, + CreateTabReq::SignalLength, JBB); return; } @@ -4624,7 +4629,7 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it, jam(); tablePtr.p->tabState = TableRecord::DEFINING; }//if - +#ifdef HAVE_TABLE_REORG /* ---------------------------------------------------------------- */ // Get id of second table id and check that table doesn't already exist // and set up links between first and second table. @@ -4638,7 +4643,7 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it, secondTablePtr.p->tabState = TableRecord::REORG_TABLE_PREPARED; secondTablePtr.p->secondTable = tablePtr.i; tablePtr.p->secondTable = secondTablePtr.i; - +#endif /* ---------------------------------------------------------------- */ // Set table version /* ---------------------------------------------------------------- */ @@ -5536,10 +5541,12 @@ void Dbdict::releaseTableObject(Uint32 tableId, bool removeFromHash) nextAttrRecord = attrPtr.p->nextAttrInTable; c_attributeRecordPool.release(attrPtr); }//if +#ifdef HAVE_TABLE_REORG Uint32 secondTableId = tablePtr.p->secondTable; initialiseTableRecord(tablePtr); c_tableRecordPool.getPtr(tablePtr, secondTableId); initialiseTableRecord(tablePtr); +#endif return; }//releaseTableObject() @@ -6046,11 +6053,21 @@ Dbdict::execCREATE_INDX_REQ(Signal* signal) jam(); if (getOwnNodeId() != c_masterNodeId) { jam(); - // forward to DICT master - sendSignal(calcDictBlockRef(c_masterNodeId), GSN_CREATE_INDX_REQ, - signal, signal->getLength(), JBB); - return; + + releaseSections(signal); + OpCreateIndex opBusy; + opPtr.p = &opBusy; + opPtr.p->save(req); + opPtr.p->m_isMaster = (senderRef == reference()); + opPtr.p->key = 0; + opPtr.p->m_requestType = CreateIndxReq::RT_DICT_PREPARE; + opPtr.p->m_errorCode = CreateIndxRef::NotMaster; + opPtr.p->m_errorLine = __LINE__; + opPtr.p->m_errorNode = c_masterNodeId; + createIndex_sendReply(signal, opPtr, true); + return; } + // forward initial request plus operation key to all req->setOpKey(++c_opRecordSequence); NodeReceiverGroup rg(DBDICT, c_aliveNodes); @@ -6581,10 +6598,9 @@ Dbdict::execDROP_INDX_REQ(Signal* signal) jam(); if (getOwnNodeId() != c_masterNodeId) { jam(); - // forward to DICT master - sendSignal(calcDictBlockRef(c_masterNodeId), GSN_DROP_INDX_REQ, - signal, signal->getLength(), JBB); - return; + + err = DropIndxRef::NotMaster; + goto error; } // forward initial request plus operation key to all Uint32 indexId= req->getIndexId(); @@ -6672,6 +6688,7 @@ error: opPtr.p->save(req); opPtr.p->m_errorCode = (DropIndxRef::ErrorCode)err; opPtr.p->m_errorLine = __LINE__; + opPtr.p->m_errorNode = c_masterNodeId; dropIndex_sendReply(signal, opPtr, true); } @@ -9110,9 +9127,15 @@ Dbdict::execALTER_INDX_REQ(Signal* signal) jam(); if (! isLocal && getOwnNodeId() != c_masterNodeId) { jam(); - // forward to DICT master - sendSignal(calcDictBlockRef(c_masterNodeId), GSN_ALTER_INDX_REQ, - signal, signal->getLength(), JBB); + + releaseSections(signal); + OpAlterIndex opBad; + opPtr.p = &opBad; + opPtr.p->save(req); + opPtr.p->m_errorCode = AlterIndxRef::NotMaster; + opPtr.p->m_errorLine = __LINE__; + opPtr.p->m_errorNode = c_masterNodeId; + alterIndex_sendReply(signal, opPtr, true); return; } // forward initial request plus operation key to all @@ -9790,9 +9813,15 @@ Dbdict::execBUILDINDXREQ(Signal* signal) jam(); if (getOwnNodeId() != c_masterNodeId) { jam(); - // forward to DICT master - sendSignal(calcDictBlockRef(c_masterNodeId), GSN_BUILDINDXREQ, - signal, signal->getLength(), JBB); + + releaseSections(signal); + OpBuildIndex opBad; + opPtr.p = &opBad; + opPtr.p->save(req); + opPtr.p->m_errorCode = BuildIndxRef::NotMaster; + opPtr.p->m_errorLine = __LINE__; + opPtr.p->m_errorNode = c_masterNodeId; + buildIndex_sendReply(signal, opPtr, true); return; } // forward initial request plus operation key to all @@ -10208,6 +10237,7 @@ Dbdict::buildIndex_sendReply(Signal* signal, OpBuildIndexPtr opPtr, rep->setIndexId(opPtr.p->m_request.getIndexId()); if (sendRef) { rep->setErrorCode(opPtr.p->m_errorCode); + rep->masterNodeId = opPtr.p->m_errorNode; gsn = GSN_BUILDINDXREF; length = BuildIndxRef::SignalLength; } @@ -10256,9 +10286,15 @@ Dbdict::execCREATE_TRIG_REQ(Signal* signal) jam(); if (! isLocal && getOwnNodeId() != c_masterNodeId) { jam(); - // forward to DICT master - sendSignal(calcDictBlockRef(c_masterNodeId), GSN_CREATE_TRIG_REQ, - signal, signal->getLength(), JBB); + + releaseSections(signal); + OpCreateTrigger opBad; + opPtr.p = &opBad; + opPtr.p->save(req); + opPtr.p->m_errorCode = CreateTrigRef::NotMaster; + opPtr.p->m_errorLine = __LINE__; + opPtr.p->m_errorNode = c_masterNodeId; + createTrigger_sendReply(signal, opPtr, true); return; } // forward initial request plus operation key to all diff --git a/ndb/src/kernel/blocks/dbdict/Dbdict.hpp b/ndb/src/kernel/blocks/dbdict/Dbdict.hpp index 19c03a86e22..5fc4742e829 100644 --- a/ndb/src/kernel/blocks/dbdict/Dbdict.hpp +++ b/ndb/src/kernel/blocks/dbdict/Dbdict.hpp @@ -151,10 +151,10 @@ public: /* Temporary record used during add/drop table */ Uint32 myConnect; - +#ifdef HAVE_TABLE_REORG /* Second table used by this table (for table reorg) */ Uint32 secondTable; - +#endif /* Next record in Pool */ Uint32 nextPool; @@ -639,7 +639,7 @@ private: WRITE_ADD_TABLE_SLAVE = 2, WRITE_RESTART_FROM_MASTER = 3, WRITE_RESTART_FROM_OWN = 4, - CALLBACK = 5 + TWR_CALLBACK = 5 }; TableWriteState tableWriteState; Callback m_callback; diff --git a/ndb/src/kernel/blocks/dbdict/Makefile.am b/ndb/src/kernel/blocks/dbdict/Makefile.am index dc4c4fe4734..9a0d68f8148 100644 --- a/ndb/src/kernel/blocks/dbdict/Makefile.am +++ b/ndb/src/kernel/blocks/dbdict/Makefile.am @@ -9,3 +9,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libdbdict.dsp + +libdbdict.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libdbdict_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/dbdict/Makefile_old b/ndb/src/kernel/blocks/dbdict/Makefile_old deleted file mode 100644 index 46d938114fb..00000000000 --- a/ndb/src/kernel/blocks/dbdict/Makefile_old +++ /dev/null @@ -1,12 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := dbdict - -SOURCES = \ - Dbdict.cpp - -DIRS := printSchemafile - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp index 14fa262f871..ee67bf47d7b 100644 --- a/ndb/src/kernel/blocks/dbdih/Dbdih.hpp +++ b/ndb/src/kernel/blocks/dbdih/Dbdih.hpp @@ -147,7 +147,6 @@ public: Uint32 nfConnect; Uint32 table; Uint32 userpointer; - Uint32 nodeCount; BlockReference userblockref; }; typedef Ptr<ConnectRecord> ConnectRecordPtr; @@ -1469,7 +1468,7 @@ private: Uint32 c_blockCommitNo; bool getBlockCommit() const { - return c_blockCommit == true || cgckptflag == true; + return c_blockCommit || cgckptflag; } /** diff --git a/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp b/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp index 7ca45ef4b43..9a5efebc56e 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp @@ -18,7 +18,6 @@ #define DBDIH_C #include "Dbdih.hpp" #include <ndb_limits.h> -#include <new> #define DEBUG(x) { ndbout << "DIH::" << x << endl; } @@ -314,7 +313,7 @@ Dbdih::~Dbdih() }//Dbdih::~Dbdih() -BLOCK_FUNCTIONS(Dbdih); +BLOCK_FUNCTIONS(Dbdih) diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 76aa745c3e0..0bc8351a9db 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -2976,6 +2976,8 @@ void Dbdih::execCOPY_FRAGREF(Signal* signal) SystemError * const sysErr = (SystemError*)&signal->theData[0]; sysErr->errorCode = SystemError::CopyFragRefError; sysErr->errorRef = reference(); + sysErr->data1 = errorCode; + sysErr->data2 = 0; sendSignal(cntrRef, GSN_SYSTEM_ERROR, signal, SystemError::SignalLength, JBB); return; @@ -4492,6 +4494,8 @@ void Dbdih::handleTakeOverNewMaster(Signal* signal, Uint32 takeOverPtrI) SystemError * const sysErr = (SystemError*)&signal->theData[0]; sysErr->errorCode = SystemError::CopyFragRefError; sysErr->errorRef = reference(); + sysErr->data1= 0; + sysErr->data2= __LINE__; sendSignal(cntrRef, GSN_SYSTEM_ERROR, signal, SystemError::SignalLength, JBB); } @@ -6174,7 +6178,7 @@ void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal){ break; case DictTabInfo::AllNodesMediumTable: jam(); - noOfFragments = csystemnodes; + noOfFragments = 2 * csystemnodes; break; case DictTabInfo::AllNodesLargeTable: jam(); @@ -7080,24 +7084,22 @@ void Dbdih::execDIGETPRIMREQ(Signal* signal) ndbrequire(tabPtr.p->tabStatus == TabRecord::TS_ACTIVE); connectPtr.i = signal->theData[0]; - if(connectPtr.i != RNIL){ + if(connectPtr.i != RNIL) + { jam(); ptrCheckGuard(connectPtr, cconnectFileSize, connectRecord); - ndbrequire(connectPtr.p->connectState == ConnectRecord::INUSE); - getFragstore(tabPtr.p, fragId, fragPtr); - connectPtr.p->nodeCount = extractNodeInfo(fragPtr.p, connectPtr.p->nodes); signal->theData[0] = connectPtr.p->userpointer; - signal->theData[1] = passThrough; - signal->theData[2] = connectPtr.p->nodes[0]; - sendSignal(connectPtr.p->userblockref, GSN_DIGETPRIMCONF, signal, 3, JBB); - return; - }//if - //connectPtr.i == RNIL -> question without connect record + } + else + { + jam(); + signal->theData[0] = RNIL; + } + Uint32 nodes[MAX_REPLICAS]; getFragstore(tabPtr.p, fragId, fragPtr); Uint32 count = extractNodeInfo(fragPtr.p, nodes); - signal->theData[0] = RNIL; signal->theData[1] = passThrough; signal->theData[2] = nodes[0]; signal->theData[3] = nodes[1]; @@ -12944,7 +12946,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) Uint32 nodeOrder[MAX_REPLICAS]; const Uint32 noOfReplicas = extractNodeInfo(fragPtr.p, nodeOrder); char buf[100]; - snprintf(buf, sizeof(buf), " Table %d Fragment %d - ", tabPtr.i, j); + BaseString::snprintf(buf, sizeof(buf), " Table %d Fragment %d - ", tabPtr.i, j); for(Uint32 k = 0; k < noOfReplicas; k++){ char tmp[100]; BaseString::snprintf(tmp, sizeof(tmp), "%d ", nodeOrder[k]); @@ -13155,7 +13157,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) getFragstore(tabPtr.p, fid, fragPtr); char buf[100], buf2[100]; - snprintf(buf, sizeof(buf), " Fragment %d: noLcpReplicas==%d ", + BaseString::snprintf(buf, sizeof(buf), " Fragment %d: noLcpReplicas==%d ", fid, fragPtr.p->noLcpReplicas); Uint32 num=0; diff --git a/ndb/src/kernel/blocks/dbdih/Makefile.am b/ndb/src/kernel/blocks/dbdih/Makefile.am index 2ee8017ec13..d6ad380b806 100644 --- a/ndb/src/kernel/blocks/dbdih/Makefile.am +++ b/ndb/src/kernel/blocks/dbdih/Makefile.am @@ -7,3 +7,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libdbdih.dsp + +libdbdih.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libdbdih_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/dbdih/Makefile_old b/ndb/src/kernel/blocks/dbdih/Makefile_old deleted file mode 100644 index 83c1b95b5c4..00000000000 --- a/ndb/src/kernel/blocks/dbdih/Makefile_old +++ /dev/null @@ -1,13 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := dbdih - -DIRS := printSysfile - -SOURCES = \ - DbdihInit.cpp \ - DbdihMain.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index d6987f3e478..0c63cb5fe17 100644 --- a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -550,6 +550,11 @@ public: UintR scanErrorCounter; UintR scanLocalFragid; UintR scanSchemaVersion; + + /** + * This is _always_ main table, even in range scan + * in which case scanTcrec->fragmentptr is different + */ Uint32 fragPtrI; UintR scanStoredProcId; ScanState scanState; @@ -2474,7 +2479,7 @@ private: void sendExecFragRefLab(Signal* signal); void fragrefLab(Signal* signal, BlockReference retRef, Uint32 retPtr, Uint32 errorCode); - void accFragRefLab(Signal* signal); + void abortAddFragOps(Signal* signal); void rwConcludedLab(Signal* signal); void sendsttorryLab(Signal* signal); void initialiseRecordsLab(Signal* signal, Uint32 data, Uint32, Uint32); @@ -2925,4 +2930,23 @@ Dblqh::ScanRecord::check_scan_batch_completed() const (max_bytes > 0 && (m_curr_batch_size_bytes >= max_bytes)); } +inline +void +Dblqh::i_get_acc_ptr(ScanRecord* scanP, Uint32* &acc_ptr, Uint32 index) +{ + if (index == 0) { + acc_ptr= (Uint32*)&scanP->scan_acc_op_ptr[0]; + } else { + Uint32 attr_buf_index, attr_buf_rec; + + AttrbufPtr regAttrPtr; + jam(); + attr_buf_rec= (index + 31) / 32; + attr_buf_index= (index - 1) & 31; + regAttrPtr.i= scanP->scan_acc_op_ptr[attr_buf_rec]; + ptrCheckGuard(regAttrPtr, cattrinbufFileSize, attrbuf); + acc_ptr= (Uint32*)®AttrPtr.p->attrbuf[attr_buf_index]; + } +} + #endif diff --git a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp index d0fef8753cb..ec29489180c 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhInit.cpp @@ -19,7 +19,6 @@ #define DBLQH_C #include "Dblqh.hpp" #include <ndb_limits.h> -#include <new> #define DEBUG(x) { ndbout << "LQH::" << x << endl; } @@ -454,5 +453,5 @@ Dblqh::~Dblqh() ctcNodeFailrecFileSize); }//Dblqh::~Dblqh() -BLOCK_FUNCTIONS(Dblqh); +BLOCK_FUNCTIONS(Dblqh) diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index cd15ad0c3b2..c79f4dfc6c7 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -912,6 +912,10 @@ void Dblqh::execREAD_CONFIG_REQ(Signal* signal) /* *********************************************************> */ /* LQHFRAGREQ: Create new fragments for a table. Sender DICT */ /* *********************************************************> */ + +// this unbelievable mess could be replaced by one signal to LQH +// and execute direct to local DICT to get everything at once + void Dblqh::execLQHFRAGREQ(Signal* signal) { jamEntry(); @@ -1049,6 +1053,11 @@ void Dblqh::execLQHFRAGREQ(Signal* signal) addfragptr.p->lh3DistrBits = tlhstar; addfragptr.p->tableType = tableType; addfragptr.p->primaryTableId = primaryTableId; + // + addfragptr.p->tup1Connectptr = RNIL; + addfragptr.p->tup2Connectptr = RNIL; + addfragptr.p->tux1Connectptr = RNIL; + addfragptr.p->tux2Connectptr = RNIL; if (DictTabInfo::isTable(tableType) || DictTabInfo::isHashIndex(tableType)) { @@ -1329,15 +1338,21 @@ void Dblqh::execTUP_ADD_ATTCONF(Signal* signal) { jamEntry(); addfragptr.i = signal->theData[0]; + // implies that operation was released on the other side + const bool lastAttr = signal->theData[1]; ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord); switch (addfragptr.p->addfragStatus) { case AddFragRecord::TUP_ATTR_WAIT1: jam(); + if (lastAttr) + addfragptr.p->tup1Connectptr = RNIL; addfragptr.p->addfragStatus = AddFragRecord::TUP_ATTR_WAIT2; sendAddAttrReq(signal); break; case AddFragRecord::TUP_ATTR_WAIT2: jam(); + if (lastAttr) + addfragptr.p->tup2Connectptr = RNIL; if (DictTabInfo::isOrderedIndex(addfragptr.p->tableType)) { addfragptr.p->addfragStatus = AddFragRecord::TUX_ATTR_WAIT1; sendAddAttrReq(signal); @@ -1347,11 +1362,15 @@ void Dblqh::execTUP_ADD_ATTCONF(Signal* signal) break; case AddFragRecord::TUX_ATTR_WAIT1: jam(); + if (lastAttr) + addfragptr.p->tux1Connectptr = RNIL; addfragptr.p->addfragStatus = AddFragRecord::TUX_ATTR_WAIT2; sendAddAttrReq(signal); break; case AddFragRecord::TUX_ATTR_WAIT2: jam(); + if (lastAttr) + addfragptr.p->tux2Connectptr = RNIL; goto done_with_attr; break; done_with_attr: @@ -1455,6 +1474,7 @@ Dblqh::sendAddAttrReq(Signal* signal) jam(); TupAddAttrConf* tupconf = (TupAddAttrConf*)signal->getDataPtrSend(); tupconf->userPtr = addfragptr.i; + tupconf->lastAttr = false; sendSignal(reference(), GSN_TUP_ADD_ATTCONF, signal, TupAddAttrConf::SignalLength, JBB); return; @@ -1485,6 +1505,7 @@ Dblqh::sendAddAttrReq(Signal* signal) jam(); TuxAddAttrConf* tuxconf = (TuxAddAttrConf*)signal->getDataPtrSend(); tuxconf->userPtr = addfragptr.i; + tuxconf->lastAttr = false; sendSignal(reference(), GSN_TUX_ADD_ATTRCONF, signal, TuxAddAttrConf::SignalLength, JBB); return; @@ -1549,6 +1570,40 @@ void Dblqh::fragrefLab(Signal* signal, return; }//Dblqh::fragrefLab() +/* + * Abort on-going ops. + */ +void Dblqh::abortAddFragOps(Signal* signal) +{ + fragptr.i = addfragptr.p->fragmentPtr; + ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord); + signal->theData[0] = (Uint32)-1; + if (addfragptr.p->tup1Connectptr != RNIL) { + jam(); + signal->theData[1] = addfragptr.p->tup1Connectptr; + sendSignal(fragptr.p->tupBlockref, GSN_TUPFRAGREQ, signal, 2, JBB); + addfragptr.p->tup1Connectptr = RNIL; + } + if (addfragptr.p->tup2Connectptr != RNIL) { + jam(); + signal->theData[1] = addfragptr.p->tup2Connectptr; + sendSignal(fragptr.p->tupBlockref, GSN_TUPFRAGREQ, signal, 2, JBB); + addfragptr.p->tup2Connectptr = RNIL; + } + if (addfragptr.p->tux1Connectptr != RNIL) { + jam(); + signal->theData[1] = addfragptr.p->tux1Connectptr; + sendSignal(fragptr.p->tuxBlockref, GSN_TUXFRAGREQ, signal, 2, JBB); + addfragptr.p->tux1Connectptr = RNIL; + } + if (addfragptr.p->tux2Connectptr != RNIL) { + jam(); + signal->theData[1] = addfragptr.p->tux2Connectptr; + sendSignal(fragptr.p->tuxBlockref, GSN_TUXFRAGREQ, signal, 2, JBB); + addfragptr.p->tux2Connectptr = RNIL; + } +} + /* ************>> */ /* ACCFRAGREF > */ /* ************>> */ @@ -1582,6 +1637,27 @@ void Dblqh::execTUPFRAGREF(Signal* signal) fragptr.i = addfragptr.p->fragmentPtr; ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord); addfragptr.p->addfragErrorCode = terrorCode; + + // no operation to release, just add some jams + switch (addfragptr.p->addfragStatus) { + case AddFragRecord::WAIT_TWO_TUP: + jam(); + break; + case AddFragRecord::WAIT_ONE_TUP: + jam(); + break; + case AddFragRecord::WAIT_TWO_TUX: + jam(); + break; + case AddFragRecord::WAIT_ONE_TUX: + jam(); + break; + default: + ndbrequire(false); + break; + } + abortAddFragOps(signal); + const Uint32 ref = addfragptr.p->dictBlockref; const Uint32 senderData = addfragptr.p->dictConnectptr; const Uint32 errorCode = addfragptr.p->addfragErrorCode; @@ -1605,11 +1681,38 @@ void Dblqh::execTUXFRAGREF(Signal* signal) void Dblqh::execTUP_ADD_ATTRREF(Signal* signal) { jamEntry(); - addfragptr.i = signal->theData[0]; ptrCheckGuard(addfragptr, caddfragrecFileSize, addFragRecord); terrorCode = signal->theData[1]; addfragptr.p->addfragErrorCode = terrorCode; + + // operation was released on the other side + switch (addfragptr.p->addfragStatus) { + case AddFragRecord::TUP_ATTR_WAIT1: + jam(); + ndbrequire(addfragptr.p->tup1Connectptr != RNIL); + addfragptr.p->tup1Connectptr = RNIL; + break; + case AddFragRecord::TUP_ATTR_WAIT2: + jam(); + ndbrequire(addfragptr.p->tup2Connectptr != RNIL); + addfragptr.p->tup2Connectptr = RNIL; + break; + case AddFragRecord::TUX_ATTR_WAIT1: + jam(); + ndbrequire(addfragptr.p->tux1Connectptr != RNIL); + addfragptr.p->tux1Connectptr = RNIL; + break; + case AddFragRecord::TUX_ATTR_WAIT2: + jam(); + ndbrequire(addfragptr.p->tux2Connectptr != RNIL); + addfragptr.p->tux2Connectptr = RNIL; + break; + default: + ndbrequire(false); + break; + } + abortAddFragOps(signal); const Uint32 Ref = addfragptr.p->dictBlockref; const Uint32 senderData = addfragptr.p->dictConnectptr; @@ -2981,6 +3084,7 @@ void Dblqh::execATTRINFO(Signal* signal) return; break; default: + ndbout_c("%d", regTcPtr->transactionState); ndbrequire(false); break; }//switch @@ -7058,10 +7162,7 @@ void Dblqh::continueScanNextReqLab(Signal* signal) // Update timer on tcConnectRecord tcConnectptr.p->tcTimer = cLqhTimeOutCount; - init_acc_ptr_list(scanptr.p); - scanptr.p->m_curr_batch_size_rows = 0; - scanptr.p->m_curr_batch_size_bytes= 0; scanptr.p->scanFlag = NextScanReq::ZSCAN_NEXT; scanNextLoopLab(signal); }//Dblqh::continueScanNextReqLab() @@ -7219,6 +7320,8 @@ void Dblqh::closeScanRequestLab(Signal* signal) scanptr.p->m_curr_batch_size_rows = 0; scanptr.p->m_curr_batch_size_bytes= 0; sendScanFragConf(signal, ZTRUE); + abort_scan(signal, scanptr.i, 0); + return; break; case TcConnectionrec::SCAN_TUPKEY: case TcConnectionrec::SCAN_FIRST_STOPPED: @@ -7260,22 +7363,32 @@ void Dblqh::scanLockReleasedLab(Signal* signal) tcConnectptr.i = scanptr.p->scanTcrec; ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec); releaseActiveFrag(signal); + if (scanptr.p->scanReleaseCounter == scanptr.p->m_curr_batch_size_rows) { if ((scanptr.p->scanErrorCounter > 0) || (scanptr.p->scanCompletedStatus == ZTRUE)) { jam(); + scanptr.p->m_curr_batch_size_rows = 0; + scanptr.p->m_curr_batch_size_bytes = 0; closeScanLab(signal); } else if (scanptr.p->check_scan_batch_completed() && scanptr.p->scanLockHold != ZTRUE) { jam(); scanptr.p->scanState = ScanRecord::WAIT_SCAN_NEXTREQ; sendScanFragConf(signal, ZFALSE); + } else if (scanptr.p->m_last_row && !scanptr.p->scanLockHold) { + jam(); + closeScanLab(signal); + return; } else { jam(); /* - We came here after releasing locks after receiving SCAN_NEXTREQ from TC. We only - come here when scanHoldLock == ZTRUE - */ + * We came here after releasing locks after + * receiving SCAN_NEXTREQ from TC. We only come here + * when scanHoldLock == ZTRUE + */ + scanptr.p->m_curr_batch_size_rows = 0; + scanptr.p->m_curr_batch_size_bytes = 0; continueScanNextReqLab(signal); }//if } else if (scanptr.p->scanReleaseCounter < scanptr.p->m_curr_batch_size_rows) { @@ -7362,25 +7475,6 @@ Dblqh::init_acc_ptr_list(ScanRecord* scanP) scanP->scan_acc_index = 0; } -inline -void -Dblqh::i_get_acc_ptr(ScanRecord* scanP, Uint32* &acc_ptr, Uint32 index) -{ - if (index == 0) { - acc_ptr= (Uint32*)&scanP->scan_acc_op_ptr[0]; - } else { - Uint32 attr_buf_index, attr_buf_rec; - - AttrbufPtr regAttrPtr; - jam(); - attr_buf_rec= (index + 31) / 32; - attr_buf_index= (index - 1) & 31; - regAttrPtr.i= scanP->scan_acc_op_ptr[attr_buf_rec]; - ptrCheckGuard(regAttrPtr, cattrinbufFileSize, attrbuf); - acc_ptr= (Uint32*)®AttrPtr.p->attrbuf[attr_buf_index]; - } -} - Uint32 Dblqh::get_acc_ptr_from_scan_record(ScanRecord* scanP, Uint32 index, @@ -7611,18 +7705,25 @@ void Dblqh::abort_scan(Signal* signal, Uint32 scan_ptr_i, Uint32 errcode){ jam(); scanptr.i = scan_ptr_i; c_scanRecordPool.getPtr(scanptr); + + fragptr.i = tcConnectptr.p->fragmentptr; + ptrCheckGuard(fragptr, cfragrecFileSize, fragrecord); finishScanrec(signal); releaseScanrec(signal); tcConnectptr.p->transactionState = TcConnectionrec::IDLE; tcConnectptr.p->abortState = TcConnectionrec::ABORT_ACTIVE; - - ScanFragRef * ref = (ScanFragRef*)&signal->theData[0]; - ref->senderData = tcConnectptr.p->clientConnectrec; - ref->transId1 = tcConnectptr.p->transid[0]; - ref->transId2 = tcConnectptr.p->transid[1]; - ref->errorCode = errcode; - sendSignal(tcConnectptr.p->clientBlockref, GSN_SCAN_FRAGREF, signal, - ScanFragRef::SignalLength, JBB); + + if(errcode) + { + jam(); + ScanFragRef * ref = (ScanFragRef*)&signal->theData[0]; + ref->senderData = tcConnectptr.p->clientConnectrec; + ref->transId1 = tcConnectptr.p->transid[0]; + ref->transId2 = tcConnectptr.p->transid[1]; + ref->errorCode = errcode; + sendSignal(tcConnectptr.p->clientBlockref, GSN_SCAN_FRAGREF, signal, + ScanFragRef::SignalLength, JBB); + } deleteTransidHash(signal); releaseOprec(signal); releaseTcrec(signal, tcConnectptr); @@ -7904,6 +8005,13 @@ void Dblqh::nextScanConfScanLab(Signal* signal) /************************************************************* * STOP THE SCAN PROCESS IF THIS HAS BEEN REQUESTED. ************************************************************ */ + if (!scanptr.p->scanLockHold) + { + jam(); + closeScanLab(signal); + return; + } + if (scanptr.p->scanCompletedStatus == ZTRUE) { if ((scanptr.p->scanLockHold == ZTRUE) && (scanptr.p->m_curr_batch_size_rows > 0)) { @@ -8404,8 +8512,6 @@ void Dblqh::tupScanCloseConfLab(Signal* signal) ScanFragRef::SignalLength, JBB); } else { jam(); - scanptr.p->m_curr_batch_size_rows = 0; - scanptr.p->m_curr_batch_size_bytes= 0; sendScanFragConf(signal, ZSCAN_FRAG_CLOSED); }//if finishScanrec(signal); @@ -8477,7 +8583,7 @@ Uint32 Dblqh::initScanrec(const ScanFragReq* scanFragReq) tFragPtr.i = fragptr.p->tableFragptr; ptrCheckGuard(tFragPtr, cfragrecFileSize, fragrecord); scanptr.p->fragPtrI = fragptr.p->tableFragptr; - + /** * !idx uses 1 - (MAX_PARALLEL_SCANS_PER_FRAG - 1) = 1-11 * idx uses from MAX_PARALLEL_SCANS_PER_FRAG - MAX = 12-42) @@ -8486,10 +8592,10 @@ Uint32 Dblqh::initScanrec(const ScanFragReq* scanFragReq) Uint32 stop = (idx ? MAX_PARALLEL_INDEX_SCANS_PER_FRAG : MAX_PARALLEL_SCANS_PER_FRAG - 1); stop += start; Uint32 free = tFragPtr.p->m_scanNumberMask.find(start); - + if(free == Fragrecord::ScanNumberMask::NotFound || free >= stop){ jam(); - + if(scanPrio == 0){ jam(); return ScanFragRef::ZTOO_MANY_ACTIVE_SCAN_ERROR; @@ -8500,16 +8606,15 @@ Uint32 Dblqh::initScanrec(const ScanFragReq* scanFragReq) */ scanptr.p->scanState = ScanRecord::IN_QUEUE; LocalDLFifoList<ScanRecord> queue(c_scanRecordPool, - tFragPtr.p->m_queuedScans); + fragptr.p->m_queuedScans); queue.add(scanptr); return ZOK; } - scanptr.p->scanNumber = free; tFragPtr.p->m_scanNumberMask.clear(free);// Update mask - - LocalDLList<ScanRecord> active(c_scanRecordPool, tFragPtr.p->m_activeScans); + + LocalDLList<ScanRecord> active(c_scanRecordPool, fragptr.p->m_activeScans); active.add(scanptr); if(scanptr.p->scanKeyinfoFlag){ jam(); @@ -8569,12 +8674,8 @@ void Dblqh::finishScanrec(Signal* signal) { release_acc_ptr_list(scanptr.p); - FragrecordPtr tFragPtr; - tFragPtr.i = scanptr.p->fragPtrI; - ptrCheckGuard(tFragPtr, cfragrecFileSize, fragrecord); - LocalDLFifoList<ScanRecord> queue(c_scanRecordPool, - tFragPtr.p->m_queuedScans); + fragptr.p->m_queuedScans); if(scanptr.p->scanState == ScanRecord::IN_QUEUE){ jam(); @@ -8592,9 +8693,13 @@ void Dblqh::finishScanrec(Signal* signal) ndbrequire(tmp.p == scanptr.p); } - LocalDLList<ScanRecord> scans(c_scanRecordPool, tFragPtr.p->m_activeScans); + LocalDLList<ScanRecord> scans(c_scanRecordPool, fragptr.p->m_activeScans); scans.release(scanptr); + FragrecordPtr tFragPtr; + tFragPtr.i = scanptr.p->fragPtrI; + ptrCheckGuard(tFragPtr, cfragrecFileSize, fragrecord); + const Uint32 scanNumber = scanptr.p->scanNumber; ndbrequire(!tFragPtr.p->m_scanNumberMask.get(scanNumber)); ScanRecordPtr restart; @@ -8614,14 +8719,15 @@ void Dblqh::finishScanrec(Signal* signal) return; } + ndbrequire(restart.p->scanState == ScanRecord::IN_QUEUE); + ScanRecordPtr tmpScan = scanptr; TcConnectionrecPtr tmpTc = tcConnectptr; tcConnectptr.i = restart.p->scanTcrec; ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec); restart.p->scanNumber = scanNumber; - restart.p->scanState = ScanRecord::WAIT_ACC_SCAN; - + queue.remove(restart); scans.add(restart); if(restart.p->scanKeyinfoFlag){ @@ -8635,10 +8741,18 @@ void Dblqh::finishScanrec(Signal* signal) ndbout_c("adding-r (%d %d)", restart.p->scanNumber, restart.p->fragPtrI); #endif } - - scanptr = restart; - continueAfterReceivingAllAiLab(signal); - + + restart.p->scanState = ScanRecord::SCAN_FREE; // set in initScanRec + if(tcConnectptr.p->transactionState == TcConnectionrec::SCAN_STATE_USED) + { + jam(); + scanptr = restart; + continueAfterReceivingAllAiLab(signal); + } + else + { + ndbrequire(tcConnectptr.p->transactionState == TcConnectionrec::WAIT_SCAN_AI); + } scanptr = tmpScan; tcConnectptr = tmpTc; }//Dblqh::finishScanrec() @@ -8725,7 +8839,7 @@ void Dblqh::sendKeyinfo20(Signal* signal, sendSignal(ref, GSN_KEYINFO20, signal, 25, JBB); src += KeyInfo20::DataLength;; keyLen -= KeyInfo20::DataLength; - } while(keyLen >= KeyInfo20::DataLength); + } MEMCOPY_NO_WORDS(keyInfo->keyData, src, keyLen); sendSignal(ref, GSN_KEYINFO20, signal, @@ -8809,6 +8923,13 @@ void Dblqh::sendScanFragConf(Signal* signal, Uint32 scanCompleted) conf->total_len= total_len; sendSignal(tcConnectptr.p->clientBlockref, GSN_SCAN_FRAGCONF, signal, ScanFragConf::SignalLength, JBB); + + if(!scanptr.p->scanLockHold) + { + jam(); + scanptr.p->m_curr_batch_size_rows = 0; + scanptr.p->m_curr_batch_size_bytes= 0; + } }//Dblqh::sendScanFragConf() /* ######################################################################### */ diff --git a/ndb/src/kernel/blocks/dblqh/Makefile.am b/ndb/src/kernel/blocks/dblqh/Makefile.am index 3a58dba742e..854860b269c 100644 --- a/ndb/src/kernel/blocks/dblqh/Makefile.am +++ b/ndb/src/kernel/blocks/dblqh/Makefile.am @@ -9,3 +9,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libdblqh.dsp + +libdblqh.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libdblqh_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/dblqh/Makefile_old b/ndb/src/kernel/blocks/dblqh/Makefile_old deleted file mode 100644 index 520486d8058..00000000000 --- a/ndb/src/kernel/blocks/dblqh/Makefile_old +++ /dev/null @@ -1,12 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := dblqh -DIRS := redoLogReader - -SOURCES = \ - DblqhInit.cpp \ - DblqhMain.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp index a209df24c44..fb90ccc8c90 100644 --- a/ndb/src/kernel/blocks/dbtc/Dbtc.hpp +++ b/ndb/src/kernel/blocks/dbtc/Dbtc.hpp @@ -1054,9 +1054,8 @@ public: // Id of the ScanRecord this fragment scan belongs to Uint32 scanRec; - // The maximum number of operations that can be scanned before - // returning to TC - Uint16 scanFragConcurrency; + // The value of fragmentCompleted in the last received SCAN_FRAGCONF + Uint8 m_scan_frag_conf_status; inline void startFragTimer(Uint32 timeVal){ scanFragTimer = timeVal; @@ -1193,8 +1192,10 @@ public: // Number of operation records per scanned fragment // Number of operations in first batch // Max number of bytes per batch - Uint16 noOprecPerFrag; - Uint16 first_batch_size; + union { + Uint16 first_batch_size_rows; + Uint16 batch_size_rows; + }; Uint32 batch_byte_size; Uint32 scanRequestInfo; // ScanFrag format diff --git a/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp b/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp index e38089242c3..59c8237f20a 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp @@ -20,7 +20,6 @@ #include <ndb_limits.h> #include <Properties.hpp> #include <Configuration.hpp> -#include <new> #define DEBUG(x) { ndbout << "TC::" << x << endl; } @@ -365,5 +364,5 @@ Dbtc::~Dbtc() capiConnectFilesize); }//Dbtc::~Dbtc() -BLOCK_FUNCTIONS(Dbtc); +BLOCK_FUNCTIONS(Dbtc) diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index d8b3ee10532..97931041e2a 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -1271,7 +1271,10 @@ void Dbtc::execTCRELEASEREQ(Signal* signal) if (tapiBlockref == apiConnectptr.p->ndbapiBlockref) { if (apiConnectptr.p->apiConnectstate == CS_CONNECTED || (apiConnectptr.p->apiConnectstate == CS_ABORTING && - apiConnectptr.p->abortState == AS_IDLE)){ + apiConnectptr.p->abortState == AS_IDLE) || + (apiConnectptr.p->apiConnectstate == CS_STARTED && + apiConnectptr.p->firstTcConnect == RNIL)) + { jam(); /* JUST REPLY OK */ releaseApiCon(signal, apiConnectptr.i); signal->theData[0] = tuserpointer; @@ -1879,7 +1882,6 @@ void Dbtc::packKeyData000Lab(Signal* signal, Uint32 totalLen) { CacheRecord * const regCachePtr = cachePtr.p; - UintR Tmp; jam(); Uint32 len = 0; @@ -6366,7 +6368,7 @@ void Dbtc::sendAbortedAfterTimeout(Signal* signal, int Tcheck) *------------------------------------------------------------------*/ char buf[96]; buf[0] = 0; char buf2[96]; - snprintf(buf, sizeof(buf), "TC %d: %d ops:", + BaseString::snprintf(buf, sizeof(buf), "TC %d: %d ops:", __LINE__, apiConnectptr.i); for(Uint32 i = 0; i<TloopCount; i++){ BaseString::snprintf(buf2, sizeof(buf2), "%s %d", buf, tmp[i]); @@ -8503,14 +8505,16 @@ void Dbtc::execSCAN_TABREQ(Signal* signal) apiConnectptr.i = scanTabReq->apiConnectPtr; tabptr.i = scanTabReq->tableId; - if (apiConnectptr.i >= capiConnectFilesize || - tabptr.i >= ctabrecFilesize) { + if (apiConnectptr.i >= capiConnectFilesize) + { jam(); warningHandlerLab(signal); return; }//if + ptrAss(apiConnectptr, apiConnectRecord); ApiConnectRecord * transP = apiConnectptr.p; + if (transP->apiConnectstate != CS_CONNECTED) { jam(); // could be left over from TCKEYREQ rollback @@ -8524,9 +8528,16 @@ void Dbtc::execSCAN_TABREQ(Signal* signal) } else { jam(); errCode = ZSTATE_ERROR; - goto SCAN_TAB_error; + goto SCAN_TAB_error_no_state_change; } } + + if(tabptr.i >= ctabrecFilesize) + { + errCode = ZUNKNOWN_TABLE_ERROR; + goto SCAN_TAB_error; + } + ptrAss(tabptr, tableRecord); if ((aiLength == 0) || (!tabptr.p->checkTable(schemaVersion)) || @@ -8621,8 +8632,18 @@ void Dbtc::execSCAN_TABREQ(Signal* signal) errCode = ZNO_SCANREC_ERROR; goto SCAN_TAB_error; - SCAN_TAB_error: +SCAN_TAB_error: jam(); + /** + * Prepare for up coming ATTRINFO/KEYINFO + */ + transP->apiConnectstate = CS_ABORTING; + transP->abortState = AS_IDLE; + transP->transid[0] = transid1; + transP->transid[1] = transid2; + +SCAN_TAB_error_no_state_change: + ScanTabRef * ref = (ScanTabRef*)&signal->theData[0]; ref->apiConnectPtr = transP->ndbapiConnect; ref->transId1 = transid1; @@ -8646,9 +8667,9 @@ void Dbtc::initScanrec(ScanRecordPtr scanptr, scanptr.p->scanTableref = tabptr.i; scanptr.p->scanSchemaVersion = scanTabReq->tableSchemaVersion; scanptr.p->scanParallel = scanParallel; - scanptr.p->noOprecPerFrag = noOprecPerFrag; - scanptr.p->first_batch_size= scanTabReq->first_batch_size; - scanptr.p->batch_byte_size= scanTabReq->batch_byte_size; + scanptr.p->first_batch_size_rows = scanTabReq->first_batch_size; + scanptr.p->batch_byte_size = scanTabReq->batch_byte_size; + scanptr.p->batch_size_rows = noOprecPerFrag; Uint32 tmp = 0; const UintR ri = scanTabReq->requestInfo; @@ -8672,7 +8693,6 @@ void Dbtc::initScanrec(ScanRecordPtr scanptr, ndbrequire(list.seize(ptr)); ptr.p->scanRec = scanptr.i; ptr.p->scanFragId = 0; - ptr.p->scanFragConcurrency = noOprecPerFrag; ptr.p->m_apiPtr = cdata[i]; }//for @@ -8945,6 +8965,25 @@ void Dbtc::execDIGETPRIMCONF(Signal* signal) scanptr.i = scanFragptr.p->scanRec; ptrCheckGuard(scanptr, cscanrecFileSize, scanRecord); + /** + * This must be false as select count(*) otherwise + * can "pass" committing on backup fragments and + * get incorrect row count + */ + if(false && ScanFragReq::getReadCommittedFlag(scanptr.p->scanRequestInfo)) + { + jam(); + Uint32 max = 3+signal->theData[6]; + Uint32 nodeid = getOwnNodeId(); + for(Uint32 i = 3; i<max; i++) + if(signal->theData[i] == nodeid) + { + jam(); + tnodeid = nodeid; + break; + } + } + { /** * Check table @@ -8989,6 +9028,8 @@ void Dbtc::execDIGETPRIMCONF(Signal* signal) scanFragptr.p->lqhBlockref = ref; scanFragptr.p->m_connectCount = getNodeInfo(tnodeid).m_connectCount; sendScanFragReq(signal, scanptr.p, scanFragptr.p); + if(ERROR_INSERTED(8035)) + globalTransporterRegistry.performSend(); attrbufptr.i = cachePtr.p->firstAttrbuf; while (attrbufptr.i != RNIL) { jam(); @@ -8998,6 +9039,8 @@ void Dbtc::execDIGETPRIMCONF(Signal* signal) attrbufptr.p, ref); attrbufptr.i = attrbufptr.p->attrbuf[ZINBUF_NEXT]; + if(ERROR_INSERTED(8035)) + globalTransporterRegistry.performSend(); }//while scanFragptr.p->scanFragState = ScanFragRec::LQH_ACTIVE; scanFragptr.p->startFragTimer(ctcTimer); @@ -9141,6 +9184,7 @@ void Dbtc::execSCAN_FRAGCONF(Signal* signal) const ScanFragConf * const conf = (ScanFragConf*)&signal->theData[0]; const Uint32 noCompletedOps = conf->completedOps; + const Uint32 status = conf->fragmentCompleted; scanFragptr.i = conf->senderData; c_scan_frag_pool.getPtr(scanFragptr); @@ -9163,11 +9207,9 @@ void Dbtc::execSCAN_FRAGCONF(Signal* signal) ndbrequire(scanFragptr.p->scanFragState == ScanFragRec::LQH_ACTIVE); - const Uint32 status = conf->fragmentCompleted; - if(scanptr.p->scanState == ScanRecord::CLOSING_SCAN){ jam(); - if(status == ZFALSE){ + if(status == 0){ /** * We have started closing = we sent a close -> ignore this */ @@ -9184,11 +9226,11 @@ void Dbtc::execSCAN_FRAGCONF(Signal* signal) return; } - if(status == ZCLOSED && scanptr.p->scanNextFragId < scanptr.p->scanNoFrag){ + if(noCompletedOps == 0 && status != 0 && + scanptr.p->scanNextFragId < scanptr.p->scanNoFrag){ /** * Start on next fragment */ - ndbrequire(noCompletedOps == 0); scanFragptr.p->scanFragState = ScanFragRec::WAIT_GET_PRIMCONF; scanFragptr.p->startFragTimer(ctcTimer); @@ -9218,6 +9260,7 @@ void Dbtc::execSCAN_FRAGCONF(Signal* signal) scanptr.p->m_queued_count++; } + scanFragptr.p->m_scan_frag_conf_status = status; scanFragptr.p->m_ops = noCompletedOps; scanFragptr.p->m_totalLen = total_len; scanFragptr.p->scanFragState = ScanFragRec::QUEUED_FOR_DELIVERY; @@ -9311,7 +9354,6 @@ void Dbtc::execSCAN_NEXTREQ(Signal* signal) /********************************************************************* * APPLICATION IS CLOSING THE SCAN. **********************************************************************/ - ndbrequire(len == 0); close_scan_req(signal, scanptr, true); return; }//if @@ -9330,11 +9372,12 @@ void Dbtc::execSCAN_NEXTREQ(Signal* signal) // Copy op ptrs so I dont overwrite them when sending... memcpy(signal->getDataPtrSend()+25, signal->getDataPtr()+4, 4 * len); - ScanFragNextReq * nextReq = (ScanFragNextReq*)&signal->theData[0]; - nextReq->closeFlag = ZFALSE; - nextReq->transId1 = apiConnectptr.p->transid[0]; - nextReq->transId2 = apiConnectptr.p->transid[1]; - nextReq->batch_size_bytes= scanP->batch_byte_size; + ScanFragNextReq tmp; + tmp.closeFlag = ZFALSE; + tmp.transId1 = apiConnectptr.p->transid[0]; + tmp.transId2 = apiConnectptr.p->transid[1]; + tmp.batch_size_rows = scanP->batch_size_rows; + tmp.batch_size_bytes = scanP->batch_byte_size; ScanFragList running(c_scan_frag_pool, scanP->m_running_scan_frags); ScanFragList delivered(c_scan_frag_pool, scanP->m_delivered_scan_frags); @@ -9344,15 +9387,37 @@ void Dbtc::execSCAN_NEXTREQ(Signal* signal) c_scan_frag_pool.getPtr(scanFragptr); ndbrequire(scanFragptr.p->scanFragState == ScanFragRec::DELIVERED); - scanFragptr.p->scanFragState = ScanFragRec::LQH_ACTIVE; scanFragptr.p->startFragTimer(ctcTimer); - scanFragptr.p->m_ops = 0; - nextReq->senderData = scanFragptr.i; - nextReq->batch_size_rows= scanFragptr.p->scanFragConcurrency; - sendSignal(scanFragptr.p->lqhBlockref, GSN_SCAN_NEXTREQ, signal, - ScanFragNextReq::SignalLength, JBB); + if(scanFragptr.p->m_scan_frag_conf_status) + { + /** + * last scan was complete + */ + jam(); + ndbrequire(scanptr.p->scanNextFragId < scanptr.p->scanNoFrag); + scanFragptr.p->scanFragState = ScanFragRec::WAIT_GET_PRIMCONF; + + tcConnectptr.i = scanptr.p->scanTcrec; + ptrCheckGuard(tcConnectptr, ctcConnectFilesize, tcConnectRecord); + scanFragptr.p->scanFragId = scanptr.p->scanNextFragId++; + signal->theData[0] = tcConnectptr.p->dihConnectptr; + signal->theData[1] = scanFragptr.i; + signal->theData[2] = scanptr.p->scanTableref; + signal->theData[3] = scanFragptr.p->scanFragId; + sendSignal(cdihblockref, GSN_DIGETPRIMREQ, signal, 4, JBB); + } + else + { + jam(); + scanFragptr.p->scanFragState = ScanFragRec::LQH_ACTIVE; + ScanFragNextReq * req = (ScanFragNextReq*)signal->getDataPtrSend(); + * req = tmp; + req->senderData = scanFragptr.i; + sendSignal(scanFragptr.p->lqhBlockref, GSN_SCAN_NEXTREQ, signal, + ScanFragNextReq::SignalLength, JBB); + } delivered.remove(scanFragptr); running.add(scanFragptr); }//for @@ -9416,7 +9481,7 @@ Dbtc::close_scan_req(Signal* signal, ScanRecordPtr scanPtr, bool req_received){ ndbrequire(curr.p->scanFragState == ScanFragRec::DELIVERED); delivered.remove(curr); - if(curr.p->m_ops > 0){ + if(curr.p->m_ops > 0 && curr.p->m_scan_frag_conf_status == 0){ jam(); running.add(curr); curr.p->scanFragState = ScanFragRec::LQH_ACTIVE; @@ -9551,7 +9616,7 @@ void Dbtc::sendScanFragReq(Signal* signal, req->transId1 = apiConnectptr.p->transid[0]; req->transId2 = apiConnectptr.p->transid[1]; req->clientOpPtr = scanFragP->m_apiPtr; - req->batch_size_rows= scanFragP->scanFragConcurrency; + req->batch_size_rows= scanP->batch_size_rows; req->batch_size_bytes= scanP->batch_byte_size; sendSignal(scanFragP->lqhBlockref, GSN_SCAN_FRAGREQ, signal, ScanFragReq::SignalLength, JBB); @@ -9573,6 +9638,8 @@ void Dbtc::sendScanTabConf(Signal* signal, ScanRecordPtr scanPtr) { jam(); ops += 21; } + + Uint32 left = scanPtr.p->scanNoFrag - scanPtr.p->scanNextFragId; ScanTabConf * conf = (ScanTabConf*)&signal->theData[0]; conf->apiConnectPtr = apiConnectptr.p->ndbapiConnect; @@ -9588,24 +9655,25 @@ void Dbtc::sendScanTabConf(Signal* signal, ScanRecordPtr scanPtr) { ScanFragRecPtr curr = ptr; // Remove while iterating... queued.next(ptr); + bool done = curr.p->m_scan_frag_conf_status && --left; + * ops++ = curr.p->m_apiPtr; - * ops++ = curr.i; + * ops++ = done ? RNIL : curr.i; * ops++ = (curr.p->m_totalLen << 10) + curr.p->m_ops; queued.remove(curr); - if(curr.p->m_ops > 0){ + if(!done){ delivered.add(curr); curr.p->scanFragState = ScanFragRec::DELIVERED; curr.p->stopFragTimer(); } else { - (* --ops) = ScanTabConf::EndOfData; ops++; c_scan_frag_pool.release(curr); curr.p->scanFragState = ScanFragRec::COMPLETED; curr.p->stopFragTimer(); } } } - + if(scanPtr.p->m_delivered_scan_frags.isEmpty() && scanPtr.p->m_running_scan_frags.isEmpty()){ conf->requestInfo = op_count | ScanTabConf::EndOfData; @@ -10424,9 +10492,8 @@ Dbtc::execDUMP_STATE_ORD(Signal* signal) sfp.i, sfp.p->scanFragState, sfp.p->scanFragId); - infoEvent(" nodeid=%d, concurr=%d, timer=%d", + infoEvent(" nodeid=%d, timer=%d", refToNode(sfp.p->lqhBlockref), - sfp.p->scanFragConcurrency, sfp.p->scanFragTimer); } @@ -10504,7 +10571,7 @@ Dbtc::execDUMP_STATE_ORD(Signal* signal) sp.p->scanAiLength, sp.p->scanParallel, sp.p->scanReceivedOperations, - sp.p->noOprecPerFrag); + sp.p->batch_size_rows); infoEvent(" schv=%d, tab=%d, sproc=%d", sp.p->scanSchemaVersion, sp.p->scanTableref, diff --git a/ndb/src/kernel/blocks/dbtc/Makefile.am b/ndb/src/kernel/blocks/dbtc/Makefile.am index 4aa514c0aba..98ee2639bac 100644 --- a/ndb/src/kernel/blocks/dbtc/Makefile.am +++ b/ndb/src/kernel/blocks/dbtc/Makefile.am @@ -7,3 +7,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libdbtc.dsp + +libdbtc.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libdbtc_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/dbtc/Makefile_old b/ndb/src/kernel/blocks/dbtc/Makefile_old deleted file mode 100644 index ae876ab1f84..00000000000 --- a/ndb/src/kernel/blocks/dbtc/Makefile_old +++ /dev/null @@ -1,11 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := dbtc -SOURCES = \ - DbtcInit.cpp \ - DbtcMain.cpp - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/src/kernel/blocks/dbtup/Dbtup.hpp b/ndb/src/kernel/blocks/dbtup/Dbtup.hpp index 55ad1d0910a..b48546576f9 100644 --- a/ndb/src/kernel/blocks/dbtup/Dbtup.hpp +++ b/ndb/src/kernel/blocks/dbtup/Dbtup.hpp @@ -504,6 +504,7 @@ struct Fragoperrec { Uint32 noOfNewAttrCount; Uint32 charsetIndex; BlockReference lqhBlockrefFrag; + bool inUse; }; typedef Ptr<Fragoperrec> FragoperrecPtr; @@ -1936,6 +1937,7 @@ private: void setUpKeyArray(Tablerec* const regTabPtr); bool addfragtotab(Tablerec* const regTabPtr, Uint32 fragId, Uint32 fragIndex); void deleteFragTab(Tablerec* const regTabPtr, Uint32 fragId); + void abortAddFragOp(Signal* signal); void releaseTabDescr(Tablerec* const regTabPtr); void getFragmentrec(FragrecordPtr& regFragPtr, Uint32 fragId, Tablerec* const regTabPtr); diff --git a/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp b/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp index 49de0d80bcd..8e3ca6528c2 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp @@ -1113,6 +1113,7 @@ Dbtup::updateStartLab(Signal* signal, regOperPtr->attrinbufLen); if (retValue == -1) { tupkeyErrorLab(signal); + return -1; }//if } else { jam(); diff --git a/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp b/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp index d33adcd08e1..0d7430e662d 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp @@ -31,7 +31,6 @@ #include <signaldata/TupKey.hpp> #include <signaldata/DropTab.hpp> -#include <new> #define DEBUG(x) { ndbout << "TUP::" << x << endl; } @@ -215,7 +214,7 @@ Dbtup::~Dbtup() }//Dbtup::~Dbtup() -BLOCK_FUNCTIONS(Dbtup); +BLOCK_FUNCTIONS(Dbtup) /* **************************************************************** */ /* ---------------------------------------------------------------- */ @@ -632,14 +631,11 @@ void Dbtup::execREAD_CONFIG_REQ(Signal* signal) ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_FRAG, &cnoOfFragrec)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_OP_RECS, &cnoOfOprec)); - - // MemorySpaceTuples is specified in 8k pages, divide by 4 for 32k pages - Uint32 tmp; - ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_PAGE, &tmp)); - Uint64 pages = (tmp * 2048 + (ZWORDS_ON_PAGE - 1))/ (Uint64)ZWORDS_ON_PAGE; - cnoOfPage = (Uint32)pages; + + ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_PAGE, &cnoOfPage)); Uint32 noOfTriggers= 0; + Uint32 tmp= 0; ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_PAGE_RANGE, &tmp)); initPageRangeSize(tmp); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUP_TABLE, &cnoOfTablerec)); diff --git a/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp b/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp index efea312b865..405f790954e 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp @@ -39,11 +39,18 @@ /* ---------------------------------------------------------------- */ void Dbtup::execTUPFRAGREQ(Signal* signal) { + ljamEntry(); + + if (signal->theData[0] == (Uint32)-1) { + ljam(); + abortAddFragOp(signal); + return; + } + FragoperrecPtr fragOperPtr; FragrecordPtr regFragPtr; TablerecPtr regTabPtr; - ljamEntry(); Uint32 userptr = signal->theData[0]; Uint32 userblockref = signal->theData[1]; Uint32 reqinfo = signal->theData[2]; @@ -62,6 +69,17 @@ void Dbtup::execTUPFRAGREQ(Signal* signal) Uint32 noOfAttributeGroups = signal->theData[12]; Uint32 globalCheckpointIdIndicator = signal->theData[13]; +#ifndef VM_TRACE + // config mismatch - do not crash if release compiled + if (regTabPtr.i >= cnoOfTablerec) { + ljam(); + signal->theData[0] = userptr; + signal->theData[1] = 800; + sendSignal(userblockref, GSN_TUPFRAGREF, signal, 2, JBB); + return; + } +#endif + ptrCheckGuard(regTabPtr, cnoOfTablerec, tablerec); if (cfirstfreeFragopr == RNIL) { ljam(); @@ -132,6 +150,15 @@ void Dbtup::execTUPFRAGREQ(Signal* signal) return; }//if + if (ERROR_INSERTED(4007) && regTabPtr.p->fragid[0] == fragId || + ERROR_INSERTED(4008) && regTabPtr.p->fragid[1] == fragId) { + ljam(); + terrorCode = 1; + fragrefuse4Lab(signal, fragOperPtr, regFragPtr, regTabPtr.p, fragId); + CLEAR_ERROR_INSERT_VALUE; + return; + } + if (regTabPtr.p->tableStatus == NOT_DEFINED) { ljam(); //------------------------------------------------------------------------------------- @@ -243,6 +270,7 @@ void Dbtup::seizeFragoperrec(FragoperrecPtr& fragOperPtr) ptrCheckGuard(fragOperPtr, cnoOfFragoprec, fragoperrec); cfirstfreeFragopr = fragOperPtr.p->nextFragoprec; fragOperPtr.p->nextFragoprec = RNIL; + fragOperPtr.p->inUse = true; }//Dbtup::seizeFragoperrec() /* **************************************************************** */ @@ -273,6 +301,7 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal) ndbrequire(fragOperPtr.p->attributeCount > 0); fragOperPtr.p->attributeCount--; + const bool lastAttr = (fragOperPtr.p->attributeCount == 0); if ((regTabPtr.p->tableStatus == DEFINING) && (fragOperPtr.p->definingFragment)) { @@ -346,20 +375,30 @@ void Dbtup::execTUP_ADD_ATTRREQ(Signal* signal) addattrrefuseLab(signal, regFragPtr, fragOperPtr, regTabPtr.p, fragId); return; }//if - if ((fragOperPtr.p->attributeCount == 0) && - (fragOperPtr.p->freeNullBit != 0)) { + if (lastAttr && (fragOperPtr.p->freeNullBit != 0)) { ljam(); terrorCode = ZINCONSISTENT_NULL_ATTRIBUTE_COUNT; addattrrefuseLab(signal, regFragPtr, fragOperPtr, regTabPtr.p, fragId); return; }//if }//if + if (ERROR_INSERTED(4009) && regTabPtr.p->fragid[0] == fragId && attrId == 0 || + ERROR_INSERTED(4010) && regTabPtr.p->fragid[0] == fragId && lastAttr || + ERROR_INSERTED(4011) && regTabPtr.p->fragid[1] == fragId && attrId == 0 || + ERROR_INSERTED(4012) && regTabPtr.p->fragid[1] == fragId && lastAttr) { + ljam(); + terrorCode = 1; + addattrrefuseLab(signal, regFragPtr, fragOperPtr, regTabPtr.p, fragId); + CLEAR_ERROR_INSERT_VALUE; + return; + } /* **************************************************************** */ /* ************** TUP_ADD_ATTCONF ****************** */ /* **************************************************************** */ signal->theData[0] = fragOperPtr.p->lqhPtrFrag; - sendSignal(fragOperPtr.p->lqhBlockrefFrag, GSN_TUP_ADD_ATTCONF, signal, 1, JBB); - if (fragOperPtr.p->attributeCount > 0) { + signal->theData[1] = lastAttr; + sendSignal(fragOperPtr.p->lqhBlockrefFrag, GSN_TUP_ADD_ATTCONF, signal, 2, JBB); + if (! lastAttr) { ljam(); return; /* EXIT AND WAIT FOR MORE */ }//if @@ -491,11 +530,11 @@ void Dbtup::fragrefuseLab(Signal* signal, FragoperrecPtr fragOperPtr) void Dbtup::releaseFragoperrec(FragoperrecPtr fragOperPtr) { + fragOperPtr.p->inUse = false; fragOperPtr.p->nextFragoprec = cfirstfreeFragopr; cfirstfreeFragopr = fragOperPtr.i; }//Dbtup::releaseFragoperrec() - void Dbtup::deleteFragTab(Tablerec* const regTabPtr, Uint32 fragId) { for (Uint32 i = 0; i < (2 * MAX_FRAG_PER_NODE); i++) { @@ -510,6 +549,20 @@ void Dbtup::deleteFragTab(Tablerec* const regTabPtr, Uint32 fragId) ndbrequire(false); }//Dbtup::deleteFragTab() +/* + * LQH aborts on-going create table operation. The table is later + * dropped by DICT. + */ +void Dbtup::abortAddFragOp(Signal* signal) +{ + FragoperrecPtr fragOperPtr; + + fragOperPtr.i = signal->theData[1]; + ptrCheckGuard(fragOperPtr, cnoOfFragoprec, fragoperrec); + ndbrequire(fragOperPtr.p->inUse); + releaseFragoperrec(fragOperPtr); +} + void Dbtup::execDROP_TAB_REQ(Signal* signal) { diff --git a/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp index e6cc6f68842..cbb165c3eb1 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp @@ -706,7 +706,10 @@ Dbtup::checkUpdateOfPrimaryKey(Uint32* updateBuffer, Tablerec* const regTabPtr) tOutBufIndex = 0; tMaxRead = MAX_KEY_SIZE_IN_WORDS; + bool tmp = tXfrmFlag; + tXfrmFlag = false; ndbrequire((this->*f)(&keyReadBuffer[0], ahOut, attrDescriptor, attributeOffset)); + tXfrmFlag = tmp; ndbrequire(tOutBufIndex == ahOut->getDataSize()); if (ahIn.getDataSize() != ahOut->getDataSize()) { ljam(); diff --git a/ndb/src/kernel/blocks/dbtup/Makefile.am b/ndb/src/kernel/blocks/dbtup/Makefile.am index 7e94a01d43b..e51410e6be3 100644 --- a/ndb/src/kernel/blocks/dbtup/Makefile.am +++ b/ndb/src/kernel/blocks/dbtup/Makefile.am @@ -25,3 +25,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libdbtup.dsp + +libdbtup.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libdbtup_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/dbtup/Makefile_old b/ndb/src/kernel/blocks/dbtup/Makefile_old deleted file mode 100644 index 87146f4b441..00000000000 --- a/ndb/src/kernel/blocks/dbtup/Makefile_old +++ /dev/null @@ -1,26 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := dbtup -SOURCES = \ - DbtupExecQuery.cpp \ - DbtupBuffer.cpp \ - DbtupRoutines.cpp \ - DbtupCommit.cpp \ - DbtupFixAlloc.cpp \ - DbtupTrigger.cpp \ - DbtupAbort.cpp \ - DbtupLCP.cpp \ - DbtupUndoLog.cpp \ - DbtupPageMap.cpp \ - DbtupPagMan.cpp \ - DbtupStoredProcDef.cpp \ - DbtupMeta.cpp \ - DbtupTabDesMan.cpp \ - DbtupGen.cpp \ - DbtupSystemRestart.cpp \ - DbtupIndex.cpp \ - DbtupDebug.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp index 8896324f793..2c96271eb5d 100644 --- a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp +++ b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp @@ -17,7 +17,6 @@ #ifndef DBTUX_H #define DBTUX_H -#include <new> #include <ndb_limits.h> #include <SimulatedBlock.hpp> #include <AttributeDescriptor.hpp> @@ -575,6 +574,7 @@ private: void execDROP_TAB_REQ(Signal* signal); bool allocDescEnt(IndexPtr indexPtr); void freeDescEnt(IndexPtr indexPtr); + void abortAddFragOp(Signal* signal); void dropIndex(Signal* signal, IndexPtr indexPtr, Uint32 senderRef, Uint32 senderData); /* @@ -684,6 +684,7 @@ private: friend class NdbOut& operator<<(NdbOut&, const ScanOp&); friend class NdbOut& operator<<(NdbOut&, const Index&); friend class NdbOut& operator<<(NdbOut&, const Frag&); + friend class NdbOut& operator<<(NdbOut&, const FragOp&); friend class NdbOut& operator<<(NdbOut&, const NodeHandle&); FILE* debugFile; NdbOut debugOut; @@ -1064,7 +1065,7 @@ Dbtux::Index::Index() : m_fragId[i] = ZNIL; m_fragPtrI[i] = RNIL; }; -}; +} // Dbtux::Frag @@ -1101,7 +1102,7 @@ Dbtux::FragOp::FragOp() : m_fragNo(ZNIL), m_numAttrsRecvd(ZNIL) { -}; +} // Dbtux::NodeHandle diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp index c5c22264460..1e1b0d1d5b6 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp @@ -404,6 +404,19 @@ operator<<(NdbOut& out, const Dbtux::Frag& frag) } NdbOut& +operator<<(NdbOut& out, const Dbtux::FragOp& fragOp) +{ + out << "[FragOp " << hex << &fragOp; + out << " [userPtr " << dec << fragOp.m_userPtr << "]"; + out << " [indexId " << dec << fragOp.m_indexId << "]"; + out << " [fragId " << dec << fragOp.m_fragId << "]"; + out << " [fragNo " << dec << fragOp.m_fragNo << "]"; + out << " numAttrsRecvd " << dec << fragOp.m_numAttrsRecvd << "]"; + out << "]"; + return out; +} + +NdbOut& operator<<(NdbOut& out, const Dbtux::NodeHandle& node) { const Dbtux::Frag& frag = node.m_frag; diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp index ded02696a89..8990d6c86b6 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp @@ -24,13 +24,8 @@ Dbtux::Dbtux(const Configuration& conf) : #ifdef VM_TRACE debugFile(0), debugOut(*new NullOutputStream()), - // until ndb_mgm supports dump -#ifdef DBTUX_DEBUG_TREE - debugFlags(DebugTree), -#else debugFlags(0), #endif -#endif c_internalStartPhase(0), c_typeOfStart(NodeState::ST_ILLEGAL_TYPE), c_dataBuffer(0) @@ -86,7 +81,7 @@ Dbtux::execCONTINUEB(Signal* signal) jamEntry(); const Uint32* data = signal->getDataPtr(); switch (data[0]) { - case TuxContinueB::DropIndex: + case TuxContinueB::DropIndex: // currently unused { IndexPtr indexPtr; c_indexPool.getPtr(indexPtr, data[1]); @@ -174,7 +169,7 @@ Dbtux::execREAD_CONFIG_REQ(Signal* signal) ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_ATTRIBUTE, &nAttribute)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_SCAN_OP, &nScanOp)); - const Uint32 nDescPage = (nIndex + nAttribute + DescPageSize - 1) / DescPageSize; + const Uint32 nDescPage = (nIndex * DescHeadSize + nAttribute * DescAttrSize + DescPageSize - 1) / DescPageSize; const Uint32 nScanBoundWords = nScanOp * ScanBoundSegmentSize * 4; c_indexPool.setSize(nIndex); @@ -298,4 +293,4 @@ Dbtux::copyAttrs(const Frag& frag, ConstData data1, Data data2, unsigned maxlen2 #endif } -BLOCK_FUNCTIONS(Dbtux); +BLOCK_FUNCTIONS(Dbtux) diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp index 1577c5045e0..b7526593a08 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp @@ -29,6 +29,11 @@ void Dbtux::execTUXFRAGREQ(Signal* signal) { jamEntry(); + if (signal->theData[0] == (Uint32)-1) { + jam(); + abortAddFragOp(signal); + return; + } const TuxFragReq reqCopy = *(const TuxFragReq*)signal->getDataPtr(); const TuxFragReq* const req = &reqCopy; IndexPtr indexPtr; @@ -61,6 +66,11 @@ Dbtux::execTUXFRAGREQ(Signal* signal) fragOpPtr.p->m_fragId = req->fragId; fragOpPtr.p->m_fragNo = indexPtr.p->m_numFrags; fragOpPtr.p->m_numAttrsRecvd = 0; +#ifdef VM_TRACE + if (debugFlags & DebugMeta) { + debugOut << "Seize frag op " << fragOpPtr.i << " " << *fragOpPtr.p << endl; + } +#endif // check if index has place for more fragments ndbrequire(indexPtr.p->m_numFrags < MaxIndexFragments); // seize new fragment record @@ -129,6 +139,14 @@ Dbtux::execTUXFRAGREQ(Signal* signal) debugOut << "Add frag " << fragPtr.i << " " << *fragPtr.p << endl; } #endif + // error inserts + if (ERROR_INSERTED(12001) && fragOpPtr.p->m_fragNo == 0 || + ERROR_INSERTED(12002) && fragOpPtr.p->m_fragNo == 1) { + jam(); + errorCode = (TuxFragRef::ErrorCode)1; + CLEAR_ERROR_INSERT_VALUE; + break; + } // success TuxFragConf* const conf = (TuxFragConf*)signal->getDataPtrSend(); conf->userPtr = req->userPtr; @@ -145,10 +163,18 @@ Dbtux::execTUXFRAGREQ(Signal* signal) ref->errorCode = errorCode; sendSignal(req->userRef, GSN_TUXFRAGREF, signal, TuxFragRef::SignalLength, JBB); - if (fragOpPtr.i != RNIL) + if (fragOpPtr.i != RNIL) { +#ifdef VM_TRACE + if (debugFlags & DebugMeta) { + debugOut << "Release on frag error frag op " << fragOpPtr.i << " " << *fragOpPtr.p << endl; + } +#endif c_fragOpPool.release(fragOpPtr); - if (indexPtr.i != RNIL) - dropIndex(signal, indexPtr, 0, 0); + } + if (indexPtr.i != RNIL) { + jam(); + // let DICT drop the unfinished index + } } void @@ -203,7 +229,16 @@ Dbtux::execTUX_ADD_ATTRREQ(Signal* signal) } } #endif - if (indexPtr.p->m_numAttrs == fragOpPtr.p->m_numAttrsRecvd) { + const bool lastAttr = (indexPtr.p->m_numAttrs == fragOpPtr.p->m_numAttrsRecvd); + if (ERROR_INSERTED(12003) && fragOpPtr.p->m_fragNo == 0 && attrId == 0 || + ERROR_INSERTED(12004) && fragOpPtr.p->m_fragNo == 0 && lastAttr || + ERROR_INSERTED(12005) && fragOpPtr.p->m_fragNo == 1 && attrId == 0 || + ERROR_INSERTED(12006) && fragOpPtr.p->m_fragNo == 1 && lastAttr) { + errorCode = (TuxAddAttrRef::ErrorCode)1; + CLEAR_ERROR_INSERT_VALUE; + break; + } + if (lastAttr) { jam(); // initialize tree header TreeHead& tree = fragPtr.p->m_tree; @@ -246,11 +281,17 @@ Dbtux::execTUX_ADD_ATTRREQ(Signal* signal) } #endif // fragment is defined +#ifdef VM_TRACE + if (debugFlags & DebugMeta) { + debugOut << "Release frag op " << fragOpPtr.i << " " << *fragOpPtr.p << endl; + } +#endif c_fragOpPool.release(fragOpPtr); } // success TuxAddAttrConf* conf = (TuxAddAttrConf*)signal->getDataPtrSend(); conf->userPtr = fragOpPtr.p->m_userPtr; + conf->lastAttr = lastAttr; sendSignal(fragOpPtr.p->m_userRef, GSN_TUX_ADD_ATTRCONF, signal, TuxAddAttrConf::SignalLength, JBB); return; @@ -261,8 +302,32 @@ Dbtux::execTUX_ADD_ATTRREQ(Signal* signal) ref->errorCode = errorCode; sendSignal(fragOpPtr.p->m_userRef, GSN_TUX_ADD_ATTRREF, signal, TuxAddAttrRef::SignalLength, JBB); +#ifdef VM_TRACE + if (debugFlags & DebugMeta) { + debugOut << "Release on attr error frag op " << fragOpPtr.i << " " << *fragOpPtr.p << endl; + } +#endif c_fragOpPool.release(fragOpPtr); - dropIndex(signal, indexPtr, 0, 0); + // let DICT drop the unfinished index +} + +/* + * LQH aborts on-going create index operation. + */ +void +Dbtux::abortAddFragOp(Signal* signal) +{ + FragOpPtr fragOpPtr; + IndexPtr indexPtr; + c_fragOpPool.getPtr(fragOpPtr, signal->theData[1]); + c_indexPool.getPtr(indexPtr, fragOpPtr.p->m_indexId); +#ifdef VM_TRACE + if (debugFlags & DebugMeta) { + debugOut << "Release on abort frag op " << fragOpPtr.i << " " << *fragOpPtr.p << endl; + } +#endif + c_fragOpPool.release(fragOpPtr); + // let DICT drop the unfinished index } /* @@ -341,20 +406,13 @@ Dbtux::dropIndex(Signal* signal, IndexPtr indexPtr, Uint32 senderRef, Uint32 sen { jam(); indexPtr.p->m_state = Index::Dropping; - // drop one fragment at a time - if (indexPtr.p->m_numFrags > 0) { + // drop fragments + while (indexPtr.p->m_numFrags > 0) { jam(); - unsigned i = --indexPtr.p->m_numFrags; + Uint32 i = --indexPtr.p->m_numFrags; FragPtr fragPtr; c_fragPool.getPtr(fragPtr, indexPtr.p->m_fragPtrI[i]); c_fragPool.release(fragPtr); - // the real time break is not used for anything currently - signal->theData[0] = TuxContinueB::DropIndex; - signal->theData[1] = indexPtr.i; - signal->theData[2] = senderRef; - signal->theData[3] = senderData; - sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB); - return; } // drop attributes if (indexPtr.p->m_descPage != RNIL) { diff --git a/ndb/src/kernel/blocks/dbtux/Makefile.am b/ndb/src/kernel/blocks/dbtux/Makefile.am index 7d012924522..b5951e8ed37 100644 --- a/ndb/src/kernel/blocks/dbtux/Makefile.am +++ b/ndb/src/kernel/blocks/dbtux/Makefile.am @@ -18,3 +18,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libdbtux.dsp + +libdbtux.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libdbtux_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/dbtux/Makefile_old b/ndb/src/kernel/blocks/dbtux/Makefile_old deleted file mode 100644 index 30927c31848..00000000000 --- a/ndb/src/kernel/blocks/dbtux/Makefile_old +++ /dev/null @@ -1,17 +0,0 @@ -include .defs.mk - -TYPE = kernel - -ARCHIVE_TARGET = dbtux - -SOURCES = \ - DbtuxGen.cpp \ - DbtuxMeta.cpp \ - DbtuxMaint.cpp \ - DbtuxNode.cpp \ - DbtuxTree.cpp \ - DbtuxScan.cpp \ - DbtuxCmp.cpp \ - DbtuxDebug.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/dbutil/DbUtil.cpp b/ndb/src/kernel/blocks/dbutil/DbUtil.cpp index f7e8981e122..b94bb8e6d7e 100644 --- a/ndb/src/kernel/blocks/dbutil/DbUtil.cpp +++ b/ndb/src/kernel/blocks/dbutil/DbUtil.cpp @@ -158,7 +158,7 @@ DbUtil::~DbUtil() { } -BLOCK_FUNCTIONS(DbUtil); +BLOCK_FUNCTIONS(DbUtil) void DbUtil::releasePrepare(PreparePtr prepPtr) { diff --git a/ndb/src/kernel/blocks/dbutil/Makefile.am b/ndb/src/kernel/blocks/dbutil/Makefile.am index 763875d578f..925356c2f76 100644 --- a/ndb/src/kernel/blocks/dbutil/Makefile.am +++ b/ndb/src/kernel/blocks/dbutil/Makefile.am @@ -7,3 +7,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libdbutil.dsp + +libdbutil.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libdbutil_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/dbutil/Makefile_old b/ndb/src/kernel/blocks/dbutil/Makefile_old deleted file mode 100644 index 54b7326e4e5..00000000000 --- a/ndb/src/kernel/blocks/dbutil/Makefile_old +++ /dev/null @@ -1,8 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := dbutil -SOURCES = DbUtil.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/grep/Grep.cpp b/ndb/src/kernel/blocks/grep/Grep.cpp index 0e41182348f..e89361dab06 100644 --- a/ndb/src/kernel/blocks/grep/Grep.cpp +++ b/ndb/src/kernel/blocks/grep/Grep.cpp @@ -603,7 +603,7 @@ Grep::PSCoord::execCREATE_SUBID_CONF(Signal* signal) GrepEvent::GrepPS_CreateSubIdConf, subId, subKey, - (Uint32)GrepError::NO_ERROR); + (Uint32)GrepError::GE_NO_ERROR); } void @@ -612,7 +612,7 @@ Grep::PSCoord::execCREATE_SUBID_REF(Signal* signal) { CreateSubscriptionIdRef const * ref = (CreateSubscriptionIdRef *)signal->getDataPtr(); Uint32 subData = ref->subscriberData; - GrepError::Code err; + GrepError::GE_Code err; Uint32 sendersBlockRef = signal->getSendersBlockRef(); if(sendersBlockRef == SUMA_REF) @@ -624,7 +624,7 @@ Grep::PSCoord::execCREATE_SUBID_REF(Signal* signal) { ndbrequire(false); /* Added since errorcode err unhandled * TODO: fix correct errorcode */ - err= GrepError::NO_ERROR; // remove compiler warning + err= GrepError::GE_NO_ERROR; // remove compiler warning } SubCoordinatorPtr subPtr; @@ -824,7 +824,7 @@ Grep::PSPart::execSUB_CREATE_REF(Signal* signal) jamEntry(); SubCreateRef * const ref = (SubCreateRef *)signal->getDataPtr(); Uint32 subData = ref->subscriberData; - GrepError::Code err = (GrepError::Code)ref->err; + GrepError::GE_Code err = (GrepError::GE_Code)ref->err; SubscriptionPtr subPtr; c_subscriptions.getPtr(subPtr, subData); sendRefToPSCoord(signal, *subPtr.p, err /*error*/); @@ -867,7 +867,7 @@ Grep::PSCoord::execGREP_CREATE_CONF(Signal* signal) GrepEvent::GrepPS_SubCreateConf, subId, subKey, - (Uint32)GrepError::NO_ERROR); + (Uint32)GrepError::GE_NO_ERROR); c_subCoordinatorPool.release(subPtr); @@ -889,7 +889,7 @@ Grep::PSCoord::execGREP_CREATE_REF(Signal* signal) SubCoordinatorPtr subPtr; c_runningSubscriptions.getPtr(subPtr, subData); - sendRefToSS(signal, *subPtr.p, (GrepError::Code)err /*error*/); + sendRefToSS(signal, *subPtr.p, (GrepError::GE_Code)err /*error*/); } @@ -1046,7 +1046,7 @@ Grep::PSPart::execSUB_START_REF(Signal* signal) { SubStartRef * const ref = (SubStartRef *)signal->getDataPtr(); Uint32 subData = ref->subscriberData; - GrepError::Code err = (GrepError::Code)ref->err; + GrepError::GE_Code err = (GrepError::GE_Code)ref->err; SubscriptionData::Part part = (SubscriptionData::Part)ref->part; SubscriptionPtr subPtr; c_subscriptions.getPtr(subPtr, subData); @@ -1102,7 +1102,7 @@ Grep::PSCoord::execGREP_START_CONF(Signal* signal) EventReport::GrepSubscriptionInfo, GrepEvent::GrepPS_SubStartMetaConf, subId, subKey, - (Uint32)GrepError::NO_ERROR); + (Uint32)GrepError::GE_NO_ERROR); c_subCoordinatorPool.release(subPtr); break; @@ -1118,7 +1118,7 @@ Grep::PSCoord::execGREP_START_CONF(Signal* signal) EventReport::GrepSubscriptionInfo, GrepEvent::GrepPS_SubStartDataConf, subId, subKey, - (Uint32)GrepError::NO_ERROR); + (Uint32)GrepError::GE_NO_ERROR); c_subCoordinatorPool.release(subPtr); @@ -1145,7 +1145,7 @@ Grep::PSCoord::execGREP_START_REF(Signal* signal) jamEntry(); GrepStartRef * const ref = (GrepStartRef *)signal->getDataPtr(); Uint32 subData = ref->senderData; - GrepError::Code err = (GrepError::Code)ref->err; + GrepError::GE_Code err = (GrepError::GE_Code)ref->err; SubscriptionData::Part part = (SubscriptionData::Part)ref->part; SubCoordinatorPtr subPtr; @@ -1301,7 +1301,7 @@ Grep::PSPart::execSUB_REMOVE_REF(Signal* signal) jamEntry(); SubRemoveRef * const ref = (SubRemoveRef *)signal->getDataPtr(); Uint32 subData = ref->subscriberData; - /* GrepError::Code err = (GrepError::Code)ref->err;*/ + /* GrepError::GE_Code err = (GrepError::GE_Code)ref->err;*/ SubscriptionPtr subPtr; c_subscriptions.getPtr(subPtr, subData); @@ -1342,7 +1342,7 @@ Grep::PSCoord::execGREP_REMOVE_CONF(Signal* signal) EventReport::GrepSubscriptionInfo, GrepEvent::GrepPS_SubRemoveConf, subId, subKey, - GrepError::NO_ERROR); + GrepError::GE_NO_ERROR); GrepSubRemoveConf * grepConf = (GrepSubRemoveConf *) conf; grepConf->subscriptionId = subId; @@ -1375,7 +1375,7 @@ Grep::PSCoord::execGREP_REMOVE_REF(Signal* signal) subPtr.p = c_runningSubscriptions.getPtr(subPtr.i); if(subData == subPtr.i) { - sendRefToSS(signal, *subPtr.p, (GrepError::Code)err /*error*/); + sendRefToSS(signal, *subPtr.p, (GrepError::GE_Code)err /*error*/); c_runningSubscriptions.release(subPtr); return; } @@ -1633,7 +1633,7 @@ Grep::PSPart::execSUB_SYNC_REF(Signal* signal) { jamEntry(); SubSyncRef * const ref = (SubSyncRef *)signal->getDataPtr(); Uint32 subData = ref->subscriberData; - GrepError::Code err = (GrepError::Code)ref->err; + GrepError::GE_Code err = (GrepError::GE_Code)ref->err; SubscriptionData::Part part = (SubscriptionData::Part)ref->part; SubscriptionPtr subPtr; @@ -1677,7 +1677,7 @@ Grep::PSCoord::execGREP_SYNC_CONF(Signal* signal) /* @todo Johan: Add firstGCI here. /Lars */ m_grep->sendEventRep(signal, EventReport::GrepSubscriptionInfo, event, subId, subKey, - (Uint32)GrepError::NO_ERROR, + (Uint32)GrepError::GE_NO_ERROR, lastGCI); /************************* @@ -1707,7 +1707,7 @@ Grep::PSCoord::execGREP_SYNC_REF(Signal* signal) { GrepSyncRef * const ref = (GrepSyncRef *)signal->getDataPtr(); Uint32 subData = ref->senderData; SubscriptionData::Part part = (SubscriptionData::Part)ref->part; - GrepError::Code err = (GrepError::Code)ref->err; + GrepError::GE_Code err = (GrepError::GE_Code)ref->err; SubCoordinatorPtr subPtr; c_runningSubscriptions.getPtr(subPtr, subData); sendRefToSS(signal, *subPtr.p, err /*error*/, part); @@ -1718,7 +1718,7 @@ Grep::PSCoord::execGREP_SYNC_REF(Signal* signal) { void Grep::PSCoord::sendRefToSS(Signal * signal, SubCoordinator sub, - GrepError::Code err, + GrepError::GE_Code err, SubscriptionData::Part part) { /** @@ -1843,7 +1843,7 @@ Grep::PSCoord::sendRefToSS(Signal * signal, void Grep::PSPart::sendRefToPSCoord(Signal * signal, Subscription sub, - GrepError::Code err, + GrepError::GE_Code err, SubscriptionData::Part part) { jam(); diff --git a/ndb/src/kernel/blocks/grep/Grep.hpp b/ndb/src/kernel/blocks/grep/Grep.hpp index eeabac36966..7d3dd916ecc 100644 --- a/ndb/src/kernel/blocks/grep/Grep.hpp +++ b/ndb/src/kernel/blocks/grep/Grep.hpp @@ -380,16 +380,16 @@ public: Uint32 subId, Uint32 subKey, BlockReference to, - GrepError::Code err); + GrepError::GE_Code err); void sendSubRemoveRef_SS(Signal * signal, SubCoordinator sub, - GrepError::Code err); + GrepError::GE_Code err); void sendRefToSS(Signal * signal, SubCoordinator sub, - GrepError::Code err, + GrepError::GE_Code err, SubscriptionData::Part part = (SubscriptionData::Part)0); void setRepRef(BlockReference rr) { m_repRef = rr; }; @@ -496,7 +496,7 @@ public: void sendRefToPSCoord(Signal * signal, Subscription sub, - GrepError::Code err, + GrepError::GE_Code err, SubscriptionData::Part part = (SubscriptionData::Part)0); //protected: diff --git a/ndb/src/kernel/blocks/grep/GrepInit.cpp b/ndb/src/kernel/blocks/grep/GrepInit.cpp index cfb454a1f9b..d764fb1f473 100644 --- a/ndb/src/kernel/blocks/grep/GrepInit.cpp +++ b/ndb/src/kernel/blocks/grep/GrepInit.cpp @@ -15,7 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Grep.hpp" -#include <new> #include <Properties.hpp> #include <Configuration.hpp> @@ -132,7 +131,7 @@ Grep::~Grep() { } -BLOCK_FUNCTIONS(Grep); +BLOCK_FUNCTIONS(Grep) Grep::PSPart::PSPart(Grep * sb) : BlockComponent(sb), diff --git a/ndb/src/kernel/blocks/grep/Makefile.am b/ndb/src/kernel/blocks/grep/Makefile.am index 31081c7b6a0..6d2b422784b 100644 --- a/ndb/src/kernel/blocks/grep/Makefile.am +++ b/ndb/src/kernel/blocks/grep/Makefile.am @@ -7,3 +7,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libgrep.dsp + +libgrep.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libgrep_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/grep/Makefile_old b/ndb/src/kernel/blocks/grep/Makefile_old deleted file mode 100644 index 5ad5a0bce3b..00000000000 --- a/ndb/src/kernel/blocks/grep/Makefile_old +++ /dev/null @@ -1,9 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := grep - -SOURCES = Grep.cpp GrepInit.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/ndbcntr/Makefile.am b/ndb/src/kernel/blocks/ndbcntr/Makefile.am index 9230b55b374..3f24675b2b3 100644 --- a/ndb/src/kernel/blocks/ndbcntr/Makefile.am +++ b/ndb/src/kernel/blocks/ndbcntr/Makefile.am @@ -10,3 +10,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libndbcntr.dsp + +libndbcntr.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libndbcntr_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/ndbcntr/Makefile_old b/ndb/src/kernel/blocks/ndbcntr/Makefile_old deleted file mode 100644 index 8e9c4f01027..00000000000 --- a/ndb/src/kernel/blocks/ndbcntr/Makefile_old +++ /dev/null @@ -1,12 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := ndbcntr - -SOURCES = \ - NdbcntrInit.cpp \ - NdbcntrSysTable.cpp \ - NdbcntrMain.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp b/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp index 43044eeebcd..c7b472fc91a 100644 --- a/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp +++ b/ndb/src/kernel/blocks/ndbcntr/NdbcntrInit.cpp @@ -114,4 +114,4 @@ Ndbcntr::~Ndbcntr() }//Ndbcntr::~Ndbcntr() -BLOCK_FUNCTIONS(Ndbcntr); +BLOCK_FUNCTIONS(Ndbcntr) diff --git a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp index a02bfd459b3..f76440a462a 100644 --- a/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp +++ b/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp @@ -14,19 +14,11 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/** - * O_DIRECT - */ -#if 0 -//#ifdef NDB_LINUX -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#endif - #include <ndb_global.h> +#include <my_sys.h> +#include <my_pthread.h> -#include "Error.hpp" +#include <Error.hpp> #include "AsyncFile.hpp" #include <ErrorHandlingMacros.hpp> @@ -35,13 +27,12 @@ #include <NdbThread.h> #include <signaldata/FsOpenReq.hpp> -#if 0 -#ifdef HAVE_PREAD -// This is for pread and pwrite -#ifndef __USE_UNIX98 -#define __USE_UNIX98 -#endif -#endif +// use this to test broken pread code +//#define HAVE_BROKEN_PREAD + +#ifdef HAVE_BROKEN_PREAD +#undef HAVE_PWRITE +#undef HAVE_PREAD #endif #if defined NDB_WIN32 || defined NDB_OSE || defined NDB_SOFTOSE @@ -227,7 +218,8 @@ AsyncFile::run() rmrfReq(request, (char*)theFileName.c_str(), request->par.rmrf.own_directory); break; case Request:: end: - closeReq(request); + if (theFd > 0) + closeReq(request); endReq(); return; default: @@ -247,6 +239,7 @@ void AsyncFile::openReq(Request* request) { m_openedWithSync = false; m_syncFrequency = 0; + m_syncCount= 0; // for open.flags, see signal FSOPENREQ #ifdef NDB_WIN32 @@ -337,7 +330,6 @@ void AsyncFile::openReq(Request* request) } else { #endif m_openedWithSync = false; - m_syncCount = 0; m_syncFrequency = Global_syncFreq; #if 0 } @@ -395,9 +387,12 @@ AsyncFile::readBuffer(char * buf, size_t size, off_t offset){ if(dwSFP != offset) { return GetLastError(); } -#elif defined NDB_OSE || defined NDB_SOFTOSE - return_value = lseek(theFd, offset, SEEK_SET); - if (return_value != offset) { +#elif ! defined(HAVE_PREAD) + off_t seek_val; + while((seek_val= lseek(theFd, offset, SEEK_SET)) == (off_t)-1 + && errno == EINTR); + if(seek_val == (off_t)-1) + { return errno; } #endif @@ -416,7 +411,7 @@ AsyncFile::readBuffer(char * buf, size_t size, off_t offset){ return GetLastError(); } bytes_read = dwBytesRead; -#elif defined NDB_OSE || defined NDB_SOFTOSE +#elif ! defined(HAVE_PREAD) return_value = ::read(theFd, buf, size); #else // UNIX return_value = ::pread(theFd, buf, size, offset); @@ -469,7 +464,7 @@ AsyncFile::readReq( Request * request) void AsyncFile::readvReq( Request * request) { -#if defined NDB_OSE || defined NDB_SOFTOSE +#if ! defined(HAVE_PREAD) readReq(request); return; #elif defined NDB_WIN32 @@ -499,7 +494,7 @@ AsyncFile::readvReq( Request * request) int AsyncFile::extendfile(Request* request) { -#if defined NDB_OSE || defined NDB_SOFTOSE +#if ! defined(HAVE_PWRITE) // Find max size of this file in this request int maxOffset = 0; int maxSize = 0; @@ -608,27 +603,13 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, if(dwSFP != offset) { return GetLastError(); } -#elif defined NDB_OSE || defined NDB_SOFTOSE - return_value = lseek(theFd, offset, SEEK_SET); - if (return_value != offset) { - DEBUG(ndbout_c("AsyncFile::writeReq, err1: return_value=%d, offset=%d\n", - return_value, chunk_offset)); - PRINT_ERRORANDFLAGS(0); - if (errno == 78) { - // Could not write beyond end of file, try to extend file - DEBUG(ndbout_c("AsyncFile::writeReq, Extend. file! filename=\"%s\" \n", - theFileName.c_str())); - return_value = extendfile(request); - if (return_value == -1) { - return errno; - } - return_value = lseek(theFd, offset, SEEK_SET); - if (return_value != offset) { - return errno; - } - } else { - return errno; - } +#elif ! defined(HAVE_PWRITE) + off_t seek_val; + while((seek_val= lseek(theFd, offset, SEEK_SET)) == (off_t)-1 + && errno == EINTR); + if(seek_val == (off_t)-1) + { + return errno; } #endif @@ -650,7 +631,7 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, DEBUG(ndbout_c("Warning partial write %d != %d", bytes_written, bytes_to_write)); } -#elif defined NDB_OSE || defined NDB_SOFTOSE +#elif ! defined(HAVE_PWRITE) return_value = ::write(theFd, buf, bytes_to_write); #else // UNIX return_value = ::pwrite(theFd, buf, bytes_to_write, offset); @@ -675,6 +656,7 @@ AsyncFile::writeBuffer(const char * buf, size_t size, off_t offset, } #endif + m_syncCount+= bytes_written; buf += bytes_written; size -= bytes_written; offset += bytes_written; @@ -701,6 +683,10 @@ AsyncFile::closeReq(Request * request) hFile = INVALID_HANDLE_VALUE; #else if (-1 == ::close(theFd)) { +#ifndef DBUG_OFF + if (theFd == -1) + abort(); +#endif request->error = errno; } theFd = -1; @@ -719,7 +705,8 @@ bool AsyncFile::isOpen(){ void AsyncFile::syncReq(Request * request) { - if(m_openedWithSync){ + if(m_openedWithSync || + m_syncCount == 0){ return; } #ifdef NDB_WIN32 @@ -775,7 +762,6 @@ AsyncFile::appendReq(Request * request){ if(m_syncFrequency != 0 && m_syncCount > m_syncFrequency){ syncReq(request); - request->error = 0; } } @@ -889,7 +875,6 @@ void AsyncFile::endReq() { // Thread is ended with return if (theWriteBuffer) NdbMem_Free(theWriteBuffer); - NdbThread_Exit(0); } diff --git a/ndb/src/kernel/blocks/ndbfs/Makefile.am b/ndb/src/kernel/blocks/ndbfs/Makefile.am index c2b663c5042..a22386f8612 100644 --- a/ndb/src/kernel/blocks/ndbfs/Makefile.am +++ b/ndb/src/kernel/blocks/ndbfs/Makefile.am @@ -11,3 +11,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libndbfs.dsp + +libndbfs.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libndbfs_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/ndbfs/Makefile_old b/ndb/src/kernel/blocks/ndbfs/Makefile_old deleted file mode 100644 index 58e1458bf16..00000000000 --- a/ndb/src/kernel/blocks/ndbfs/Makefile_old +++ /dev/null @@ -1,14 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := ndbfs - -SOURCES = \ - AsyncFile.cpp \ - Ndbfs.cpp VoidFs.cpp \ - Filename.cpp \ - CircularIndex.cpp - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp b/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp index aeab9f7828d..b98c60693f4 100644 --- a/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp +++ b/ndb/src/kernel/blocks/ndbfs/MemoryChannelTest/MemoryChannelTest.cpp @@ -40,7 +40,6 @@ extern "C" void* runProducer(void*arg) NdbSleep_MilliSleep(i); i++; } - NdbThread_Exit(0); return NULL; } @@ -58,7 +57,6 @@ extern "C" void* runConsumer(void* arg) delete p; } - NdbThread_Exit(0); return NULL; } @@ -92,7 +90,6 @@ extern "C" void* runProducer2(void*arg) NdbSleep_MilliSleep(i); i++; } - NdbThread_Exit(0); return NULL; } @@ -111,7 +108,6 @@ extern "C" void* runConsumer2(void* arg) delete p; } ndbout << "Consumer2: " << count << " received" << endl; - NdbThread_Exit(0); return NULL; } diff --git a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp index 56e3d3abbed..9c943760e31 100644 --- a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp +++ b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp @@ -730,7 +730,7 @@ Ndbfs::scanIPC(Signal* signal) jam(); report(request, signal); theRequestPool->put(request); - return &request; + return true; } return false; } @@ -1010,7 +1010,7 @@ Ndbfs::execDUMP_STATE_ORD(Signal* signal) -BLOCK_FUNCTIONS(Ndbfs); +BLOCK_FUNCTIONS(Ndbfs) template class Vector<AsyncFile*>; template class Vector<OpenFiles::OpenFileItem>; diff --git a/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp b/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp index d3407e8d4e7..d093089acfc 100644 --- a/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp +++ b/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp @@ -196,5 +196,5 @@ VoidFs::execDUMP_STATE_ORD(Signal* signal) -BLOCK_FUNCTIONS(VoidFs); +BLOCK_FUNCTIONS(VoidFs) diff --git a/ndb/src/kernel/blocks/qmgr/Makefile.am b/ndb/src/kernel/blocks/qmgr/Makefile.am index 52cadb3bd3d..278af2a7865 100644 --- a/ndb/src/kernel/blocks/qmgr/Makefile.am +++ b/ndb/src/kernel/blocks/qmgr/Makefile.am @@ -9,3 +9,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libqmgr.dsp + +libqmgr.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libqmgr_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/qmgr/Makefile_old b/ndb/src/kernel/blocks/qmgr/Makefile_old deleted file mode 100644 index cd15643ea60..00000000000 --- a/ndb/src/kernel/blocks/qmgr/Makefile_old +++ /dev/null @@ -1,11 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := qmgr - -SOURCES = \ - QmgrInit.cpp \ - QmgrMain.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp b/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp index b0f1088779c..d6960ce154e 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrInit.cpp @@ -100,4 +100,4 @@ Qmgr::~Qmgr() }//Qmgr::~Qmgr() -BLOCK_FUNCTIONS(Qmgr); +BLOCK_FUNCTIONS(Qmgr) diff --git a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp index 41deb3403c8..da8596076ec 100644 --- a/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp +++ b/ndb/src/kernel/blocks/qmgr/QmgrMain.cpp @@ -1934,17 +1934,27 @@ void Qmgr::execAPI_REGREQ(Signal* signal) switch(getNodeInfo(apiNodePtr.i).getType()){ case NodeInfo::API: compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version); + if (!compatability_check) + infoEvent("Connection attempt from api or mysqld id=%d with %s " + "incompatible with %s", apiNodePtr.i, + getVersionString(version,""), NDB_VERSION_STRING); break; case NodeInfo::MGM: compatability_check = ndbCompatible_ndb_mgmt(NDB_VERSION, version); + if (!compatability_check) + infoEvent("Connection attempt from management server id=%d with %s " + "incompatible with %s", apiNodePtr.i, + getVersionString(version,""), NDB_VERSION_STRING); break; case NodeInfo::REP: - compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version); - break; + // compatability_check = ndbCompatible_ndb_api(NDB_VERSION, version); + // break; case NodeInfo::DB: case NodeInfo::INVALID: default: sendApiRegRef(signal, ref, ApiRegRef::WrongType); + infoEvent("Invalid connection attempt with type %d", + getNodeInfo(apiNodePtr.i).getType()); return; } @@ -2937,6 +2947,12 @@ void Qmgr::sendPrepFailReq(Signal* signal, Uint16 aNode) */ /** + * Should < 1/2 nodes die unconditionally. Affects only >= 3-way + * replication. + */ +static const bool g_ndb_arbit_one_half_rule = false; + +/** * Config signals are logically part of CM_INIT. */ void @@ -3147,7 +3163,8 @@ Qmgr::handleArbitCheck(Signal* signal) ndbrequire(cpresident == getOwnNodeId()); NodeBitmask ndbMask; computeArbitNdbMask(ndbMask); - if (2 * ndbMask.count() < cnoOfNodes) { + if (g_ndb_arbit_one_half_rule && + 2 * ndbMask.count() < cnoOfNodes) { jam(); arbitRec.code = ArbitCode::LoseNodes; } else { @@ -3171,6 +3188,11 @@ Qmgr::handleArbitCheck(Signal* signal) case CheckNodeGroups::Partitioning: jam(); arbitRec.code = ArbitCode::Partitioning; + if (g_ndb_arbit_one_half_rule && + 2 * ndbMask.count() > cnoOfNodes) { + jam(); + arbitRec.code = ArbitCode::WinNodes; + } break; default: ndbrequire(false); @@ -3180,8 +3202,12 @@ Qmgr::handleArbitCheck(Signal* signal) switch (arbitRec.code) { case ArbitCode::LoseNodes: jam(); + case ArbitCode::LoseGroups: + jam(); goto crashme; - case ArbitCode::WinGroups: + case ArbitCode::WinNodes: + jam(); + case ArbitCode::WinGroups: jam(); if (arbitRec.state == ARBIT_RUN) { jam(); @@ -3190,9 +3216,6 @@ Qmgr::handleArbitCheck(Signal* signal) arbitRec.state = ARBIT_INIT; arbitRec.newstate = true; break; - case ArbitCode::LoseGroups: - jam(); - goto crashme; case ArbitCode::Partitioning: if (arbitRec.state == ARBIT_RUN) { jam(); @@ -3752,8 +3775,7 @@ Qmgr::execARBIT_CHOOSEREF(Signal* signal) } /** - * Handle CRASH state. We must crash immediately. But it - * would be nice to wait until event reports have been sent. + * Handle CRASH state. We must crash immediately. * XXX tell other nodes in our party to crash too. */ void @@ -3763,12 +3785,11 @@ Qmgr::stateArbitCrash(Signal* signal) if (arbitRec.newstate) { jam(); CRASH_INSERTION((Uint32)910 + arbitRec.state); - arbitRec.setTimestamp(); arbitRec.code = 0; arbitRec.newstate = false; } -#if 0 +#ifdef ndb_arbit_crash_wait_for_event_report_to_get_out if (! (arbitRec.getTimediff() > getArbitTimeout())) return; #endif diff --git a/ndb/src/kernel/blocks/suma/Makefile.am b/ndb/src/kernel/blocks/suma/Makefile.am index 4dacb22af51..5a74dbb74eb 100644 --- a/ndb/src/kernel/blocks/suma/Makefile.am +++ b/ndb/src/kernel/blocks/suma/Makefile.am @@ -7,3 +7,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libsuma.dsp + +libsuma.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libsuma_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/suma/Makefile_old b/ndb/src/kernel/blocks/suma/Makefile_old deleted file mode 100644 index 20014c94670..00000000000 --- a/ndb/src/kernel/blocks/suma/Makefile_old +++ /dev/null @@ -1,10 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := suma - -SOURCES = Suma.cpp SumaInit.cpp - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/src/kernel/blocks/suma/Suma.cpp b/ndb/src/kernel/blocks/suma/Suma.cpp index d11d5f7176a..44ac054dd67 100644 --- a/ndb/src/kernel/blocks/suma/Suma.cpp +++ b/ndb/src/kernel/blocks/suma/Suma.cpp @@ -824,7 +824,8 @@ Suma::execUTIL_SEQUENCE_CONF(Signal* signal) return; } - Uint32 subId = conf->sequenceValue[0]; + Uint64 subId; + memcpy(&subId,conf->sequenceValue,8); Uint32 subData = conf->senderData; SubscriberPtr subbPtr; @@ -832,8 +833,8 @@ Suma::execUTIL_SEQUENCE_CONF(Signal* signal) CreateSubscriptionIdConf * subconf = (CreateSubscriptionIdConf*)conf; - subconf->subscriptionId = subId; - subconf->subscriptionKey =(getOwnNodeId() << 16) | (subId & 0xFFFF); + subconf->subscriptionId = (Uint32)subId; + subconf->subscriptionKey =(getOwnNodeId() << 16) | (Uint32)(subId & 0xFFFF); subconf->subscriberData = subbPtr.p->m_senderData; sendSignal(subbPtr.p->m_subscriberRef, GSN_CREATE_SUBID_CONF, signal, @@ -1888,7 +1889,7 @@ SumaParticipant::SyncRecord::nextScan(Signal* signal){ req->requestInfo = 0; req->savePointId = 0; ScanFragReq::setLockMode(req->requestInfo, 0); - ScanFragReq::setHoldLockFlag(req->requestInfo, 0); + ScanFragReq::setHoldLockFlag(req->requestInfo, 1); ScanFragReq::setKeyinfoFlag(req->requestInfo, 0); ScanFragReq::setAttrLen(req->requestInfo, attrLen); req->fragmentNoKeyLen = fd.m_fragDesc.m_fragmentNo; @@ -3471,10 +3472,10 @@ SumaParticipant::completeSubRemoveReq(Signal* signal, SubscriptionPtr subPtr) { */ #if 0 ndbout_c("c_subscriptionPool.getSize() %d c_subscriptionPool.getNoOfFree()%d", - c_subscriptionPool.getSize(),c_subscriptionPool.getNoOfFree()+1); + c_subscriptionPool.getSize(),c_subscriptionPool.getNoOfFree()); #endif - if(c_subscriptionPool.getSize() == c_subscriptionPool.getNoOfFree()+1) { + if(c_subscriptionPool.getSize() == c_subscriptionPool.getNoOfFree()) { jam(); #if 0 ndbout_c("SUB_REMOVE_REQ:Clearing c_tables"); @@ -3553,7 +3554,7 @@ Suma::Restart::Restart(Suma& s) : suma(s) { c_okToStart[i] = false; c_waitingToStart[i] = false; } -}; +} void Suma::Restart::resetNode(Uint32 sumaRef) diff --git a/ndb/src/kernel/blocks/suma/SumaInit.cpp b/ndb/src/kernel/blocks/suma/SumaInit.cpp index 255abd47c94..b5945db3811 100644 --- a/ndb/src/kernel/blocks/suma/SumaInit.cpp +++ b/ndb/src/kernel/blocks/suma/SumaInit.cpp @@ -16,7 +16,6 @@ #include "Suma.hpp" -#include <new> #include <Properties.hpp> #include <Configuration.hpp> @@ -188,6 +187,6 @@ Suma::~Suma() { } -BLOCK_FUNCTIONS(Suma); -BLOCK_FUNCTIONS(SumaParticipant); +BLOCK_FUNCTIONS(Suma) +BLOCK_FUNCTIONS(SumaParticipant) diff --git a/ndb/src/kernel/blocks/trix/Makefile.am b/ndb/src/kernel/blocks/trix/Makefile.am index 803da815cf0..343063a6283 100644 --- a/ndb/src/kernel/blocks/trix/Makefile.am +++ b/ndb/src/kernel/blocks/trix/Makefile.am @@ -7,3 +7,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libtrix.dsp + +libtrix.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libtrix_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/blocks/trix/Makefile_old b/ndb/src/kernel/blocks/trix/Makefile_old deleted file mode 100644 index 5ac0da11f33..00000000000 --- a/ndb/src/kernel/blocks/trix/Makefile_old +++ /dev/null @@ -1,8 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := trix -SOURCES = Trix.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/blocks/trix/Trix.cpp b/ndb/src/kernel/blocks/trix/Trix.cpp index 80cf9f88c0d..75bc19b6a20 100644 --- a/ndb/src/kernel/blocks/trix/Trix.cpp +++ b/ndb/src/kernel/blocks/trix/Trix.cpp @@ -962,6 +962,6 @@ void Trix::checkParallelism(Signal* signal, SubscriptionRecord* subRec) } } -BLOCK_FUNCTIONS(Trix); +BLOCK_FUNCTIONS(Trix) template void append(DataBuffer<15>&,SegmentedSectionPtr,SectionSegmentPool&); diff --git a/ndb/src/kernel/error/ErrorReporter.cpp b/ndb/src/kernel/error/ErrorReporter.cpp index 35c99b30994..35cd3f099d9 100644 --- a/ndb/src/kernel/error/ErrorReporter.cpp +++ b/ndb/src/kernel/error/ErrorReporter.cpp @@ -137,7 +137,7 @@ ErrorReporter::formatMessage(ErrorCategory type, faultID, (problemData == NULL) ? "" : problemData, objRef, - programName, + my_progname, processId, theNameOfTheTraceFile ? theNameOfTheTraceFile : "<no tracefile>"); diff --git a/ndb/src/kernel/error/Makefile.am b/ndb/src/kernel/error/Makefile.am index 4514d2d105c..54f3de2d76d 100644 --- a/ndb/src/kernel/error/Makefile.am +++ b/ndb/src/kernel/error/Makefile.am @@ -9,3 +9,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: liberror.dsp + +liberror.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(liberror_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/error/Makefile_old b/ndb/src/kernel/error/Makefile_old deleted file mode 100644 index 0fe81f083ce..00000000000 --- a/ndb/src/kernel/error/Makefile_old +++ /dev/null @@ -1,12 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := error - -SOURCES = \ - TimeModule.cpp \ - ErrorReporter.cpp \ - ErrorMessages.cpp - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index fa44704807d..e6e0a7ca877 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -19,7 +19,6 @@ #include <ndb_version.h> #include "Configuration.hpp" -#include <LocalConfig.hpp> #include <TransporterRegistry.hpp> #include "vm/SimBlockList.hpp" @@ -53,15 +52,13 @@ extern "C" void handler_error(int signum); // for process signal handling void systemInfo(const Configuration & conf, const LogLevel & ll); -const char programName[] = "NDB Kernel"; - -NDB_MAIN(ndb_kernel){ - - ndb_init(); +int main(int argc, char** argv) +{ + NDB_INIT(argv[0]); // Print to stdout/console g_eventLogger.createConsoleHandler(); g_eventLogger.setCategory("NDB"); - g_eventLogger.enable(Logger::LL_INFO, Logger::LL_ALERT); // Log INFO to ALERT + g_eventLogger.enable(Logger::LL_ON, Logger::LL_ERROR); globalEmulatorData.create(); @@ -71,19 +68,14 @@ NDB_MAIN(ndb_kernel){ return NRT_Default; } - LocalConfig local_config; - if (!local_config.init(theConfig->getConnectString(),0)){ - local_config.printError(); - local_config.printUsage(); - return NRT_Default; - } - { // Do configuration - signal(SIGPIPE, SIG_IGN); - theConfig->fetch_configuration(local_config); +#ifndef NDB_WIN32 + signal(SIGPIPE, SIG_IGN); +#endif + theConfig->fetch_configuration(); } - - chdir(NdbConfig_get_path(0)); + + my_setwd(NdbConfig_get_path(0), MYF(0)); if (theConfig->getDaemonMode()) { // Become a daemon @@ -97,6 +89,7 @@ NDB_MAIN(ndb_kernel){ } } +#ifndef NDB_WIN32 for(pid_t child = fork(); child != 0; child = fork()){ /** * Parent @@ -143,10 +136,13 @@ NDB_MAIN(ndb_kernel){ exit(0); } g_eventLogger.info("Ndb has terminated (pid %d) restarting", child); - theConfig->fetch_configuration(local_config); + theConfig->fetch_configuration(); } g_eventLogger.info("Angel pid: %d ndb pid: %d", getppid(), getpid()); +#else + g_eventLogger.info("Ndb started"); +#endif theConfig->setupConfiguration(); systemInfo(* theConfig, * theConfig->m_logLevel); @@ -184,11 +180,9 @@ NDB_MAIN(ndb_kernel){ assert("Illegal state globalData.theRestartFlag" == 0); } - SocketServer socket_server; - globalTransporterRegistry.startSending(); globalTransporterRegistry.startReceiving(); - if (!globalTransporterRegistry.start_service(socket_server)){ + if (!globalTransporterRegistry.start_service(*globalEmulatorData.m_socket_server)){ ndbout_c("globalTransporterRegistry.start_service() failed"); exit(-1); } @@ -200,7 +194,7 @@ NDB_MAIN(ndb_kernel){ globalEmulatorData.theWatchDog->doStart(); - socket_server.startServer(); + globalEmulatorData.m_socket_server->startServer(); // theConfig->closeConfiguration(); @@ -208,11 +202,6 @@ NDB_MAIN(ndb_kernel){ NdbShutdown(NST_Normal); - socket_server.stopServer(); - socket_server.stopSessions(); - - globalTransporterRegistry.stop_clients(); - return NRT_Default; } @@ -278,7 +267,7 @@ systemInfo(const Configuration & config, const LogLevel & logLevel){ void catchsigs(bool ignore){ -#if ! defined NDB_SOFTOSE && !defined NDB_OSE +#if !defined NDB_WIN32 && !defined NDB_SOFTOSE && !defined NDB_OSE static const int signals_shutdown[] = { #ifdef SIGBREAK @@ -320,7 +309,6 @@ catchsigs(bool ignore){ SIGTRAP #endif }; -#endif static const int signals_ignore[] = { SIGPIPE @@ -333,6 +321,7 @@ catchsigs(bool ignore){ handler_register(signals_error[i], handler_error, ignore); for(i = 0; i < sizeof(signals_ignore)/sizeof(signals_ignore[0]); i++) handler_register(signals_ignore[i], SIG_IGN, ignore); +#endif } extern "C" @@ -351,8 +340,10 @@ handler_error(int signum){ if (thread_id != 0 && thread_id == my_thread_id()) { // Shutdown thread received signal - signal(signum, SIG_DFL); +#ifndef NDB_WIN32 + signal(signum, SIG_DFL); kill(getpid(), signum); +#endif while(true) NdbSleep_MilliSleep(10); } diff --git a/ndb/src/kernel/vm/Callback.hpp b/ndb/src/kernel/vm/Callback.hpp index bf1ae5968d3..6a619ba7859 100644 --- a/ndb/src/kernel/vm/Callback.hpp +++ b/ndb/src/kernel/vm/Callback.hpp @@ -20,12 +20,5 @@ /** * Block callbacks */ -typedef void (SimulatedBlock::* CallbackFunction)(class Signal*, - Uint32 callbackData, - Uint32 returnCode); -struct Callback { - CallbackFunction m_callbackFunction; - Uint32 m_callbackData; -}; #endif diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 706f60fd9cf..de78a4e927c 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -15,8 +15,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> +#include <ndb_opts.h> -#include <LocalConfig.hpp> #include "Configuration.hpp" #include <ErrorHandlingMacros.hpp> #include "GlobalData.hpp" @@ -28,14 +28,13 @@ #include <NdbOut.hpp> #include <WatchDog.hpp> -#include <getarg.h> - #include <mgmapi_configuration.hpp> #include <mgmapi_config_parameters_debug.h> #include <kernel_config_parameters.h> #include <kernel_types.h> #include <ndb_limits.h> +#include <ndbapi_limits.h> #include "pc.hpp" #include <LogLevel.hpp> #include <NdbSleep.h> @@ -47,81 +46,77 @@ extern "C" { #include <EventLogger.hpp> extern EventLogger g_eventLogger; +enum ndbd_options { + OPT_INITIAL = NDB_STD_OPTIONS_LAST, + OPT_NODAEMON +}; + +NDB_STD_OPTS_VARS; +static int _daemon, _no_daemon, _initial, _no_start; +/** + * Arguments to NDB process + */ +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndbd"), + { "initial", OPT_INITIAL, + "Perform initial start of ndbd, including cleaning the file system. " + "Consult documentation before using this", + (gptr*) &_initial, (gptr*) &_initial, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "nostart", 'n', + "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", + (gptr*) &_no_start, (gptr*) &_no_start, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "daemon", 'd', "Start ndbd as daemon (default)", + (gptr*) &_daemon, (gptr*) &_daemon, 0, + GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, + { "nodaemon", OPT_NODAEMON, + "Do not start ndbd as daemon, provided for testing purposes", + (gptr*) &_no_daemon, (gptr*) &_no_daemon, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void short_usage_sub(void) +{ + printf("Usage: %s [OPTIONS]\n", my_progname); +} +static void usage() +{ + short_usage_sub(); + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, + argument ? argument : "d:t:O,/tmp/ndbd.trace"); +} + bool -Configuration::init(int argc, const char** argv){ +Configuration::init(int argc, char** argv) +{ + const char *load_default_groups[]= { "mysql_cluster","ndbd",0 }; + load_defaults("my",load_default_groups,&argc,&argv); - /** - * Default values for arguments - */ - int _no_start = 0; - int _initial = 0; - const char* _connect_str = NULL; - int _daemon = 1; - int _no_daemon = 0; - int _help = 0; - int _print_version = 0; -#ifndef DBUG_OFF - const char *debug_option= 0; -#endif - - /** - * Arguments to NDB process - */ - - struct getargs args[] = { - { "version", 'v', arg_flag, &_print_version, "Print ndbd version", "" }, - { "nostart", 'n', arg_flag, &_no_start, - "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", "" }, - { "daemon", 'd', arg_flag, &_daemon, "Start ndbd as daemon (default)", "" }, - { "nodaemon", 0, arg_flag, &_no_daemon, "Do not start ndbd as daemon, provided for testing purposes", "" }, -#ifndef DBUG_OFF - { "debug", 0, arg_string, &debug_option, - "Specify debug options e.g. d:t:i:o,out.trace", "options" }, -#endif - { "initial", 0, arg_flag, &_initial, - "Perform initial start of ndbd, including cleaning the file system. Consult documentation before using this", "" }, + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + exit(ho_error); - { "connect-string", 'c', arg_string, &_connect_str, - "Set connect string for connecting to ndb_mgmd. <constr>=\"host=<hostname:port>[;nodeid=<id>]\". Overides specifying entries in NDB_CONNECTSTRING and config file", - "<constr>" }, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; - char desc[] = - "The MySQL Cluster kernel"; - - if(getarg(args, num_args, argc, argv, &optind) || _help) { - arg_printusage(args, num_args, argv[0], desc); - for (int i = 0; i < argc; i++) { - if (strcmp("-i",argv[i]) == 0) { - printf("flag depricated %s, use %s\n", "-i", "--initial"); - } - } - return false; - } if (_no_daemon) { _daemon= 0; } - // check for depricated flag '-i' - -#ifndef DBUG_OFF - if (debug_option) - DBUG_PUSH(debug_option); -#endif DBUG_PRINT("info", ("no_start=%d", _no_start)); DBUG_PRINT("info", ("initial=%d", _initial)); DBUG_PRINT("info", ("daemon=%d", _daemon)); - DBUG_PRINT("info", ("connect_str=%s", _connect_str)); + DBUG_PRINT("info", ("connect_str=%s", opt_connect_str)); ndbSetOwnVersion(); - if (_print_version) { - ndbPrintVersion(); - return false; - } - // Check the start flag if (_no_start) globalData.theRestartFlag = initial_state; @@ -133,8 +128,8 @@ Configuration::init(int argc, const char** argv){ _initialStart = true; // Check connectstring - if (_connect_str) - _connectString = strdup(_connect_str); + if (opt_connect_str) + _connectString = strdup(opt_connect_str); // Check daemon flag if (_daemon) @@ -146,6 +141,8 @@ Configuration::init(int argc, const char** argv){ else _programName = strdup(""); + globalData.ownId= 0; + return true; } @@ -185,7 +182,7 @@ Configuration::closeConfiguration(){ } void -Configuration::fetch_configuration(LocalConfig &local_config){ +Configuration::fetch_configuration(){ /** * Fetch configuration from management server */ @@ -195,8 +192,17 @@ Configuration::fetch_configuration(LocalConfig &local_config){ m_mgmd_port= 0; m_mgmd_host= 0; - m_config_retriever= new ConfigRetriever(local_config, NDB_VERSION, NODE_TYPE_DB); - if(m_config_retriever->do_connect() == -1){ + m_config_retriever= new ConfigRetriever(getConnectString(), + NDB_VERSION, NODE_TYPE_DB); + + if (m_config_retriever->hasError()) + { + ERROR_SET(fatal, ERR_INVALID_CONFIG, + "Could not connect initialize handle to management server", + m_config_retriever->getErrorString()); + } + + if(m_config_retriever->do_connect(12,5,1) == -1){ const char * s = m_config_retriever->getErrorString(); if(s == 0) s = "No error given!"; @@ -211,13 +217,14 @@ Configuration::fetch_configuration(LocalConfig &local_config){ ConfigRetriever &cr= *m_config_retriever; - if((globalData.ownId = cr.allocNodeId()) == 0){ - for(Uint32 i = 0; i<3; i++){ - NdbSleep_SecSleep(3); - if((globalData.ownId = cr.allocNodeId()) != 0) - break; - } - } + /** + * if we have a nodeid set (e.g in a restart situation) + * reuse it + */ + if (globalData.ownId) + cr.setNodeId(globalData.ownId); + + globalData.ownId = cr.allocNodeId(2 /*retry*/,3 /*delay*/); if(globalData.ownId == 0){ ERROR_SET(fatal, ERR_INVALID_CONFIG, @@ -274,19 +281,19 @@ static char * get_and_validate_path(ndb_mgm_configuration_iterator &iter, memset(buf2, 0,sizeof(buf2)); #ifdef NDB_WIN32 char* szFilePart; - if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart) - || (::GetFileAttributes(alloc_path)&FILE_ATTRIBUTE_READONLY)) + if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart) || + (GetFileAttributes(buf2) & FILE_ATTRIBUTE_READONLY)) #else - if((::realpath(path, buf2) == NULL)|| + if((::realpath(path, buf2) == NULL)|| (::access(buf2, W_OK) != 0)) #endif - { - ERROR_SET(fatal, AFS_ERROR_INVALIDPATH, path, " Filename::init()"); - } - + { + ERROR_SET(fatal, AFS_ERROR_INVALIDPATH, path, " Filename::init()"); + } + if (strcmp(&buf2[strlen(buf2) - 1], DIR_SEPARATOR)) strcat(buf2, DIR_SEPARATOR); - + return strdup(buf2); } @@ -448,6 +455,7 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ unsigned int noOfTables = 0; unsigned int noOfUniqueHashIndexes = 0; unsigned int noOfOrderedIndexes = 0; + unsigned int noOfTriggers = 0; unsigned int noOfReplicas = 0; unsigned int noOfDBNodes = 0; unsigned int noOfAPINodes = 0; @@ -472,6 +480,7 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ { CFG_DB_NO_TABLES, &noOfTables, false }, { CFG_DB_NO_ORDERED_INDEXES, &noOfOrderedIndexes, false }, { CFG_DB_NO_UNIQUE_HASH_INDEXES, &noOfUniqueHashIndexes, false }, + { CFG_DB_NO_TRIGGERS, &noOfTriggers, true }, { CFG_DB_NO_REPLICAS, &noOfReplicas, false }, { CFG_DB_NO_ATTRIBUTES, &noOfAttributes, false }, { CFG_DB_NO_OPS, &noOfOperations, false }, @@ -506,7 +515,7 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf); } - noOfDataPages = (dataMem / 8192); + noOfDataPages = (dataMem / 32768); noOfIndexPages = (indexMem / 8192); for(unsigned j = 0; j<LogLevel::LOGLEVEL_CATEGORIES; j++){ @@ -552,7 +561,7 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ noOfDBNodes++; // No of NDB processes if(nodeId > MAX_NDB_NODES){ - snprintf(buf, sizeof(buf), "Maximum node id for a ndb node is: %d", + BaseString::snprintf(buf, sizeof(buf), "Maximum node id for a ndb node is: %d", MAX_NDB_NODES); ERROR_SET(fatal, ERR_INVALID_CONFIG, msg, buf); } @@ -580,12 +589,42 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ ConfigValues::Iterator it2(*ownConfig, db.m_config); it2.set(CFG_DB_NO_TABLES, noOfTables); it2.set(CFG_DB_NO_ATTRIBUTES, noOfAttributes); + { + Uint32 neededNoOfTriggers = /* types: Insert/Update/Delete/Custom */ + 3 * noOfUniqueHashIndexes + /* for unique hash indexes, I/U/D */ + 3 * NDB_MAX_ACTIVE_EVENTS + /* for events in suma, I/U/D */ + 3 * noOfTables + /* for backup, I/U/D */ + noOfOrderedIndexes; /* for ordered indexes, C */ + if (noOfTriggers < neededNoOfTriggers) + { + noOfTriggers= neededNoOfTriggers; + it2.set(CFG_DB_NO_TRIGGERS, noOfTriggers); + } + } /** * Do size calculations */ ConfigValuesFactory cfg(ownConfig); + Uint32 noOfMetaTables= noOfTables + noOfOrderedIndexes + + noOfUniqueHashIndexes; + Uint32 noOfMetaTablesDict= noOfMetaTables; + if (noOfMetaTablesDict > MAX_TABLES) + noOfMetaTablesDict= MAX_TABLES; + + { + /** + * Dict Size Alt values + */ + cfg.put(CFG_DICT_ATTRIBUTE, + noOfAttributes); + + cfg.put(CFG_DICT_TABLE, + noOfMetaTablesDict); + } + + if (noOfLocalScanRecords == 0) { noOfLocalScanRecords = (noOfDBNodes * noOfScanRecords) + 1; } @@ -595,7 +634,7 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ Uint32 noOfTCScanRecords = noOfScanRecords; { - Uint32 noOfAccTables= noOfTables + noOfUniqueHashIndexes; + Uint32 noOfAccTables= noOfMetaTables/*noOfTables+noOfUniqueHashIndexes*/; /** * Acc Size Alt values */ @@ -637,19 +676,6 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ cfg.put(CFG_ACC_SCAN, noOfLocalScanRecords); } - Uint32 noOfMetaTables= noOfTables + noOfOrderedIndexes + - noOfUniqueHashIndexes; - { - /** - * Dict Size Alt values - */ - cfg.put(CFG_DICT_ATTRIBUTE, - noOfAttributes); - - cfg.put(CFG_DICT_TABLE, - noOfMetaTables); - } - { /** * Dih Size Alt values @@ -742,8 +768,8 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ noOfMetaTables); cfg.put(CFG_TUP_TABLE_DESC, - 4 * NO_OF_FRAG_PER_NODE * noOfAttributes* noOfReplicas + - 12 * NO_OF_FRAG_PER_NODE * noOfMetaTables* noOfReplicas ); + 2 * 6 * NO_OF_FRAG_PER_NODE * noOfAttributes * noOfReplicas + + 2 * 10 * NO_OF_FRAG_PER_NODE * noOfMetaTables * noOfReplicas ); cfg.put(CFG_TUP_STORED_PROC, noOfLocalScanRecords); @@ -754,9 +780,9 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){ * Tux Size Alt values */ cfg.put(CFG_TUX_INDEX, - noOfOrderedIndexes); + noOfMetaTables /*noOfOrderedIndexes*/); - cfg.put(CFG_TUX_FRAGMENT, + cfg.put(CFG_TUX_FRAGMENT, 2 * NO_OF_FRAG_PER_NODE * noOfOrderedIndexes * noOfReplicas); cfg.put(CFG_TUX_ATTRIBUTE, diff --git a/ndb/src/kernel/vm/Configuration.hpp b/ndb/src/kernel/vm/Configuration.hpp index 2ea32ffea37..acf0e163a84 100644 --- a/ndb/src/kernel/vm/Configuration.hpp +++ b/ndb/src/kernel/vm/Configuration.hpp @@ -21,7 +21,6 @@ #include <ndb_types.h> class ConfigRetriever; -class LocalConfig; class Configuration { public: @@ -31,9 +30,9 @@ public: /** * Returns false if arguments are invalid */ - bool init(int argc, const char** argv); + bool init(int argc, char** argv); - void fetch_configuration(LocalConfig &local_config); + void fetch_configuration(); void setupConfiguration(); void closeConfiguration(); diff --git a/ndb/src/kernel/vm/Emulator.cpp b/ndb/src/kernel/vm/Emulator.cpp index a5897cd4064..d6ed6c0dafd 100644 --- a/ndb/src/kernel/vm/Emulator.cpp +++ b/ndb/src/kernel/vm/Emulator.cpp @@ -33,7 +33,6 @@ #include <NdbOut.hpp> #include <NdbMutex.h> #include <NdbSleep.h> -#include <new> extern "C" { extern void (* ndb_new_handler)(); @@ -69,6 +68,7 @@ EmulatorData::EmulatorData(){ theThreadConfig = 0; theSimBlockList = 0; theShutdownMutex = 0; + m_socket_server = 0; } void @@ -84,6 +84,7 @@ EmulatorData::create(){ theWatchDog = new WatchDog(); theThreadConfig = new ThreadConfig(); theSimBlockList = new SimBlockList(); + m_socket_server = new SocketServer(); theShutdownMutex = NdbMutex_Create(); @@ -100,7 +101,8 @@ EmulatorData::destroy(){ delete theThreadConfig; theThreadConfig = 0; if(theSimBlockList) delete theSimBlockList; theSimBlockList = 0; - + if(m_socket_server) + delete m_socket_server; m_socket_server = 0; NdbMem_Destroy(); } @@ -179,12 +181,14 @@ NdbShutdown(NdbShutdownType type, exit(-1); #endif } - + +#ifndef NDB_WIN32 if (simulate_error_during_shutdown) { kill(getpid(), simulate_error_during_shutdown); while(true) NdbSleep_MilliSleep(10); } +#endif globalEmulatorData.theWatchDog->doStop(); @@ -194,9 +198,22 @@ NdbShutdown(NdbShutdownType type, fclose(outputStream); #endif + /** + * Stop all transporter connection attempts and accepts + */ + globalEmulatorData.m_socket_server->stopServer(); + globalEmulatorData.m_socket_server->stopSessions(); + globalTransporterRegistry.stop_clients(); + + /** + * Stop transporter communication with other nodes + */ globalTransporterRegistry.stopSending(); globalTransporterRegistry.stopReceiving(); + /** + * Remove all transporters + */ globalTransporterRegistry.removeAll(); #ifdef VM_TRACE diff --git a/ndb/src/kernel/vm/Emulator.hpp b/ndb/src/kernel/vm/Emulator.hpp index bd240f8679b..dba8cb3ab9b 100644 --- a/ndb/src/kernel/vm/Emulator.hpp +++ b/ndb/src/kernel/vm/Emulator.hpp @@ -25,6 +25,7 @@ // //=========================================================================== #include <kernel_types.h> +#include <TransporterRegistry.hpp> extern class JobTable globalJobTable; extern class TimeQueue globalTimeQueue; @@ -54,7 +55,8 @@ struct EmulatorData { class WatchDog * theWatchDog; class ThreadConfig * theThreadConfig; class SimBlockList * theSimBlockList; - + class SocketServer * m_socket_server; + /** * Constructor * diff --git a/ndb/src/kernel/vm/FastScheduler.cpp b/ndb/src/kernel/vm/FastScheduler.cpp index eca456d26dd..d0b7af27463 100644 --- a/ndb/src/kernel/vm/FastScheduler.cpp +++ b/ndb/src/kernel/vm/FastScheduler.cpp @@ -76,21 +76,27 @@ FastScheduler::activateSendPacked() globalData.loopMax = 2048; }//FastScheduler::activateSendPacked() +//------------------------------------------------------------------------ +// sendPacked is executed at the end of the loop. +// To ensure that we don't send any messages before executing all local +// packed signals we do another turn in the loop (unless we have already +// executed too many signals in the loop). +//------------------------------------------------------------------------ void FastScheduler::doJob() { + Uint32 loopCount = 0; + Uint32 TminLoops = getBOccupancy() + EXTRA_SIGNALS_PER_DO_JOB; + Uint32 TloopMax = (Uint32)globalData.loopMax; + if (TminLoops < TloopMax) { + TloopMax = TminLoops; + }//if + if (TloopMax < MIN_NUMBER_OF_SIG_PER_DO_JOB) { + TloopMax = MIN_NUMBER_OF_SIG_PER_DO_JOB; + }//if + register Signal* signal = getVMSignals(); + register Uint32 tHighPrio= globalData.highestAvailablePrio; do{ - Uint32 loopCount = 0; - Uint32 TminLoops = getBOccupancy() + EXTRA_SIGNALS_PER_DO_JOB; - Uint32 TloopMax = (Uint32)globalData.loopMax; - if (TminLoops < TloopMax) { - TloopMax = TminLoops; - }//if - if (TloopMax < MIN_NUMBER_OF_SIG_PER_DO_JOB) { - TloopMax = MIN_NUMBER_OF_SIG_PER_DO_JOB; - }//if - register Uint32 tHighPrio = globalData.highestAvailablePrio; - register Signal* signal = getVMSignals(); while ((tHighPrio < LEVEL_IDLE) && (loopCount < TloopMax)) { // signal->garbage_register(); // To ensure we find bugs quickly @@ -148,20 +154,27 @@ FastScheduler::doJob() }//if loopCount++; }//while - if (globalData.sendPackedActivated == 1) { - Uint32 t1 = theDoJobTotalCounter; - Uint32 t2 = theDoJobCallCounter; - t1 += loopCount; - t2++; - theDoJobTotalCounter = t1; - theDoJobCallCounter = t2; - if (t2 == 8192) { - reportDoJobStatistics(t1 >> 13); - theDoJobCallCounter = 0; - theDoJobTotalCounter = 0; - }//if - }//if - } while (getBOccupancy() > MAX_OCCUPANCY); + sendPacked(); + tHighPrio = globalData.highestAvailablePrio; + if(getBOccupancy() > MAX_OCCUPANCY) + { + if(loopCount != TloopMax) + abort(); + assert( loopCount == TloopMax ); + TloopMax += 512; + } + } while ((getBOccupancy() > MAX_OCCUPANCY) || + ((loopCount < TloopMax) && + (tHighPrio < LEVEL_IDLE))); + + theDoJobCallCounter ++; + theDoJobTotalCounter += loopCount; + if (theDoJobCallCounter == 8192) { + reportDoJobStatistics(theDoJobTotalCounter >> 13); + theDoJobCallCounter = 0; + theDoJobTotalCounter = 0; + }//if + }//FastScheduler::doJob() void FastScheduler::sendPacked() diff --git a/ndb/src/kernel/vm/LongSignal.hpp b/ndb/src/kernel/vm/LongSignal.hpp index f9ed443d995..9818358011f 100644 --- a/ndb/src/kernel/vm/LongSignal.hpp +++ b/ndb/src/kernel/vm/LongSignal.hpp @@ -25,7 +25,7 @@ */ struct SectionSegment { - STATIC_CONST( DataLength = 60 ); + STATIC_CONST( DataLength = NDB_SECTION_SEGMENT_SZ ); Uint32 m_ownerRef; Uint32 m_sz; diff --git a/ndb/src/kernel/vm/Makefile.am b/ndb/src/kernel/vm/Makefile.am index 4e9dbe36c78..0dce9285ae3 100644 --- a/ndb/src/kernel/vm/Makefile.am +++ b/ndb/src/kernel/vm/Makefile.am @@ -27,3 +27,17 @@ include $(top_srcdir)/ndb/config/type_kernel.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libkernel.dsp + +libkernel.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libkernel_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/kernel/vm/Makefile_old b/ndb/src/kernel/vm/Makefile_old deleted file mode 100644 index a162f3672ce..00000000000 --- a/ndb/src/kernel/vm/Makefile_old +++ /dev/null @@ -1,30 +0,0 @@ -include .defs.mk - -TYPE := kernel - -ARCHIVE_TARGET := kernel - -SOURCES = \ - SimulatedBlock.cpp \ - FastScheduler.cpp \ - TimeQueue.cpp \ - VMSignal.cpp \ - ThreadConfig.cpp \ - TransporterCallback.cpp \ - Emulator.cpp \ - Configuration.cpp \ - WatchDog.cpp \ - SimplePropertiesSection.cpp \ - SectionReader.cpp \ - MetaData.cpp \ - Mutex.cpp SafeCounter.cpp - -CFLAGS_Configuration.cpp := -I$(call fixpath,$(NDB_TOP)/src/mgmapi) - -DIRS := testCopy testDataBuffer testSimplePropertiesSection - -ifneq ($(USE_EDITLINE), N) -DIRS += testLongSig -endif - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/kernel/vm/Mutex.cpp b/ndb/src/kernel/vm/Mutex.cpp index 1dbc6e7ec4a..aab9e74312b 100644 --- a/ndb/src/kernel/vm/Mutex.cpp +++ b/ndb/src/kernel/vm/Mutex.cpp @@ -19,48 +19,51 @@ #include "Mutex.hpp" #include <signaldata/UtilLock.hpp> -MutexManager::MutexManager(class SimulatedBlock & block) +SimulatedBlock::MutexManager::MutexManager(class SimulatedBlock & block) : m_block(block), m_activeMutexes(m_mutexPool) { } bool -MutexManager::setSize(Uint32 maxNoOfActiveMutexes){ +SimulatedBlock::MutexManager::setSize(Uint32 maxNoOfActiveMutexes){ return m_mutexPool.setSize(maxNoOfActiveMutexes); } Uint32 -MutexManager::getSize() const { +SimulatedBlock::MutexManager::getSize() const { return m_mutexPool.getSize(); } bool -MutexManager::seize(ActiveMutexPtr& ptr){ +SimulatedBlock::MutexManager::seize(ActiveMutexPtr& ptr){ return m_activeMutexes.seize(ptr); } void -MutexManager::release(Uint32 activeMutexPtrI){ +SimulatedBlock::MutexManager::release(Uint32 activeMutexPtrI){ m_activeMutexes.release(activeMutexPtrI); } void -MutexManager::getPtr(ActiveMutexPtr& ptr){ +SimulatedBlock::MutexManager::getPtr(ActiveMutexPtr& ptr){ m_activeMutexes.getPtr(ptr); } BlockReference -MutexManager::reference() const { +SimulatedBlock::MutexManager::reference() const { return m_block.reference(); } void -MutexManager::progError(int line, int err_code, const char* extra) { +SimulatedBlock::MutexManager::progError(int line, + int err_code, + const char* extra) +{ m_block.progError(line, err_code, extra); } void -MutexManager::create(Signal* signal, ActiveMutexPtr& ptr){ +SimulatedBlock::MutexManager::create(Signal* signal, ActiveMutexPtr& ptr){ UtilCreateLockReq * req = (UtilCreateLockReq*)signal->getDataPtrSend(); req->senderData = ptr.i; @@ -78,7 +81,7 @@ MutexManager::create(Signal* signal, ActiveMutexPtr& ptr){ } void -MutexManager::execUTIL_CREATE_LOCK_REF(Signal* signal){ +SimulatedBlock::MutexManager::execUTIL_CREATE_LOCK_REF(Signal* signal){ UtilCreateLockRef * ref = (UtilCreateLockRef*)signal->getDataPtr(); ActiveMutexPtr ptr; @@ -91,7 +94,7 @@ MutexManager::execUTIL_CREATE_LOCK_REF(Signal* signal){ } void -MutexManager::execUTIL_CREATE_LOCK_CONF(Signal* signal){ +SimulatedBlock::MutexManager::execUTIL_CREATE_LOCK_CONF(Signal* signal){ UtilCreateLockConf * conf = (UtilCreateLockConf*)signal->getDataPtr(); ActiveMutexPtr ptr; @@ -105,7 +108,7 @@ MutexManager::execUTIL_CREATE_LOCK_CONF(Signal* signal){ void -MutexManager::destroy(Signal* signal, ActiveMutexPtr& ptr){ +SimulatedBlock::MutexManager::destroy(Signal* signal, ActiveMutexPtr& ptr){ UtilDestroyLockReq * req = (UtilDestroyLockReq*)signal->getDataPtrSend(); req->senderData = ptr.i; @@ -123,7 +126,7 @@ MutexManager::destroy(Signal* signal, ActiveMutexPtr& ptr){ } void -MutexManager::execUTIL_DESTORY_LOCK_REF(Signal* signal){ +SimulatedBlock::MutexManager::execUTIL_DESTORY_LOCK_REF(Signal* signal){ UtilDestroyLockRef * ref = (UtilDestroyLockRef*)signal->getDataPtr(); ActiveMutexPtr ptr; m_activeMutexes.getPtr(ptr, ref->senderData); @@ -135,7 +138,7 @@ MutexManager::execUTIL_DESTORY_LOCK_REF(Signal* signal){ } void -MutexManager::execUTIL_DESTORY_LOCK_CONF(Signal* signal){ +SimulatedBlock::MutexManager::execUTIL_DESTORY_LOCK_CONF(Signal* signal){ UtilDestroyLockConf * conf = (UtilDestroyLockConf*)signal->getDataPtr(); ActiveMutexPtr ptr; m_activeMutexes.getPtr(ptr, conf->senderData); @@ -148,7 +151,7 @@ MutexManager::execUTIL_DESTORY_LOCK_CONF(Signal* signal){ void -MutexManager::lock(Signal* signal, ActiveMutexPtr& ptr){ +SimulatedBlock::MutexManager::lock(Signal* signal, ActiveMutexPtr& ptr){ UtilLockReq * req = (UtilLockReq*)signal->getDataPtrSend(); req->senderData = ptr.i; @@ -166,7 +169,7 @@ MutexManager::lock(Signal* signal, ActiveMutexPtr& ptr){ } void -MutexManager::trylock(Signal* signal, ActiveMutexPtr& ptr){ +SimulatedBlock::MutexManager::trylock(Signal* signal, ActiveMutexPtr& ptr){ UtilLockReq * req = (UtilLockReq*)signal->getDataPtrSend(); req->senderData = ptr.i; @@ -184,7 +187,7 @@ MutexManager::trylock(Signal* signal, ActiveMutexPtr& ptr){ } void -MutexManager::execUTIL_LOCK_REF(Signal* signal){ +SimulatedBlock::MutexManager::execUTIL_LOCK_REF(Signal* signal){ UtilLockRef * ref = (UtilLockRef*)signal->getDataPtr(); ActiveMutexPtr ptr; m_activeMutexes.getPtr(ptr, ref->senderData); @@ -196,7 +199,7 @@ MutexManager::execUTIL_LOCK_REF(Signal* signal){ } void -MutexManager::execUTIL_LOCK_CONF(Signal* signal){ +SimulatedBlock::MutexManager::execUTIL_LOCK_CONF(Signal* signal){ UtilLockConf * conf = (UtilLockConf*)signal->getDataPtr(); ActiveMutexPtr ptr; m_activeMutexes.getPtr(ptr, conf->senderData); @@ -210,7 +213,7 @@ MutexManager::execUTIL_LOCK_CONF(Signal* signal){ } void -MutexManager::unlock(Signal* signal, ActiveMutexPtr& ptr){ +SimulatedBlock::MutexManager::unlock(Signal* signal, ActiveMutexPtr& ptr){ UtilUnlockReq * req = (UtilUnlockReq*)signal->getDataPtrSend(); req->senderData = ptr.i; req->senderRef = m_block.reference(); @@ -227,7 +230,7 @@ MutexManager::unlock(Signal* signal, ActiveMutexPtr& ptr){ } void -MutexManager::execUTIL_UNLOCK_REF(Signal* signal){ +SimulatedBlock::MutexManager::execUTIL_UNLOCK_REF(Signal* signal){ UtilUnlockRef * ref = (UtilUnlockRef*)signal->getDataPtr(); ActiveMutexPtr ptr; m_activeMutexes.getPtr(ptr, ref->senderData); @@ -239,7 +242,7 @@ MutexManager::execUTIL_UNLOCK_REF(Signal* signal){ } void -MutexManager::execUTIL_UNLOCK_CONF(Signal* signal){ +SimulatedBlock::MutexManager::execUTIL_UNLOCK_CONF(Signal* signal){ UtilUnlockConf * conf = (UtilUnlockConf*)signal->getDataPtr(); ActiveMutexPtr ptr; m_activeMutexes.getPtr(ptr, conf->senderData); @@ -251,8 +254,9 @@ MutexManager::execUTIL_UNLOCK_CONF(Signal* signal){ } void -Mutex::release(MutexManager& mgr, Uint32 activePtrI, Uint32 mutexId){ - MutexManager::ActiveMutexPtr ptr; +Mutex::release(SimulatedBlock::MutexManager& mgr, + Uint32 activePtrI, Uint32 mutexId){ + SimulatedBlock::MutexManager::ActiveMutexPtr ptr; ptr.i = activePtrI; mgr.getPtr(ptr); if(ptr.p->m_gsn == 0 && ptr.p->m_mutexId == mutexId){ @@ -272,7 +276,8 @@ Mutex::unlock(){ if(!m_ptr.isNull()){ m_mgr.getPtr(m_ptr); if(m_ptr.p->m_mutexId == m_mutexId){ - Callback c = { &SimulatedBlock::ignoreMutexUnlockCallback, m_ptr.i }; + SimulatedBlock::Callback c = + { &SimulatedBlock::ignoreMutexUnlockCallback, m_ptr.i }; m_ptr.p->m_callback = c; m_mgr.unlock(m_signal, m_ptr); m_ptr.setNull(); // Remove reference diff --git a/ndb/src/kernel/vm/Mutex.hpp b/ndb/src/kernel/vm/Mutex.hpp index 40e3fb56b4f..7a16046188c 100644 --- a/ndb/src/kernel/vm/Mutex.hpp +++ b/ndb/src/kernel/vm/Mutex.hpp @@ -22,63 +22,6 @@ class Mutex; -class MutexManager { - friend class Mutex; - friend class SimulatedBlock; - friend class DbUtil; -public: - MutexManager(class SimulatedBlock &); - - bool setSize(Uint32 maxNoOfActiveMutexes); - Uint32 getSize() const ; // Get maxNoOfActiveMutexes - -private: - /** - * core interface - */ - struct ActiveMutex { - Uint32 m_gsn; // state - Uint32 m_mutexId; - Uint32 m_mutexKey; - Callback m_callback; - union { - Uint32 nextPool; - Uint32 nextList; - }; - Uint32 prevList; - }; - typedef Ptr<ActiveMutex> ActiveMutexPtr; - - bool seize(ActiveMutexPtr& ptr); - void release(Uint32 activeMutexPtrI); - - void getPtr(ActiveMutexPtr& ptr); - - void create(Signal*, ActiveMutexPtr&); - void destroy(Signal*, ActiveMutexPtr&); - void lock(Signal*, ActiveMutexPtr&); - void trylock(Signal*, ActiveMutexPtr&); - void unlock(Signal*, ActiveMutexPtr&); - -private: - void execUTIL_CREATE_LOCK_REF(Signal* signal); - void execUTIL_CREATE_LOCK_CONF(Signal* signal); - void execUTIL_DESTORY_LOCK_REF(Signal* signal); - void execUTIL_DESTORY_LOCK_CONF(Signal* signal); - void execUTIL_LOCK_REF(Signal* signal); - void execUTIL_LOCK_CONF(Signal* signal); - void execUTIL_UNLOCK_REF(Signal* signal); - void execUTIL_UNLOCK_CONF(Signal* signal); - - SimulatedBlock & m_block; - ArrayPool<ActiveMutex> m_mutexPool; - DLList<ActiveMutex> m_activeMutexes; - - BlockReference reference() const; - void progError(int line, int err_code, const char* extra = 0); -}; - - /** * MutexHandle - A "reference" to a mutex * - Should be used together with Mutex @@ -89,7 +32,7 @@ public: MutexHandle(Uint32 id); bool isNull() const; - void release(MutexManager & mgr); + void release(SimulatedBlock::MutexManager & mgr); private: const Uint32 m_mutexId; @@ -106,7 +49,7 @@ public: MutexHandle2(); bool isNull() const; - void release(MutexManager & mgr); + void release(SimulatedBlock::MutexManager & mgr); private: Uint32 m_activeMutexPtrI; @@ -117,33 +60,34 @@ private: */ class Mutex { public: - Mutex(Signal*, MutexManager & mgr, MutexHandle &); + Mutex(Signal*, SimulatedBlock::MutexManager & mgr, MutexHandle &); template<Uint32 MutexId> - Mutex(Signal*, MutexManager & mgr, MutexHandle2<MutexId> &); + Mutex(Signal*, SimulatedBlock::MutexManager & mgr, MutexHandle2<MutexId> &); ~Mutex(); void release(); bool isNull() const ; - bool lock(Callback & callback); - bool trylock(Callback & callback); - void unlock(Callback & callback); + bool lock(SimulatedBlock::Callback & callback); + bool trylock(SimulatedBlock::Callback & callback); + void unlock(SimulatedBlock::Callback & callback); void unlock(); // Ignore callback - bool create(Callback & callback); - bool destroy(Callback & callback); + bool create(SimulatedBlock::Callback & callback); + bool destroy(SimulatedBlock::Callback & callback); private: Signal* m_signal; - MutexManager & m_mgr; + SimulatedBlock::MutexManager & m_mgr; const Uint32 m_mutexId; Uint32 & m_srcPtrI; - MutexManager::ActiveMutexPtr m_ptr; + SimulatedBlock::MutexManager::ActiveMutexPtr m_ptr; public: - static void release(MutexManager&, Uint32 activePtrI, Uint32 mutexId); + static void release(SimulatedBlock::MutexManager&, + Uint32 activePtrI, Uint32 mutexId); }; inline @@ -159,7 +103,7 @@ MutexHandle::isNull() const { inline void -MutexHandle::release(MutexManager & mgr){ +MutexHandle::release(SimulatedBlock::MutexManager & mgr){ if(!isNull()){ Mutex::release(mgr, m_activeMutexPtrI, m_mutexId); m_activeMutexPtrI = RNIL; @@ -183,7 +127,7 @@ MutexHandle2<MutexId>::isNull() const { template<Uint32 MutexId> inline void -MutexHandle2<MutexId>::release(MutexManager & mgr){ +MutexHandle2<MutexId>::release(SimulatedBlock::MutexManager & mgr){ if(!isNull()){ Mutex::release(mgr, m_activeMutexPtrI, MutexId); m_activeMutexPtrI = RNIL; @@ -192,7 +136,8 @@ MutexHandle2<MutexId>::release(MutexManager & mgr){ inline -Mutex::Mutex(Signal* signal, MutexManager & mgr, MutexHandle & mh) +Mutex::Mutex(Signal* signal, SimulatedBlock::MutexManager & mgr, + MutexHandle & mh) : m_signal(signal), m_mgr(mgr), m_mutexId(mh.m_mutexId), @@ -204,7 +149,8 @@ Mutex::Mutex(Signal* signal, MutexManager & mgr, MutexHandle & mh) template<Uint32 MutexId> inline -Mutex::Mutex(Signal* signal, MutexManager & mgr, MutexHandle2<MutexId> & mh) +Mutex::Mutex(Signal* signal, SimulatedBlock::MutexManager & mgr, + MutexHandle2<MutexId> & mh) : m_signal(signal), m_mgr(mgr), m_mutexId(MutexId), @@ -236,7 +182,7 @@ Mutex::isNull() const { inline bool -Mutex::lock(Callback & callback){ +Mutex::lock(SimulatedBlock::Callback & callback){ if(m_ptr.isNull()){ if(m_mgr.seize(m_ptr)){ m_ptr.p->m_mutexId = m_mutexId; @@ -253,7 +199,7 @@ Mutex::lock(Callback & callback){ inline bool -Mutex::trylock(Callback & callback){ +Mutex::trylock(SimulatedBlock::Callback & callback){ if(m_ptr.isNull()){ if(m_mgr.seize(m_ptr)){ m_ptr.p->m_mutexId = m_mutexId; @@ -270,7 +216,7 @@ Mutex::trylock(Callback & callback){ inline void -Mutex::unlock(Callback & callback){ +Mutex::unlock(SimulatedBlock::Callback & callback){ if(!m_ptr.isNull()){ m_mgr.getPtr(m_ptr); if(m_ptr.p->m_mutexId == m_mutexId){ @@ -285,7 +231,7 @@ Mutex::unlock(Callback & callback){ inline bool -Mutex::create(Callback & callback){ +Mutex::create(SimulatedBlock::Callback & callback){ if(m_ptr.isNull()){ if(m_mgr.seize(m_ptr)){ m_ptr.p->m_mutexId = m_mutexId; @@ -302,7 +248,7 @@ Mutex::create(Callback & callback){ inline bool -Mutex::destroy(Callback & callback){ +Mutex::destroy(SimulatedBlock::Callback & callback){ if(m_ptr.isNull()){ if(m_mgr.seize(m_ptr)){ m_ptr.p->m_mutexId = m_mutexId; diff --git a/ndb/src/kernel/vm/SectionReader.cpp b/ndb/src/kernel/vm/SectionReader.cpp index 9e1cbc855e6..dd474a49e50 100644 --- a/ndb/src/kernel/vm/SectionReader.cpp +++ b/ndb/src/kernel/vm/SectionReader.cpp @@ -26,7 +26,7 @@ #endif SectionReader::SectionReader -(class SegmentedSectionPtr & ptr, class SectionSegmentPool & pool) +(struct SegmentedSectionPtr & ptr, class SectionSegmentPool & pool) : m_pool(pool) { if(ptr.p == 0){ diff --git a/ndb/src/kernel/vm/SectionReader.hpp b/ndb/src/kernel/vm/SectionReader.hpp index 17eade24a66..b51006b6128 100644 --- a/ndb/src/kernel/vm/SectionReader.hpp +++ b/ndb/src/kernel/vm/SectionReader.hpp @@ -21,7 +21,7 @@ class SectionReader { public: - SectionReader(class SegmentedSectionPtr &, + SectionReader(struct SegmentedSectionPtr &, class SectionSegmentPool &); void reset(); diff --git a/ndb/src/kernel/vm/SimplePropertiesSection.cpp b/ndb/src/kernel/vm/SimplePropertiesSection.cpp index d442ff2e698..070563be36b 100644 --- a/ndb/src/kernel/vm/SimplePropertiesSection.cpp +++ b/ndb/src/kernel/vm/SimplePropertiesSection.cpp @@ -19,7 +19,7 @@ #include "LongSignal.hpp" SimplePropertiesSectionReader::SimplePropertiesSectionReader -(class SegmentedSectionPtr & ptr, class SectionSegmentPool & pool) +(struct SegmentedSectionPtr & ptr, class SectionSegmentPool & pool) : m_pool(pool) { if(ptr.p == 0){ @@ -190,7 +190,7 @@ SimplePropertiesSectionWriter::putWords(const Uint32 * src, Uint32 len){ } void -SimplePropertiesSectionWriter::getPtr(class SegmentedSectionPtr & dst){ +SimplePropertiesSectionWriter::getPtr(struct SegmentedSectionPtr & dst){ // Set last ptr and size if(m_pos >= 0){ dst.p = m_head; diff --git a/ndb/src/kernel/vm/SimulatedBlock.cpp b/ndb/src/kernel/vm/SimulatedBlock.cpp index e6b97771d36..94fd5769406 100644 --- a/ndb/src/kernel/vm/SimulatedBlock.cpp +++ b/ndb/src/kernel/vm/SimulatedBlock.cpp @@ -1598,7 +1598,7 @@ SimulatedBlock::sendFragmentedSignal(NodeReceiverGroup rg, } } -Callback SimulatedBlock::TheEmptyCallback = {0, 0}; +SimulatedBlock::Callback SimulatedBlock::TheEmptyCallback = {0, 0}; void SimulatedBlock::sendFragmentedSignal(BlockReference ref, diff --git a/ndb/src/kernel/vm/SimulatedBlock.hpp b/ndb/src/kernel/vm/SimulatedBlock.hpp index 7972cb39746..787d14ca5cb 100644 --- a/ndb/src/kernel/vm/SimulatedBlock.hpp +++ b/ndb/src/kernel/vm/SimulatedBlock.hpp @@ -36,12 +36,10 @@ #include <ErrorReporter.hpp> #include <ErrorHandlingMacros.hpp> -#include <new> #include "DLList.hpp" #include "ArrayPool.hpp" #include "DLHashTable.hpp" #include "Callback.hpp" -#include "Mutex.hpp" #include "SafeCounter.hpp" #include "MetaData.hpp" @@ -77,7 +75,6 @@ typedef struct NewVar } NewVARIABLE; /* 128 bits */ class SimulatedBlock { - friend class MutexManager; friend class SafeCounter; friend class SafeCounterManager; friend struct UpgradeStartup; @@ -104,6 +101,14 @@ public: * */ inline void executeFunction(GlobalSignalNumber gsn, Signal* signal); +public: + typedef void (SimulatedBlock::* CallbackFunction)(class Signal*, + Uint32 callbackData, + Uint32 returnCode); + struct Callback { + CallbackFunction m_callbackFunction; + Uint32 m_callbackData; + }; protected: static Callback TheEmptyCallback; void execute(Signal* signal, Callback & c, Uint32 returnCode); @@ -405,7 +410,64 @@ private: DLList<FragmentSendInfo> c_linearFragmentSendList; DLList<FragmentSendInfo> c_segmentedFragmentSendList; -public: +public: + class MutexManager { + friend class Mutex; + friend class SimulatedBlock; + friend class DbUtil; + public: + MutexManager(class SimulatedBlock &); + + bool setSize(Uint32 maxNoOfActiveMutexes); + Uint32 getSize() const ; // Get maxNoOfActiveMutexes + + private: + /** + * core interface + */ + struct ActiveMutex { + Uint32 m_gsn; // state + Uint32 m_mutexId; + Uint32 m_mutexKey; + Callback m_callback; + union { + Uint32 nextPool; + Uint32 nextList; + }; + Uint32 prevList; + }; + typedef Ptr<ActiveMutex> ActiveMutexPtr; + + bool seize(ActiveMutexPtr& ptr); + void release(Uint32 activeMutexPtrI); + + void getPtr(ActiveMutexPtr& ptr); + + void create(Signal*, ActiveMutexPtr&); + void destroy(Signal*, ActiveMutexPtr&); + void lock(Signal*, ActiveMutexPtr&); + void trylock(Signal*, ActiveMutexPtr&); + void unlock(Signal*, ActiveMutexPtr&); + + private: + void execUTIL_CREATE_LOCK_REF(Signal* signal); + void execUTIL_CREATE_LOCK_CONF(Signal* signal); + void execUTIL_DESTORY_LOCK_REF(Signal* signal); + void execUTIL_DESTORY_LOCK_CONF(Signal* signal); + void execUTIL_LOCK_REF(Signal* signal); + void execUTIL_LOCK_CONF(Signal* signal); + void execUTIL_UNLOCK_REF(Signal* signal); + void execUTIL_UNLOCK_CONF(Signal* signal); + + SimulatedBlock & m_block; + ArrayPool<ActiveMutex> m_mutexPool; + DLList<ActiveMutex> m_activeMutexes; + + BlockReference reference() const; + void progError(int line, int err_code, const char* extra = 0); + }; + + friend class MutexManager; MutexManager c_mutexMgr; void ignoreMutexUnlockCallback(Signal* signal, Uint32 ptrI, Uint32 retVal); @@ -688,5 +750,7 @@ BLOCK::addRecSignal(GlobalSignalNumber gsn, ExecSignalLocal f, bool force){ \ addRecSignalImpl(gsn, (ExecFunction)f, force);\ } +#include "Mutex.hpp" + #endif diff --git a/ndb/src/kernel/vm/ThreadConfig.cpp b/ndb/src/kernel/vm/ThreadConfig.cpp index 4844bb9a477..76fcc4ba84f 100644 --- a/ndb/src/kernel/vm/ThreadConfig.cpp +++ b/ndb/src/kernel/vm/ThreadConfig.cpp @@ -173,9 +173,6 @@ void ThreadConfig::ipControlLoop() // until all buffers are empty or until we have executed 2048 signals. //-------------------------------------------------------------------- globalScheduler.doJob(); - - globalScheduler.sendPacked(); - }//while globalData.incrementWatchDogCounter(6); diff --git a/ndb/src/kernel/vm/WatchDog.cpp b/ndb/src/kernel/vm/WatchDog.cpp index 4e07dc1df90..23475a478d3 100644 --- a/ndb/src/kernel/vm/WatchDog.cpp +++ b/ndb/src/kernel/vm/WatchDog.cpp @@ -27,10 +27,7 @@ extern "C" void* runWatchDog(void* w){ - my_thread_init(); ((WatchDog*)w)->run(); - my_thread_end(); - NdbThread_Exit(0); return NULL; } diff --git a/ndb/src/common/mgmcommon/LocalConfig.cpp b/ndb/src/mgmapi/LocalConfig.cpp index 3cd4341c6b7..0265f982df3 100644 --- a/ndb/src/common/mgmcommon/LocalConfig.cpp +++ b/ndb/src/mgmapi/LocalConfig.cpp @@ -90,7 +90,7 @@ LocalConfig::init(const char *connectString, //7. Check { char buf[256]; - BaseString::snprintf(buf, sizeof(buf), "host=localhost:%s", NDB_BASE_PORT); + BaseString::snprintf(buf, sizeof(buf), "host=localhost:%s", NDB_PORT); if(readConnectString(buf, "default connect string")) return true; } @@ -124,12 +124,12 @@ void LocalConfig::printUsage() const { ndbout << "1. Put a Ndb.cfg file in the directory where you start"<<endl << " the node. "<< endl << " Ex: Ndb.cfg" << endl - << " | host=localhost:"<<NDB_BASE_PORT<<endl; + << " | host=localhost:"<<NDB_PORT<<endl; ndbout << "2. Use the environment variable NDB_CONNECTSTRING to "<<endl << " provide this information." <<endl << " Ex: " << endl - << " >export NDB_CONNECTSTRING=\"host=localhost:"<<NDB_BASE_PORT<<"\"" + << " >export NDB_CONNECTSTRING=\"host=localhost:"<<NDB_PORT<<"\"" <<endl<<endl; } @@ -164,17 +164,25 @@ LocalConfig::parseNodeId(const char * buf){ bool LocalConfig::parseHostName(const char * buf){ char tempString[1024]; + char tempString2[1024]; int port; - for(int i = 0; hostNameTokens[i] != 0; i++) { - if (sscanf(buf, hostNameTokens[i], tempString, &port) == 2) { - MgmtSrvrId mgmtSrvrId; - mgmtSrvrId.type = MgmId_TCP; - mgmtSrvrId.name.assign(tempString); - mgmtSrvrId.port = port; - ids.push_back(mgmtSrvrId); - return true; + do { + for(int i = 0; hostNameTokens[i] != 0; i++) { + if (sscanf(buf, hostNameTokens[i], tempString, &port) == 2) { + MgmtSrvrId mgmtSrvrId; + mgmtSrvrId.type = MgmId_TCP; + mgmtSrvrId.name.assign(tempString); + mgmtSrvrId.port = port; + ids.push_back(mgmtSrvrId); + return true; + } } - } + if (buf == tempString2) + break; + // try to add default port to see if it works + snprintf(tempString2, sizeof(tempString2),"%s:%s", buf, NDB_PORT); + buf= tempString2; + } while(1); return false; } @@ -218,7 +226,13 @@ LocalConfig::parseString(const char * connectString, BaseString &err){ return false; } - if (!found_other) { + if (b_nodeId && !found_other) + { + BaseString tmp; + tmp.assfmt("host=localhost:%s", NDB_PORT); + if(parseHostName(tmp.c_str())) + return true; + err.appfmt("Missing host/file name extry in \"%s\"", connectString); return false; } @@ -286,4 +300,27 @@ LocalConfig::readConnectString(const char * connectString, return return_value; } +char * +LocalConfig::makeConnectString(char *buf, int sz) +{ + int p= BaseString::snprintf(buf,sz,"nodeid=%d", _ownNodeId); + if (p < sz) + for (unsigned i = 0; i < ids.size(); i++) + { + if (ids[i].type != MgmId_TCP) + continue; + int new_p= p+BaseString::snprintf(buf+p,sz-p,",%s:%d", + ids[i].name.c_str(), ids[i].port); + if (new_p < sz) + p= new_p; + else + { + buf[p]= 0; + break; + } + } + buf[sz-1]=0; + return buf; +} + template class Vector<MgmtSrvrId>; diff --git a/ndb/include/mgmcommon/LocalConfig.hpp b/ndb/src/mgmapi/LocalConfig.hpp index 9ceeffdba36..c415ec1be91 100644 --- a/ndb/include/mgmcommon/LocalConfig.hpp +++ b/ndb/src/mgmapi/LocalConfig.hpp @@ -61,6 +61,7 @@ struct LocalConfig { bool parseHostName(const char *buf); bool parseFileName(const char *buf); bool parseString(const char *buf, BaseString &err); + char * makeConnectString(char *buf, int sz); }; #endif // LocalConfig_H diff --git a/ndb/src/mgmapi/Makefile.am b/ndb/src/mgmapi/Makefile.am index 0f0e1cea5d8..2f2fb407e46 100644 --- a/ndb/src/mgmapi/Makefile.am +++ b/ndb/src/mgmapi/Makefile.am @@ -1,10 +1,11 @@ noinst_LTLIBRARIES = libmgmapi.la -libmgmapi_la_SOURCES = mgmapi.cpp mgmapi_configuration.cpp +libmgmapi_la_SOURCES = mgmapi.cpp mgmapi_configuration.cpp LocalConfig.cpp -INCLUDES_LOC = -I$(top_srcdir)/ndb/include/mgmapi -I$(top_srcdir)/ndb/src/common/mgmcommon -DEFS_LOC = -DNO_DEBUG_MESSAGES +INCLUDES_LOC = -I$(top_srcdir)/ndb/include/mgmapi + +DEFS_LOC = -DNO_DEBUG_MESSAGES -DNDB_PORT="\"@ndb_port@\"" include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_util.mk.am @@ -13,3 +14,17 @@ include $(top_srcdir)/ndb/config/type_util.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libmgmapi.dsp + +libmgmapi.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libmgmapi_la_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/mgmapi/Makefile_old b/ndb/src/mgmapi/Makefile_old deleted file mode 100644 index fa734f998e6..00000000000 --- a/ndb/src/mgmapi/Makefile_old +++ /dev/null @@ -1,27 +0,0 @@ -include .defs.mk - -TYPE := util - -PIC_ARCHIVE := Y -ARCHIVE_TARGET := mgmapi - -A_LIB := Y -SO_LIB := Y -PIC_LIB := Y - -#DIRS := test - -LIB_TARGET := MGM_API -LIB_TARGET_ARCHIVES := $(ARCHIVE_TARGET) general portlib - -# Source files of non-templated classes (.C files) -SOURCES = mgmapi.cpp mgmapi_configuration.cpp - -CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/include/mgmapi) \ - -I$(call fixpath,$(NDB_TOP)/src/common/mgmcommon) - -CCFLAGS += -DNO_DEBUG_MESSAGES - -# -I$(NDB_TOP)/src/common/mgmcommon - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/src/mgmapi/mgmapi.cpp b/ndb/src/mgmapi/mgmapi.cpp index 4b62df968b3..68106c4689d 100644 --- a/ndb/src/mgmapi/mgmapi.cpp +++ b/ndb/src/mgmapi/mgmapi.cpp @@ -17,8 +17,10 @@ #include <ndb_global.h> #include <my_sys.h> +#include <LocalConfig.hpp> #include <NdbAutoPtr.hpp> +#include <NdbSleep.h> #include <NdbTCP.h> #include "mgmapi.h" #include "mgmapi_debug.h" @@ -82,8 +84,7 @@ typedef Parser<ParserDummy> Parser_t; #define NDB_MGM_MAX_ERR_DESC_SIZE 256 struct ndb_mgm_handle { - char * hostname; - unsigned short port; + int cfg_i; int connected; int last_error; @@ -94,6 +95,8 @@ struct ndb_mgm_handle { NDB_SOCKET_TYPE socket; + LocalConfig cfg; + #ifdef MGMAPI_LOG FILE* logfile; #endif @@ -145,12 +148,16 @@ ndb_mgm_create_handle() h->connected = 0; h->last_error = 0; h->last_error_line = 0; - h->hostname = 0; - h->socket = -1; + h->socket = NDB_INVALID_SOCKET; h->read_timeout = 50000; h->write_timeout = 100; + h->cfg_i = 0; strncpy(h->last_error_desc, "No error", NDB_MGM_MAX_ERR_DESC_SIZE); + + new (&(h->cfg)) LocalConfig; + h->cfg.init(0, 0); + #ifdef MGMAPI_LOG h->logfile = 0; #endif @@ -158,6 +165,23 @@ ndb_mgm_create_handle() return h; } +extern "C" +int +ndb_mgm_set_connectstring(NdbMgmHandle handle, const char * mgmsrv) +{ + new (&(handle->cfg)) LocalConfig; + if (!handle->cfg.init(mgmsrv, 0) || + handle->cfg.ids.size() == 0) + { + new (&(handle->cfg)) LocalConfig; + handle->cfg.init(0, 0); /* reset the LocalCongig */ + SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, ""); + return -1; + } + handle->cfg_i= 0; + return 0; +} + /** * Destroy a handle */ @@ -170,13 +194,13 @@ ndb_mgm_destroy_handle(NdbMgmHandle * handle) if((* handle)->connected){ ndb_mgm_disconnect(* handle); } - my_free((* handle)->hostname,MYF(MY_ALLOW_ZERO_PTR)); #ifdef MGMAPI_LOG if ((* handle)->logfile != 0){ fclose((* handle)->logfile); (* handle)->logfile = 0; } #endif + (*handle)->cfg.~LocalConfig(); my_free((char*)* handle,MYF(MY_ALLOW_ZERO_PTR)); * handle = 0; } @@ -220,42 +244,6 @@ ndb_mgm_get_latest_error_msg(const NdbMgmHandle h) return "Error"; // Unknown Error message } -static -int -parse_connect_string(const char * connect_string, - NdbMgmHandle handle) -{ - if(connect_string == 0){ - SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, ""); - return -1; - } - - char * line = my_strdup(connect_string,MYF(MY_WME)); - My_auto_ptr<char> ap1(line); - if(line == 0){ - SET_ERROR(handle, NDB_MGM_OUT_OF_MEMORY, ""); - return -1; - } - - char * tmp = strchr(line, ':'); - if(tmp == 0){ - SET_ERROR(handle, NDB_MGM_OUT_OF_MEMORY, ""); - return -1; - } - * tmp = 0; tmp++; - - int port = 0; - if(sscanf(tmp, "%d", &port) != 1){ - SET_ERROR(handle, NDB_MGM_ILLEGAL_PORT_NUMBER, ""); - return -1; - } - - my_free(handle->hostname,MYF(MY_ALLOW_ZERO_PTR)); - handle->hostname = my_strdup(line,MYF(MY_WME)); - handle->port = port; - return 0; -} - /* * Call an operation, and return the reply */ @@ -344,15 +332,11 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply, */ extern "C" int -ndb_mgm_connect(NdbMgmHandle handle, const char * mgmsrv) +ndb_mgm_connect(NdbMgmHandle handle, int no_retries, + int retry_delay_in_seconds, int verbose) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_connect"); CHECK_HANDLE(handle, -1); - - if(parse_connect_string(mgmsrv, handle) != 0) { - SET_ERROR(handle, NDB_MGM_ILLEGAL_CONNECT_STRING, ""); - return -1; - } #ifdef MGMAPI_LOG /** @@ -366,14 +350,61 @@ ndb_mgm_connect(NdbMgmHandle handle, const char * mgmsrv) /** * Do connect */ - SocketClient s(handle->hostname, handle->port); - const NDB_SOCKET_TYPE sockfd = s.connect(); - if (sockfd < 0) { - setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, - "Unable to connect to %s", mgmsrv); - return -1; + LocalConfig &cfg= handle->cfg; + NDB_SOCKET_TYPE sockfd= NDB_INVALID_SOCKET; + Uint32 i; + while (sockfd == NDB_INVALID_SOCKET) + { + // do all the mgmt servers + for (i = 0; i < cfg.ids.size(); i++) + { + if (cfg.ids[i].type != MgmId_TCP) + continue; + SocketClient s(cfg.ids[i].name.c_str(), cfg.ids[i].port); + sockfd = s.connect(); + if (sockfd != NDB_INVALID_SOCKET) + break; + } + if (sockfd != NDB_INVALID_SOCKET) + break; + if (verbose > 0) { + char buf[1024]; + ndbout_c("Unable to connect with connect string: %s", + cfg.makeConnectString(buf,sizeof(buf))); + verbose= -1; + } + if (no_retries == 0) { + char buf[1024]; + setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, + "Unable to connect with connect string: %s", + cfg.makeConnectString(buf,sizeof(buf))); + if (verbose == -2) + ndbout << ", failed." << endl; + return -1; + } + if (verbose == -1) { + ndbout << "Retrying every " << retry_delay_in_seconds << " seconds"; + if (no_retries > 0) + ndbout << ". Attempts left:"; + else + ndbout << ", until connected.";; + ndbout << flush; + verbose= -2; + } + if (no_retries > 0) { + if (verbose == -2) { + ndbout << " " << no_retries; + ndbout << flush; + } + no_retries--; + } + NdbSleep_SecSleep(retry_delay_in_seconds); } - + if (verbose == -2) + ndbout << endl; + + handle->cfg_i = i; + handle->socket = sockfd; handle->connected = 1; @@ -392,7 +423,7 @@ ndb_mgm_disconnect(NdbMgmHandle handle) CHECK_CONNECTED(handle, -1); NDB_CLOSE_SOCKET(handle->socket); - handle->socket = -1; + handle->socket = NDB_INVALID_SOCKET; handle->connected = 0; return 0; @@ -543,7 +574,9 @@ cmp_state(const void *_a, const void *_b) a = (struct ndb_mgm_node_state *)_a; b = (struct ndb_mgm_node_state *)_b; - return a->node_id > b->node_id; + if (a->node_id > b->node_id) + return 1; + return -1; } extern "C" @@ -881,21 +914,67 @@ ndb_mgm_restart(NdbMgmHandle handle, int no_of_nodes, const int *node_list) return ndb_mgm_restart2(handle, no_of_nodes, node_list, 0, 0, 0); } +static const char *clusterlog_level_names[]= + { "enabled", "debug", "info", "warning", "error", "critical", "alert" }; + +struct ndb_mgm_clusterlog_levels +{ + const char* name; + enum ndb_mgm_clusterlog_level level; +} clusterlog_levels[] = { + { clusterlog_level_names[0], NDB_MGM_CLUSTERLOG_ON }, + { clusterlog_level_names[1], NDB_MGM_CLUSTERLOG_DEBUG }, + { clusterlog_level_names[2], NDB_MGM_CLUSTERLOG_INFO }, + { clusterlog_level_names[3], NDB_MGM_CLUSTERLOG_WARNING }, + { clusterlog_level_names[4], NDB_MGM_CLUSTERLOG_ERROR }, + { clusterlog_level_names[5], NDB_MGM_CLUSTERLOG_CRITICAL }, + { clusterlog_level_names[6], NDB_MGM_CLUSTERLOG_ALERT }, + { "all", NDB_MGM_CLUSTERLOG_ALL }, + { 0, NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL }, +}; + +extern "C" +ndb_mgm_clusterlog_level +ndb_mgm_match_clusterlog_level(const char * name) +{ + if(name == 0) + return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL; + + for(int i = 0; clusterlog_levels[i].name !=0 ; i++) + if(strcasecmp(name, clusterlog_levels[i].name) == 0) + return clusterlog_levels[i].level; + + return NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL; +} + +extern "C" +const char * +ndb_mgm_get_clusterlog_level_string(enum ndb_mgm_clusterlog_level level) +{ + int i= (int)level; + if (i >= 0 && i < (int)NDB_MGM_CLUSTERLOG_ALL) + return clusterlog_level_names[i]; + for(i = (int)NDB_MGM_CLUSTERLOG_ALL; clusterlog_levels[i].name != 0; i++) + if(clusterlog_levels[i].level == level) + return clusterlog_levels[i].name; + return 0; +} + extern "C" unsigned int * ndb_mgm_get_logfilter(NdbMgmHandle handle) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_get_logfilter"); - static Uint32 enabled[7] = {0,0,0,0,0,0,0}; + static Uint32 enabled[(int)NDB_MGM_CLUSTERLOG_ALL] = {0,0,0,0,0,0,0}; const ParserRow<ParserDummy> getinfo_reply[] = { MGM_CMD("clusterlog", NULL, ""), - MGM_ARG("enabled", Int, Mandatory, ""), - MGM_ARG("debug", Int, Mandatory, ""), - MGM_ARG("info", Int, Mandatory, ""), - MGM_ARG("warning", Int, Mandatory, ""), - MGM_ARG("error", Int, Mandatory, ""), - MGM_ARG("critical", Int, Mandatory, ""), - MGM_ARG("alert", Int, Mandatory, ""), + MGM_ARG(clusterlog_level_names[0], Int, Mandatory, ""), + MGM_ARG(clusterlog_level_names[1], Int, Mandatory, ""), + MGM_ARG(clusterlog_level_names[2], Int, Mandatory, ""), + MGM_ARG(clusterlog_level_names[3], Int, Mandatory, ""), + MGM_ARG(clusterlog_level_names[4], Int, Mandatory, ""), + MGM_ARG(clusterlog_level_names[5], Int, Mandatory, ""), + MGM_ARG(clusterlog_level_names[6], Int, Mandatory, ""), }; CHECK_HANDLE(handle, NULL); CHECK_CONNECTED(handle, NULL); @@ -905,10 +984,8 @@ ndb_mgm_get_logfilter(NdbMgmHandle handle) reply = ndb_mgm_call(handle, getinfo_reply, "get info clusterlog", &args); CHECK_REPLY(reply, NULL); - const char *names[] = { "enabled", "debug", "info", "warning", "error", - "critical", "alert" }; - for(int i=0; i < 7; i++) { - reply->get(names[i], &enabled[i]); + for(int i=0; i < (int)NDB_MGM_CLUSTERLOG_ALL; i++) { + reply->get(clusterlog_level_names[i], &enabled[i]); } return enabled; } @@ -917,6 +994,7 @@ extern "C" int ndb_mgm_filter_clusterlog(NdbMgmHandle handle, enum ndb_mgm_clusterlog_level level, + int enable, struct ndb_mgm_reply* /*reply*/) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_filter_clusterlog"); @@ -931,6 +1009,7 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle, Properties args; args.put("level", level); + args.put("enable", enable); const Properties *reply; reply = ndb_mgm_call(handle, filter_reply, "set logfilter", &args); @@ -938,11 +1017,14 @@ ndb_mgm_filter_clusterlog(NdbMgmHandle handle, BaseString result; reply->get("result", result); - if(strcmp(result.c_str(), "1") == 0) { + + if (strcmp(result.c_str(), "1") == 0) + retval = 1; + else if (strcmp(result.c_str(), "0") == 0) retval = 0; - } else { + else + { SET_ERROR(handle, EINVAL, result.c_str()); - retval = -1; } delete reply; return retval; @@ -1020,15 +1102,18 @@ ndb_mgm_set_loglevel_clusterlog(NdbMgmHandle handle, int nodeId, "set cluster loglevel", &args); CHECK_REPLY(reply, -1); + DBUG_ENTER("ndb_mgm_set_loglevel_clusterlog"); + DBUG_PRINT("enter",("node=%d, category=%d, level=%d", nodeId, cat, level)); + BaseString result; reply->get("result", result); if(strcmp(result.c_str(), "Ok") != 0) { SET_ERROR(handle, EINVAL, result.c_str()); delete reply; - return -1; + DBUG_RETURN(-1); } delete reply; - return 0; + DBUG_RETURN(0); } extern "C" @@ -1080,9 +1165,11 @@ ndb_mgm_listen_event(NdbMgmHandle handle, int filter[]) }; CHECK_HANDLE(handle, -1); - SocketClient s(handle->hostname, handle->port); + const char *hostname= ndb_mgm_get_connected_host(handle); + int port= ndb_mgm_get_connected_port(handle); + SocketClient s(hostname, port); const NDB_SOCKET_TYPE sockfd = s.connect(); - if (sockfd < 0) { + if (sockfd == NDB_INVALID_SOCKET) { setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, "Unable to connect to"); return -1; @@ -1458,7 +1545,8 @@ ndb_mgm_start(NdbMgmHandle handle, int no_of_nodes, const int * node_list) *****************************************************************************/ extern "C" int -ndb_mgm_start_backup(NdbMgmHandle handle, unsigned int* _backup_id, +ndb_mgm_start_backup(NdbMgmHandle handle, int wait_completed, + unsigned int* _backup_id, struct ndb_mgm_reply* /*reply*/) { SET_ERROR(handle, NDB_MGM_NO_ERROR, "Executing: ndb_mgm_start_backup"); @@ -1472,8 +1560,17 @@ ndb_mgm_start_backup(NdbMgmHandle handle, unsigned int* _backup_id, CHECK_CONNECTED(handle, -1); Properties args; + args.put("completed", wait_completed); const Properties *reply; - reply = ndb_mgm_call(handle, start_backup_reply, "start backup", &args); + { // start backup can take some time, set timeout high + Uint64 old_timeout= handle->read_timeout; + if (wait_completed == 2) + handle->read_timeout= 30*60*1000; // 30 minutes + else if (wait_completed == 1) + handle->read_timeout= 5*60*1000; // 5 minutes + reply = ndb_mgm_call(handle, start_backup_reply, "start backup", &args); + handle->read_timeout= old_timeout; + } CHECK_REPLY(reply, -1); BaseString result; @@ -1625,19 +1722,59 @@ ndb_mgm_destroy_configuration(struct ndb_mgm_configuration *cfg) extern "C" int -ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, unsigned *pnodeid, int nodetype) +ndb_mgm_set_configuration_nodeid(NdbMgmHandle handle, int nodeid) { + CHECK_HANDLE(handle, -1); + handle->cfg._ownNodeId= nodeid; + return 0; +} +extern "C" +int +ndb_mgm_get_configuration_nodeid(NdbMgmHandle handle) +{ + CHECK_HANDLE(handle, 0); + return handle->cfg._ownNodeId; +} + +extern "C" +int ndb_mgm_get_connected_port(NdbMgmHandle handle) +{ + return handle->cfg.ids[handle->cfg_i].port; +} + +extern "C" +const char *ndb_mgm_get_connected_host(NdbMgmHandle handle) +{ + return handle->cfg.ids[handle->cfg_i].name.c_str(); +} + +extern "C" +const char *ndb_mgm_get_connectstring(NdbMgmHandle handle, char *buf, int buf_sz) +{ + return handle->cfg.makeConnectString(buf,buf_sz); +} + +extern "C" +int +ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, int nodetype) +{ CHECK_HANDLE(handle, 0); CHECK_CONNECTED(handle, 0); + union { long l; char c[sizeof(long)]; } endian_check; + + endian_check.l = 1; + + int nodeid= handle->cfg._ownNodeId; Properties args; args.put("version", version); args.put("nodetype", nodetype); - args.put("nodeid", *pnodeid); + args.put("nodeid", nodeid); args.put("user", "mysqld"); args.put("password", "mysqld"); args.put("public key", "a public key"); + args.put("endian", (endian_check.c[sizeof(long)-1])?"big":"little"); const ParserRow<ParserDummy> reply[]= { MGM_CMD("get nodeid reply", NULL, ""), @@ -1650,26 +1787,29 @@ ndb_mgm_alloc_nodeid(NdbMgmHandle handle, unsigned int version, unsigned *pnodei prop= ndb_mgm_call(handle, reply, "get nodeid", &args); CHECK_REPLY(prop, -1); - int res= -1; + nodeid= -1; do { const char * buf; if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){ + const char *hostname= ndb_mgm_get_connected_host(handle); + unsigned port= ndb_mgm_get_connected_port(handle); BaseString err; err.assfmt("Could not alloc node id at %s port %d: %s", - handle->hostname, handle->port, buf); + hostname, port, buf); setError(handle, NDB_MGM_COULD_NOT_CONNECT_TO_SOCKET, __LINE__, err.c_str()); break; } - if(!prop->get("nodeid", pnodeid) != 0){ + Uint32 _nodeid; + if(!prop->get("nodeid", &_nodeid) != 0){ ndbout_c("ERROR Message: <nodeid Unspecified>\n"); break; } - res= 0; + nodeid= _nodeid; }while(0); delete prop; - return res; + return nodeid; } /***************************************************************************** @@ -1834,4 +1974,80 @@ ndb_mgm_set_string_parameter(NdbMgmHandle handle, return res; } +extern "C" +int +ndb_mgm_purge_stale_sessions(NdbMgmHandle handle, char **purged){ + CHECK_HANDLE(handle, 0); + CHECK_CONNECTED(handle, 0); + + Properties args; + + const ParserRow<ParserDummy> reply[]= { + MGM_CMD("purge stale sessions reply", NULL, ""), + MGM_ARG("purged", String, Optional, ""), + MGM_ARG("result", String, Mandatory, "Error message"), + MGM_END() + }; + + const Properties *prop; + prop= ndb_mgm_call(handle, reply, "purge stale sessions", &args); + + if(prop == NULL) { + SET_ERROR(handle, EIO, "Unable to purge stale sessions"); + return -1; + } + + int res= -1; + do { + const char * buf; + if(!prop->get("result", &buf) || strcmp(buf, "Ok") != 0){ + ndbout_c("ERROR Message: %s\n", buf); + break; + } + if (purged) { + if (prop->get("purged", &buf)) + *purged= strdup(buf); + else + *purged= 0; + } + res= 0; + } while(0); + delete prop; + return res; +} + +extern "C" +int +ndb_mgm_check_connection(NdbMgmHandle handle){ + CHECK_HANDLE(handle, 0); + CHECK_CONNECTED(handle, 0); + SocketOutputStream out(handle->socket); + SocketInputStream in(handle->socket, handle->read_timeout); + char buf[32]; + + if (out.println("check connection")) + goto ndb_mgm_check_connection_error; + + if (out.println("")) + goto ndb_mgm_check_connection_error; + + in.gets(buf, sizeof(buf)); + if(strcmp("check connection reply\n", buf)) + goto ndb_mgm_check_connection_error; + + in.gets(buf, sizeof(buf)); + if(strcmp("result: Ok\n", buf)) + goto ndb_mgm_check_connection_error; + + in.gets(buf, sizeof(buf)); + if(strcmp("\n", buf)) + goto ndb_mgm_check_connection_error; + + return 0; + +ndb_mgm_check_connection_error: + ndb_mgm_disconnect(handle); + return -1; +} + template class Vector<const ParserRow<ParserDummy>*>; diff --git a/ndb/src/mgmapi/mgmapi_configuration.cpp b/ndb/src/mgmapi/mgmapi_configuration.cpp index ae7fe2c294c..80ab428c05a 100644 --- a/ndb/src/mgmapi/mgmapi_configuration.cpp +++ b/ndb/src/mgmapi/mgmapi_configuration.cpp @@ -1,6 +1,6 @@ +#include <ndb_types.h> #include <mgmapi.h> #include "mgmapi_configuration.hpp" -#include <new> ndb_mgm_configuration_iterator::ndb_mgm_configuration_iterator (const ndb_mgm_configuration & conf, unsigned type_of_section) @@ -138,7 +138,7 @@ ndb_mgm_get_int_parameter(const ndb_mgm_configuration_iterator* iter, extern "C" int ndb_mgm_get_int64_parameter(const ndb_mgm_configuration_iterator* iter, - int param, unsigned long long * value){ + int param, Uint64 * value){ return iter->get(param, value); } diff --git a/ndb/src/mgmapi/mgmapi_configuration.hpp b/ndb/src/mgmapi/mgmapi_configuration.hpp index c7feffd3a4e..9e94b3311bf 100644 --- a/ndb/src/mgmapi/mgmapi_configuration.hpp +++ b/ndb/src/mgmapi/mgmapi_configuration.hpp @@ -21,7 +21,7 @@ struct ndb_mgm_configuration_iterator { int find(int param, unsigned value); int get(int param, unsigned * value) const ; - int get(int param, unsigned long long * value) const ; + int get(int param, Uint64 * value) const ; int get(int param, const char ** value) const ; // diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index e0935c2104e..c3b0ee7fe97 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -17,7 +17,199 @@ #include <ndb_global.h> #include <my_sys.h> -#include "CommandInterpreter.hpp" +//#define HAVE_GLOBAL_REPLICATION + +#include <Vector.hpp> +#ifdef HAVE_GLOBAL_REPLICATION +#include "../rep/repapi/repapi.h" +#endif + +#include <mgmapi.h> + +class MgmtSrvr; + +/** + * @class CommandInterpreter + * @brief Reads command line in management client + * + * This class has one public method which reads a command line + * from a stream. It then interpret that commmand line and calls a suitable + * method in the MgmtSrvr class which executes the command. + * + * For command syntax, see the HELP command. + */ +class CommandInterpreter { +public: + /** + * Constructor + * @param mgmtSrvr: Management server to use when executing commands + */ + CommandInterpreter(const char *, int verbose); + ~CommandInterpreter(); + + /** + * Reads one line from the stream, parse the line to find + * a command and then calls a suitable method which executes + * the command. + * + * @return true until quit/bye/exit has been typed + */ + int execute(const char *_line, int _try_reconnect=-1, int *error= 0); + +private: + void printError(); + int execute_impl(const char *_line); + + /** + * Analyse the command line, after the first token. + * + * @param processId: DB process id to send command to or -1 if + * command will be sent to all DB processes. + * @param allAfterFirstToken: What the client gave after the + * first token on the command line + */ + void analyseAfterFirstToken(int processId, char* allAfterFirstTokenCstr); + + /** + * Parse the block specification part of the LOG* commands, + * things after LOG*: [BLOCK = {ALL|<blockName>+}] + * + * @param allAfterLog: What the client gave after the second token + * (LOG*) on the command line + * @param blocks, OUT: ALL or name of all the blocks + * @return: true if correct syntax, otherwise false + */ + bool parseBlockSpecification(const char* allAfterLog, + Vector<const char*>& blocks); + + /** + * A bunch of execute functions: Executes one of the commands + * + * @param processId: DB process id to send command to + * @param parameters: What the client gave after the command name + * on the command line. + * For example if complete input from user is: "1 LOGLEVEL 22" then the + * parameters argument is the string with everything after LOGLEVEL, in + * this case "22". Each function is responsible to check the parameters + * argument. + */ + void executeHelp(char* parameters); + void executeShow(char* parameters); + void executeConnect(char* parameters); + void executePurge(char* parameters); + int executeShutdown(char* parameters); + void executeRun(char* parameters); + void executeInfo(char* parameters); + void executeClusterLog(char* parameters); + +public: + void executeStop(int processId, const char* parameters, bool all); + void executeEnterSingleUser(char* parameters); + void executeExitSingleUser(char* parameters); + void executeStart(int processId, const char* parameters, bool all); + void executeRestart(int processId, const char* parameters, bool all); + void executeLogLevel(int processId, const char* parameters, bool all); + void executeError(int processId, const char* parameters, bool all); + void executeLog(int processId, const char* parameters, bool all); + void executeLogIn(int processId, const char* parameters, bool all); + void executeLogOut(int processId, const char* parameters, bool all); + void executeLogOff(int processId, const char* parameters, bool all); + void executeTestOn(int processId, const char* parameters, bool all); + void executeTestOff(int processId, const char* parameters, bool all); + void executeSet(int processId, const char* parameters, bool all); + void executeGetStat(int processId, const char* parameters, bool all); + void executeStatus(int processId, const char* parameters, bool all); + void executeEventReporting(int processId, const char* parameters, bool all); + void executeDumpState(int processId, const char* parameters, bool all); + int executeStartBackup(char * parameters); + void executeAbortBackup(char * parameters); + + void executeRep(char* parameters); + + void executeCpc(char * parameters); + +public: + bool connect(); + bool disconnect(); + + /** + * A execute function definition + */ +public: + typedef void (CommandInterpreter::* ExecuteFunction)(int processId, + const char * param, + bool all); + + struct CommandFunctionPair { + const char * command; + ExecuteFunction executeFunction; + }; +private: + /** + * + */ + void executeForAll(const char * cmd, + ExecuteFunction fun, + const char * param); + + NdbMgmHandle m_mgmsrv; + NdbMgmHandle m_mgmsrv2; + bool m_connected; + int m_verbose; + int try_reconnect; + int m_error; +#ifdef HAVE_GLOBAL_REPLICATION + NdbRepHandle m_repserver; + const char *rep_host; + bool rep_connected; +#endif + struct NdbThread* m_event_thread; +}; + + +/* + * Facade object for CommandInterpreter + */ + +#include "ndb_mgmclient.hpp" +#include "ndb_mgmclient.h" + +Ndb_mgmclient::Ndb_mgmclient(const char *host,int verbose) +{ + m_cmd= new CommandInterpreter(host,verbose); +} +Ndb_mgmclient::~Ndb_mgmclient() +{ + delete m_cmd; +} +int Ndb_mgmclient::execute(const char *_line, int _try_reconnect, int *error) +{ + return m_cmd->execute(_line,_try_reconnect,error); +} +int +Ndb_mgmclient::disconnect() +{ + return m_cmd->disconnect(); +} + +extern "C" { + Ndb_mgmclient_handle ndb_mgmclient_handle_create(const char *connect_string) + { + return (Ndb_mgmclient_handle) new Ndb_mgmclient(connect_string); + } + int ndb_mgmclient_execute(Ndb_mgmclient_handle h, int argc, char** argv) + { + return ((Ndb_mgmclient*)h)->execute(argc, argv, 1); + } + int ndb_mgmclient_handle_destroy(Ndb_mgmclient_handle h) + { + delete (Ndb_mgmclient*)h; + return 0; + } +} +/* + * The CommandInterpreter + */ #include <mgmapi.h> #include <mgmapi_debug.h> @@ -33,8 +225,22 @@ #endif // HAVE_GLOBAL_REPLICATION #include "MgmtErrorReporter.hpp" -#include "CpcClient.hpp" +#include <Parser.hpp> +#include <SocketServer.hpp> +#include <util/InputStream.hpp> +#include <util/OutputStream.hpp> +int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, int *error) +{ + if (argc <= 0) + return 0; + BaseString _line(argv[0]); + for (int i= 1; i < argc; i++) + { + _line.appfmt(" %s", argv[i]); + } + return m_cmd->execute(_line.c_str(),_try_reconnect, error); +} /***************************************************************************** * HELP @@ -56,12 +262,13 @@ static const char* helpText = "SHOW CONFIG Print configuration\n" "SHOW PARAMETERS Print configuration parameters\n" #endif -"START BACKUP Start backup\n" +"START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]\n" +" Start backup (default WAIT COMPLETED)\n" "ABORT BACKUP <backup id> Abort backup\n" -"SHUTDOWN Shutdown all processes in cluster and quit\n" -"CLUSTERLOG ON Enable Cluster logging\n" -"CLUSTERLOG OFF Disable Cluster logging\n" -"CLUSTERLOG FILTER <severity> Toggle severity filter on/off\n" +"SHUTDOWN Shutdown all processes in cluster\n" +"CLUSTERLOG ON [<severity>] ... Enable Cluster logging\n" +"CLUSTERLOG OFF [<severity>] ... Disable Cluster logging\n" +"CLUSTERLOG TOGGLE [<severity>] ... Toggle severity filter on/off\n" "CLUSTERLOG INFO Print cluster log information\n" "<id> START Start DB node (started with -n)\n" "<id> RESTART [-n] [-i] Restart DB node\n" @@ -73,6 +280,8 @@ static const char* helpText = #ifdef HAVE_GLOBAL_REPLICATION "REP CONNECT <host:port> Connect to REP server on host:port\n" #endif +"PURGE STALE SESSIONS Reset reserved nodeid's in the mgmt server\n" +"CONNECT [<connectstring>] Connect to management server (reconnect if already connected)\n" "QUIT Quit management client\n" ; @@ -131,7 +340,6 @@ static const char* helpTextDebug = #ifdef ERROR_INSERT "<id> ERROR <errorNo> Inject error into NDB node\n" #endif -"<id> TRACE <traceNo> Set trace number\n" "<id> LOG [BLOCK = {ALL|<block>+}] Set logging on in & out signals\n" "<id> LOGIN [BLOCK = {ALL|<block>+}] Set logging on in signals\n" "<id> LOGOUT [BLOCK = {ALL|<block>+}] Set logging on out signals\n" @@ -171,18 +379,28 @@ convert(const char* s, int& val) { /* * Constructor */ -CommandInterpreter::CommandInterpreter(const char *_host) +CommandInterpreter::CommandInterpreter(const char *_host,int verbose) + : m_verbose(verbose) { m_mgmsrv = ndb_mgm_create_handle(); if(m_mgmsrv == NULL) { ndbout_c("Cannot create handle to management server."); + exit(-1); + } + m_mgmsrv2 = ndb_mgm_create_handle(); + if(m_mgmsrv2 == NULL) { + ndbout_c("Cannot create handle to management server."); + exit(-1); + } + if (ndb_mgm_set_connectstring(m_mgmsrv, _host)) + { printError(); + exit(-1); } - connected = false; + m_connected= false; + m_event_thread= 0; try_reconnect = 0; - - host = my_strdup(_host,MYF(MY_WME)); #ifdef HAVE_GLOBAL_REPLICATION rep_host = NULL; m_repserver = NULL; @@ -195,13 +413,12 @@ CommandInterpreter::CommandInterpreter(const char *_host) */ CommandInterpreter::~CommandInterpreter() { - connected = false; + disconnect(); ndb_mgm_destroy_handle(&m_mgmsrv); - my_free((char *)host,MYF(0)); - host = NULL; + ndb_mgm_destroy_handle(&m_mgmsrv2); } -bool +static bool emptyString(const char* s) { if (s == NULL) { @@ -220,6 +437,11 @@ emptyString(const char* s) void CommandInterpreter::printError() { + if (ndb_mgm_check_connection(m_mgmsrv)) + { + m_connected= false; + disconnect(); + } ndbout_c("* %5d: %s", ndb_mgm_get_latest_error(m_mgmsrv), ndb_mgm_get_latest_error_msg(m_mgmsrv)); @@ -229,34 +451,105 @@ CommandInterpreter::printError() //***************************************************************************** //***************************************************************************** -bool +static int do_event_thread; +static void* +event_thread_run(void* m) +{ + NdbMgmHandle handle= *(NdbMgmHandle*)m; + + int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 }; + int fd = ndb_mgm_listen_event(handle, filter); + if (fd > 0) + { + do_event_thread= 1; + char *tmp= 0; + char buf[1024]; + SocketInputStream in(fd,10); + do { + if (tmp == 0) NdbSleep_MilliSleep(10); + if((tmp = in.gets(buf, 1024))) + ndbout << tmp; + } while(do_event_thread); + } + else + { + do_event_thread= -1; + } + + return NULL; +} + +bool CommandInterpreter::connect() { - if(!connected) { - int tries = try_reconnect; // tries == 0 => infinite - while(!connected) { - if(ndb_mgm_connect(m_mgmsrv, host) == -1) { - ndbout << "Cannot connect to management server (" << host << ")."; - tries--; - if (tries == 0) - break; - ndbout << "Retrying in 5 seconds." << endl; - NdbSleep_SecSleep(5); - } else - connected = true; + if(!m_connected) + { + if(!ndb_mgm_connect(m_mgmsrv, try_reconnect-1, 5, 1)) + { + const char *host= ndb_mgm_get_connected_host(m_mgmsrv); + unsigned port= ndb_mgm_get_connected_port(m_mgmsrv); + if(!ndb_mgm_set_connectstring(m_mgmsrv2, + BaseString(host).appfmt(":%d",port).c_str()) + && + !ndb_mgm_connect(m_mgmsrv2, try_reconnect-1, 5, 1)) + { + assert(m_event_thread == 0); + assert(do_event_thread == 0); + do_event_thread= 0; + m_event_thread = NdbThread_Create(event_thread_run, + (void**)&m_mgmsrv2, + 32768, + "CommandInterpreted_event_thread", + NDB_THREAD_PRIO_LOW); + if (m_event_thread != 0) + { + int iter= 1000; // try for 30 seconds + while(do_event_thread == 0 && + iter-- > 0) + NdbSleep_MilliSleep(30); + } + if (m_event_thread == 0 || + do_event_thread == 0 || + do_event_thread == -1) + { + printf("Warning, event thread startup failed, degraded printouts as result\n"); + do_event_thread= 0; + } + } + else + { + printf("Warning, event connect failed, degraded printouts as result\n"); + } + m_connected= true; + if (m_verbose) + { + printf("Connected to Management Server at: %s:%d\n", + host, port); + } } } - return connected; + return m_connected; } bool CommandInterpreter::disconnect() { - if (ndb_mgm_disconnect(m_mgmsrv) == -1) { - ndbout_c("Could not disconnect from management server"); - printError(); + if (m_event_thread) { + void *res; + do_event_thread= 0; + NdbThread_WaitFor(m_event_thread, &res); + NdbThread_Destroy(&m_event_thread); + m_event_thread= 0; + ndb_mgm_disconnect(m_mgmsrv2); + } + if (m_connected) + { + if (ndb_mgm_disconnect(m_mgmsrv) == -1) { + ndbout_c("Could not disconnect from management server"); + printError(); + } + m_connected= false; } - connected = false; return true; } @@ -264,95 +557,136 @@ CommandInterpreter::disconnect() //***************************************************************************** int -CommandInterpreter::readAndExecute(int _try_reconnect) +CommandInterpreter::execute(const char *_line, int _try_reconnect, + int *error) { if (_try_reconnect >= 0) try_reconnect=_try_reconnect; + int result= execute_impl(_line); + if (error) + *error= m_error; + return result; +} + +static void +invalid_command(const char *cmd) +{ + ndbout << "Invalid command: " << cmd << endl; + ndbout << "Type HELP for help." << endl << endl; +} + +int +CommandInterpreter::execute_impl(const char *_line) +{ + DBUG_ENTER("CommandInterpreter::execute_impl"); + DBUG_PRINT("enter",("line=\"%s\"",_line)); + m_error= 0; - char* _line = readline_gets(); char * line; if(_line == NULL) { - // ndbout << endl; - return false; + DBUG_RETURN(false); } - line = my_strdup(_line,MYF(MY_WME)); My_auto_ptr<char> ptr(line); - - if (emptyString(line)) { - return true; - } - - for (unsigned int i = 0; i < strlen(line); ++i) { - line[i] = toupper(line[i]); - } + int do_continue; + do { + do_continue= 0; + BaseString::trim(line," \t"); + if (line[0] == 0 || + line[0] == '#') + { + DBUG_RETURN(true); + } + // for mysql client compatability remove trailing ';' + { + unsigned last= strlen(line)-1; + if (line[last] == ';') + { + line[last]= 0; + do_continue= 1; + } + } + } while (do_continue); // if there is anything in the line proceed char* firstToken = strtok(line, " "); char* allAfterFirstToken = strtok(NULL, ""); - if (strcmp(firstToken, "HELP") == 0 || - strcmp(firstToken, "?") == 0) { + if (strcasecmp(firstToken, "HELP") == 0 || + strcasecmp(firstToken, "?") == 0) { executeHelp(allAfterFirstToken); - return true; + DBUG_RETURN(true); + } + else if (strcasecmp(firstToken, "CONNECT") == 0) { + executeConnect(allAfterFirstToken); + DBUG_RETURN(true); } - else if (strcmp(firstToken, "SHOW") == 0) { + else if (strcasecmp(firstToken, "SLEEP") == 0) { + if (allAfterFirstToken) + sleep(atoi(allAfterFirstToken)); + DBUG_RETURN(true); + } + else if((strcasecmp(firstToken, "QUIT") == 0 || + strcasecmp(firstToken, "EXIT") == 0 || + strcasecmp(firstToken, "BYE") == 0) && + allAfterFirstToken == NULL){ + DBUG_RETURN(false); + } + + if (!connect()) + DBUG_RETURN(true); + + if (strcasecmp(firstToken, "SHOW") == 0) { executeShow(allAfterFirstToken); - return true; + DBUG_RETURN(true); } - else if (strcmp(firstToken, "SHUTDOWN") == 0) { - executeShutdown(allAfterFirstToken); - return true; + else if (strcasecmp(firstToken, "SHUTDOWN") == 0) { + m_error= executeShutdown(allAfterFirstToken); + DBUG_RETURN(true); } - else if (strcmp(firstToken, "CLUSTERLOG") == 0){ + else if (strcasecmp(firstToken, "CLUSTERLOG") == 0){ executeClusterLog(allAfterFirstToken); - return true; + DBUG_RETURN(true); } - else if(strcmp(firstToken, "START") == 0 && + else if(strcasecmp(firstToken, "START") == 0 && allAfterFirstToken != NULL && - strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ - executeStartBackup(allAfterFirstToken); - return true; + strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ + m_error= executeStartBackup(allAfterFirstToken); + DBUG_RETURN(true); } - else if(strcmp(firstToken, "ABORT") == 0 && + else if(strcasecmp(firstToken, "ABORT") == 0 && allAfterFirstToken != NULL && - strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ + strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ executeAbortBackup(allAfterFirstToken); - return true; + DBUG_RETURN(true); } + else if (strcasecmp(firstToken, "PURGE") == 0) { + executePurge(allAfterFirstToken); + DBUG_RETURN(true); + } #ifdef HAVE_GLOBAL_REPLICATION - else if(strcmp(firstToken, "REPLICATION") == 0 || - strcmp(firstToken, "REP") == 0) { + else if(strcasecmp(firstToken, "REPLICATION") == 0 || + strcasecmp(firstToken, "REP") == 0) { executeRep(allAfterFirstToken); - return true; + DBUG_RETURN(true); } #endif // HAVE_GLOBAL_REPLICATION - else if(strcmp(firstToken, "ENTER") == 0 && + else if(strcasecmp(firstToken, "ENTER") == 0 && allAfterFirstToken != NULL && - strncmp(allAfterFirstToken, "SINGLE USER MODE ", + strncasecmp(allAfterFirstToken, "SINGLE USER MODE ", sizeof("SINGLE USER MODE") - 1) == 0){ executeEnterSingleUser(allAfterFirstToken); - return true; + DBUG_RETURN(true); } - else if(strcmp(firstToken, "EXIT") == 0 && + else if(strcasecmp(firstToken, "EXIT") == 0 && allAfterFirstToken != NULL && - strncmp(allAfterFirstToken, "SINGLE USER MODE ", + strncasecmp(allAfterFirstToken, "SINGLE USER MODE ", sizeof("SINGLE USER MODE") - 1) == 0){ executeExitSingleUser(allAfterFirstToken); - return true; + DBUG_RETURN(true); } - else if (strcmp(firstToken, "ALL") == 0) { + else if (strcasecmp(firstToken, "ALL") == 0) { analyseAfterFirstToken(-1, allAfterFirstToken); - } - else if((strcmp(firstToken, "QUIT") == 0 || - strcmp(firstToken, "EXIT") == 0 || - strcmp(firstToken, "BYE") == 0) && - allAfterFirstToken == NULL){ - return false; -#if 0 - } else if(strcmp(firstToken, "CPC") == 0) { - executeCpc(allAfterFirstToken); -#endif } else { /** * First token should be a digit, node ID @@ -360,20 +694,19 @@ CommandInterpreter::readAndExecute(int _try_reconnect) int nodeId; if (! convert(firstToken, nodeId)) { - ndbout << "Invalid command: " << line << endl; - ndbout << "Type HELP for help." << endl << endl; - return true; + invalid_command(_line); + DBUG_RETURN(true); } - if (nodeId < 0) { + if (nodeId <= 0) { ndbout << "Invalid node ID: " << firstToken << "." << endl; - return true; + DBUG_RETURN(true); } analyseAfterFirstToken(nodeId, allAfterFirstToken); } - return true; + DBUG_RETURN(true); } @@ -390,7 +723,6 @@ static const CommandInterpreter::CommandFunctionPair commands[] = { #ifdef ERROR_INSERT ,{ "ERROR", &CommandInterpreter::executeError } #endif - ,{ "TRACE", &CommandInterpreter::executeTrace } ,{ "LOG", &CommandInterpreter::executeLog } ,{ "LOGIN", &CommandInterpreter::executeLogIn } ,{ "LOGOUT", &CommandInterpreter::executeLogOut } @@ -410,12 +742,8 @@ CommandInterpreter::analyseAfterFirstToken(int processId, char* allAfterFirstToken) { if (emptyString(allAfterFirstToken)) { - if (processId == -1) { - ndbout << "Expected a command after ALL." << endl; - } - else { - ndbout << "Expected a command after node ID." << endl; - } + ndbout << "Expected a command after " + << ((processId == -1) ? "ALL." : "node ID.") << endl; return; } @@ -426,7 +754,7 @@ CommandInterpreter::analyseAfterFirstToken(int processId, ExecuteFunction fun = 0; const char * command = 0; for(int i = 0; i<tmpSize; i++){ - if(strcmp(secondToken, commands[i].command) == 0){ + if(strcasecmp(secondToken, commands[i].command) == 0){ fun = commands[i].executeFunction; command = commands[i].command; break; @@ -434,19 +762,16 @@ CommandInterpreter::analyseAfterFirstToken(int processId, } if(fun == 0){ - ndbout << "Invalid command: " << secondToken << endl; - ndbout << "Type HELP for help." << endl << endl; + invalid_command(secondToken); return; } if(processId == -1){ executeForAll(command, fun, allAfterSecondToken); } else { - if(strcmp(command, "STATUS") != 0) - ndbout_c("Executing %s on node %d.", command, processId); (this->*fun)(processId, allAfterSecondToken, false); - ndbout << endl; } + ndbout << endl; } /** @@ -492,17 +817,16 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, const char * allAfterSecondToken) { int nodeId = 0; - if(strcmp(cmd, "STOP") == 0) { + if(strcasecmp(cmd, "STOP") == 0) { ndbout_c("Executing STOP on all nodes."); (this->*fun)(nodeId, allAfterSecondToken, true); - } else if(strcmp(cmd, "RESTART") == 0) { + } else if(strcasecmp(cmd, "RESTART") == 0) { ndbout_c("Executing RESTART on all nodes."); ndbout_c("Starting shutdown. This may take a while. Please wait..."); (this->*fun)(nodeId, allAfterSecondToken, true); ndbout_c("Trying to start all nodes of system."); ndbout_c("Use ALL STATUS to see the system start-up phases."); } else { - connect(); struct ndb_mgm_cluster_state *cl= ndb_mgm_get_status(m_mgmsrv); if(cl == 0){ ndbout_c("Unable get status from management server"); @@ -510,12 +834,8 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, return; } NdbAutoPtr<char> ap1((char*)cl); - while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) { - if(strcmp(cmd, "STATUS") != 0) - ndbout_c("Executing %s on node %d.", cmd, nodeId); + while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) (this->*fun)(nodeId, allAfterSecondToken, true); - ndbout << endl; - } // while } } @@ -539,7 +859,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog, firstTokenAfterLog[i] = toupper(firstTokenAfterLog[i]); } - if (strcmp(firstTokenAfterLog, "BLOCK") != 0) { + if (strcasecmp(firstTokenAfterLog, "BLOCK") != 0) { ndbout << "Unexpected value: " << firstTokenAfterLog << ". Expected BLOCK." << endl; return false; @@ -552,7 +872,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog, } char* secondTokenAfterLog = strtok(allAfterFirstToken, " "); - if (strcmp(secondTokenAfterLog, "=") != 0) { + if (strcasecmp(secondTokenAfterLog, "=") != 0) { ndbout << "Unexpected value: " << secondTokenAfterLog << ". Expected =." << endl; return false; @@ -560,7 +880,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog, char* blockName = strtok(NULL, " "); bool all = false; - if (blockName != NULL && (strcmp(blockName, "ALL") == 0)) { + if (blockName != NULL && (strcasecmp(blockName, "ALL") == 0)) { all = true; } while (blockName != NULL) { @@ -611,20 +931,19 @@ CommandInterpreter::executeHelp(char* parameters) ndbout << "<level> = " << "0 - 15" << endl; ndbout << "<id> = " << "ALL | Any database node id" << endl; ndbout << endl; - } else if (strcmp(parameters, "SHOW") == 0) { + } else if (strcasecmp(parameters, "SHOW") == 0) { ndbout << helpTextShow; #ifdef HAVE_GLOBAL_REPLICATION - } else if (strcmp(parameters, "REPLICATION") == 0 || - strcmp(parameters, "REP") == 0) { + } else if (strcasecmp(parameters, "REPLICATION") == 0 || + strcasecmp(parameters, "REP") == 0) { ndbout << helpTextRep; #endif // HAVE_GLOBAL_REPLICATION #ifdef VM_TRACE // DEBUG ONLY - } else if (strcmp(parameters, "DEBUG") == 0) { + } else if (strcasecmp(parameters, "DEBUG") == 0) { ndbout << helpTextDebug; #endif } else { - ndbout << "Invalid argument: " << parameters << endl; - ndbout << "Type HELP for help." << endl << endl; + invalid_command(parameters); } } @@ -633,25 +952,23 @@ CommandInterpreter::executeHelp(char* parameters) * SHUTDOWN *****************************************************************************/ -void +int CommandInterpreter::executeShutdown(char* parameters) { - connect(); - ndb_mgm_cluster_state *state = ndb_mgm_get_status(m_mgmsrv); if(state == NULL) { ndbout_c("Could not get status"); printError(); - return; + return 1; } NdbAutoPtr<char> ap1((char*)state); int result = 0; result = ndb_mgm_stop(m_mgmsrv, 0, 0); if (result < 0) { - ndbout << "Shutdown failed." << endl; + ndbout << "Shutdown off NDB Cluster storage node(s) failed." << endl; printError(); - return; + return result; } ndbout << result << " NDB Cluster storage node(s) have shutdown." << endl; @@ -666,21 +983,24 @@ CommandInterpreter::executeShutdown(char* parameters) ndbout << "Unable to locate management server, " << "shutdown manually with <id> STOP" << endl; - return; + return 1; } } } - result = 0; result = ndb_mgm_stop(m_mgmsrv, 1, &mgm_id); if (result <= 0) { - ndbout << "Shutdown failed." << endl; + ndbout << "Shutdown of NDB Cluster management server failed." << endl; printError(); - return; + if (result == 0) + return 1; + return result; } + m_connected= false; + disconnect(); ndbout << "NDB Cluster management server shutdown." << endl; - exit(0); + return 0; } /***************************************************************************** @@ -729,7 +1049,7 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it, const char *hostname= node_state->connect_address; if (hostname == 0 || strlen(hostname) == 0 - || strcmp(hostname,"0.0.0.0") == 0) + || strcasecmp(hostname,"0.0.0.0") == 0) ndbout << " "; else ndbout << "\t@" << hostname; @@ -749,16 +1069,19 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it, } ndbout << ")" << endl; } else { - if(ndb_mgm_find(it, CFG_NODE_ID, node_id) != 0){ + ndb_mgm_first(it); + if(ndb_mgm_find(it, CFG_NODE_ID, node_id) == 0){ + const char *config_hostname= 0; + ndb_mgm_get_string_parameter(it, CFG_NODE_HOST, &config_hostname); + if (config_hostname == 0 || config_hostname[0] == 0) + config_hostname= "any host"; + ndbout_c(" (not connected, accepting connect from %s)", + config_hostname); + } + else + { ndbout_c("Unable to find node with id: %d", node_id); - return; } - const char *config_hostname= 0; - ndb_mgm_get_string_parameter(it, CFG_NODE_HOST, &config_hostname); - if (config_hostname == 0 || config_hostname[0] == 0) - config_hostname= "any host"; - ndbout << " (not connected, accepting connect from " - << config_hostname << ")" << endl; } } } @@ -766,14 +1089,49 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it, } void +CommandInterpreter::executePurge(char* parameters) +{ + int command_ok= 0; + do { + if (emptyString(parameters)) + break; + char* firstToken = strtok(parameters, " "); + char* nextToken = strtok(NULL, " \0"); + if (strcasecmp(firstToken,"STALE") == 0 && + nextToken && + strcasecmp(nextToken, "SESSIONS") == 0) { + command_ok= 1; + break; + } + } while(0); + + if (!command_ok) { + ndbout_c("Unexpected command, expected: PURGE STALE SESSIONS"); + return; + } + + int i; + char *str; + + if (ndb_mgm_purge_stale_sessions(m_mgmsrv, &str)) { + ndbout_c("Command failed"); + return; + } + if (str) { + ndbout_c("Purged sessions with node id's: %s", str); + free(str); + } + else + { + ndbout_c("No sessions purged"); + } +} + +void CommandInterpreter::executeShow(char* parameters) { int i; - connect(); if (emptyString(parameters)) { - ndbout << "Cluster Configuration" << endl - << "---------------------" << endl; - ndb_mgm_cluster_state *state = ndb_mgm_get_status(m_mgmsrv); if(state == NULL) { ndbout_c("Could not get status"); @@ -833,22 +1191,24 @@ CommandInterpreter::executeShow(char* parameters) } } + ndbout << "Cluster Configuration" << endl + << "---------------------" << endl; print_nodes(state, it, "ndbd", ndb_nodes, NDB_MGM_NODE_TYPE_NDB, master_id); print_nodes(state, it, "ndb_mgmd", mgm_nodes, NDB_MGM_NODE_TYPE_MGM, 0); print_nodes(state, it, "mysqld", api_nodes, NDB_MGM_NODE_TYPE_API, 0); // ndbout << helpTextShow; return; - } else if (strcmp(parameters, "PROPERTIES") == 0 || - strcmp(parameters, "PROP") == 0) { + } else if (strcasecmp(parameters, "PROPERTIES") == 0 || + strcasecmp(parameters, "PROP") == 0) { ndbout << "SHOW PROPERTIES is not yet implemented." << endl; // ndbout << "_mgmtSrvr.getConfig()->print();" << endl; /* XXX */ - } else if (strcmp(parameters, "CONFIGURATION") == 0 || - strcmp(parameters, "CONFIG") == 0){ + } else if (strcasecmp(parameters, "CONFIGURATION") == 0 || + strcasecmp(parameters, "CONFIG") == 0){ ndbout << "SHOW CONFIGURATION is not yet implemented." << endl; //nbout << "_mgmtSrvr.getConfig()->printConfigFile();" << endl; /* XXX */ - } else if (strcmp(parameters, "PARAMETERS") == 0 || - strcmp(parameters, "PARAMS") == 0 || - strcmp(parameters, "PARAM") == 0) { + } else if (strcasecmp(parameters, "PARAMETERS") == 0 || + strcasecmp(parameters, "PARAMS") == 0 || + strcasecmp(parameters, "PARAM") == 0) { ndbout << "SHOW PARAMETERS is not yet implemented." << endl; // ndbout << "_mgmtSrvr.getConfig()->getConfigInfo()->print();" // << endl; /* XXX */ @@ -857,151 +1217,150 @@ CommandInterpreter::executeShow(char* parameters) } } +void +CommandInterpreter::executeConnect(char* parameters) +{ + disconnect(); + if (!emptyString(parameters)) { + if (ndb_mgm_set_connectstring(m_mgmsrv, + BaseString(parameters).trim().c_str())) + { + printError(); + return; + } + } + connect(); +} //***************************************************************************** //***************************************************************************** void CommandInterpreter::executeClusterLog(char* parameters) { + DBUG_ENTER("CommandInterpreter::executeClusterLog"); int i; - connect(); - if (parameters != 0 && strlen(parameters) != 0) { - enum ndb_mgm_clusterlog_level severity = NDB_MGM_CLUSTERLOG_ALL; - int isOk = true; - char name[12]; - bool noArgs = false; - - char * tmpString = my_strdup(parameters,MYF(MY_WME)); - My_auto_ptr<char> ap1(tmpString); - char * tmpPtr = 0; - char * item = strtok_r(tmpString, " ", &tmpPtr); + if (emptyString(parameters)) + { + ndbout << "Missing argument." << endl; + DBUG_VOID_RETURN; + } + + enum ndb_mgm_clusterlog_level severity = NDB_MGM_CLUSTERLOG_ALL; - /******************** - * CLUSTERLOG FILTER - ********************/ - if (strcmp(item, "FILTER") == 0) { - - item = strtok_r(NULL, " ", &tmpPtr); - if (item == NULL) { - noArgs = true; - } - while (item != NULL) { - snprintf(name, sizeof(name), item); - - if (strcmp(item, "ALL") == 0) { - severity = NDB_MGM_CLUSTERLOG_ALL; - } else if (strcmp(item, "ALERT") == 0) { - severity = NDB_MGM_CLUSTERLOG_ALERT; - } else if (strcmp(item, "CRITICAL") == 0) { - severity = NDB_MGM_CLUSTERLOG_CRITICAL; - } else if (strcmp(item, "ERROR") == 0) { - severity = NDB_MGM_CLUSTERLOG_ERROR; - } else if (strcmp(item, "WARNING") == 0) { - severity = NDB_MGM_CLUSTERLOG_WARNING; - } else if (strcmp(item, "INFO") == 0) { - severity = NDB_MGM_CLUSTERLOG_INFO; - } else if (strcmp(item, "DEBUG") == 0) { - severity = NDB_MGM_CLUSTERLOG_DEBUG; - } else if (strcmp(item, "OFF") == 0) { - severity = NDB_MGM_CLUSTERLOG_OFF; - } else { - isOk = false; - } - - item = strtok_r(NULL, " ", &tmpPtr); - } // while(item != NULL){ - - if (noArgs) { - ndbout << "Missing argument(s)." << endl; - } else if (isOk) { - if(ndb_mgm_filter_clusterlog(m_mgmsrv, severity, NULL)) { - if(strcmp(name, "ALL") == 0 || strcmp(name, "all") == 0) { - ndbout << "All severities levels enabled." << endl; - } else if(strcmp(name, "OFF") == 0 || strcmp(name, "off") == 0) { - ndbout << "Cluster logging enabled." << endl; - } else { - ndbout << name << " events disabled." << endl; - } - } else { - if(strcmp(name, "ALL") == 0) { - ndbout << "All severities levels disabled." << endl; - } else if(strcmp(name, "OFF") == 0) { - ndbout << "Cluster logging disabled." << endl; - } else { - ndbout << name << " events enabled." << endl; - } - } - } else { - ndbout << "Invalid severity level." << endl; - } + char * tmpString = my_strdup(parameters,MYF(MY_WME)); + My_auto_ptr<char> ap1(tmpString); + char * tmpPtr = 0; + char * item = strtok_r(tmpString, " ", &tmpPtr); + int enable; - /******************** - * CLUSTERLOG INFO - ********************/ - } else if (strcmp(item, "INFO") == 0) { - Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); - if(enabled == NULL) { - ndbout << "Couldn't get status" << endl; - printError(); - return; - } - const char* names[] = {"ENABLED", "DEBUG", "INFO", "WARNING", "ERROR", - "CRITICAL", "ALERT"}; - if(enabled[0]) - ndbout << "Cluster logging is disabled." << endl; + Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); + if(enabled == NULL) { + ndbout << "Couldn't get status" << endl; + printError(); + DBUG_VOID_RETURN; + } - - for(i = 0; i<7;i++) - printf("enabled[%d] = %d\n", i, enabled[i]); - ndbout << "Severities enabled: "; - for(i = 1; i < 7; i++) { - if(enabled[i]) - ndbout << names[i] << " "; - } - ndbout << endl; - - /******************** - * CLUSTERLOG OFF - ********************/ - } else if (strcmp(item, "OFF") == 0) { - Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); - if(enabled == NULL) { - ndbout << "Couldn't get status" << endl; - printError(); - return; - } - if(!enabled[0]) { - ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_OFF, NULL); - ndbout << "Cluster logging is disabled." << endl; - } else { - ndbout << "Cluster logging is already disabled." << endl; - - } - - /******************** - * CLUSTERLOG ON - ********************/ - } else if (strcmp(item, "ON") == 0) { - Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); - if(enabled == NULL) { - ndbout << "Could not get status" << endl; - printError(); - return; - } - if(enabled[0]) { - ndb_mgm_filter_clusterlog(m_mgmsrv, NDB_MGM_CLUSTERLOG_OFF, NULL); - ndbout << "Cluster logging is enabled." << endl; - } else { - ndbout << "Cluster logging is already enabled." << endl; - + /******************** + * CLUSTERLOG INFO + ********************/ + if (strcasecmp(item, "INFO") == 0) { + DBUG_PRINT("info",("INFO")); + if(enabled[0] == 0) + { + ndbout << "Cluster logging is disabled." << endl; + DBUG_VOID_RETURN; + } +#if 0 + for(i = 0; i<7;i++) + printf("enabled[%d] = %d\n", i, enabled[i]); +#endif + ndbout << "Severities enabled: "; + for(i = 1; i < (int)NDB_MGM_CLUSTERLOG_ALL; i++) { + const char *str= ndb_mgm_get_clusterlog_level_string((ndb_mgm_clusterlog_level)i); + if (str == 0) + { + DBUG_ASSERT(false); + continue; } - } else { - ndbout << "Invalid argument." << endl; + if(enabled[i]) + ndbout << BaseString(str).ndb_toupper() << " "; } - + ndbout << endl; + DBUG_VOID_RETURN; + + } + else if (strcasecmp(item, "FILTER") == 0 || + strcasecmp(item, "TOGGLE") == 0) + { + DBUG_PRINT("info",("TOGGLE")); + enable= -1; + } + else if (strcasecmp(item, "OFF") == 0) + { + DBUG_PRINT("info",("OFF")); + enable= 0; + } else if (strcasecmp(item, "ON") == 0) { + DBUG_PRINT("info",("ON")); + enable= 1; } else { - ndbout << "Missing argument." << endl; + ndbout << "Invalid argument." << endl; + DBUG_VOID_RETURN; } + + int res_enable; + item = strtok_r(NULL, " ", &tmpPtr); + if (item == NULL) { + res_enable= ndb_mgm_filter_clusterlog(m_mgmsrv, + NDB_MGM_CLUSTERLOG_ON, enable, NULL); + if (res_enable < 0) + { + ndbout << "Couldn't set filter" << endl; + printError(); + DBUG_VOID_RETURN; + } + ndbout << "Cluster logging is " << (res_enable ? "enabled.":"disabled") << endl; + DBUG_VOID_RETURN; + } + + do { + severity= NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL; + if (strcasecmp(item, "ALL") == 0) { + severity = NDB_MGM_CLUSTERLOG_ALL; + } else if (strcasecmp(item, "ALERT") == 0) { + severity = NDB_MGM_CLUSTERLOG_ALERT; + } else if (strcasecmp(item, "CRITICAL") == 0) { + severity = NDB_MGM_CLUSTERLOG_CRITICAL; + } else if (strcasecmp(item, "ERROR") == 0) { + severity = NDB_MGM_CLUSTERLOG_ERROR; + } else if (strcasecmp(item, "WARNING") == 0) { + severity = NDB_MGM_CLUSTERLOG_WARNING; + } else if (strcasecmp(item, "INFO") == 0) { + severity = NDB_MGM_CLUSTERLOG_INFO; + } else if (strcasecmp(item, "DEBUG") == 0) { + severity = NDB_MGM_CLUSTERLOG_DEBUG; + } else if (strcasecmp(item, "OFF") == 0 || + strcasecmp(item, "ON") == 0) { + if (enable < 0) // only makes sense with toggle + severity = NDB_MGM_CLUSTERLOG_ON; + } + if (severity == NDB_MGM_ILLEGAL_CLUSTERLOG_LEVEL) { + ndbout << "Invalid severity level: " << item << endl; + DBUG_VOID_RETURN; + } + + res_enable = ndb_mgm_filter_clusterlog(m_mgmsrv, severity, enable, NULL); + if (res_enable < 0) + { + ndbout << "Couldn't set filter" << endl; + printError(); + DBUG_VOID_RETURN; + } + ndbout << BaseString(item).ndb_toupper().c_str() << " " << (res_enable ? "enabled":"disabled") << endl; + + item = strtok_r(NULL, " ", &tmpPtr); + } while(item != NULL); + + DBUG_VOID_RETURN; } //***************************************************************************** @@ -1010,7 +1369,6 @@ CommandInterpreter::executeClusterLog(char* parameters) void CommandInterpreter::executeStop(int processId, const char *, bool all) { - connect(); int result = 0; if(all) { result = ndb_mgm_stop(m_mgmsrv, 0, 0); @@ -1032,7 +1390,6 @@ CommandInterpreter::executeStop(int processId, const char *, bool all) void CommandInterpreter::executeEnterSingleUser(char* parameters) { - connect(); strtok(parameters, " "); struct ndb_mgm_reply reply; char* id = strtok(NULL, " "); @@ -1059,7 +1416,6 @@ CommandInterpreter::executeEnterSingleUser(char* parameters) void CommandInterpreter::executeExitSingleUser(char* parameters) { - connect(); int result = ndb_mgm_exit_single_user(m_mgmsrv, 0); if (result != 0) { ndbout_c("Exiting single user mode failed."); @@ -1074,7 +1430,6 @@ void CommandInterpreter::executeStart(int processId, const char* parameters, bool all) { - connect(); int result; if(all) { result = ndb_mgm_start(m_mgmsrv, 0, 0); @@ -1098,7 +1453,6 @@ void CommandInterpreter::executeRestart(int processId, const char* parameters, bool all) { - connect(); int result; int nostart = 0; int initialstart = 0; @@ -1110,11 +1464,11 @@ CommandInterpreter::executeRestart(int processId, const char* parameters, char * tmpPtr = 0; char * item = strtok_r(tmpString, " ", &tmpPtr); while(item != NULL){ - if(strcmp(item, "-N") == 0) + if(strcasecmp(item, "-N") == 0) nostart = 1; - if(strcmp(item, "-I") == 0) + if(strcasecmp(item, "-I") == 0) initialstart = 1; - if(strcmp(item, "-A") == 0) + if(strcasecmp(item, "-A") == 0) abort = 1; item = strtok_r(NULL, " ", &tmpPtr); } @@ -1136,7 +1490,7 @@ CommandInterpreter::executeRestart(int processId, const char* parameters, if(all) ndbout << "NDB Cluster is being restarted." << endl; else - ndbout_c("Database node %d is being restarted.", processId); + ndbout_c("Node %d is being restarted.", processId); } } @@ -1144,11 +1498,10 @@ void CommandInterpreter::executeDumpState(int processId, const char* parameters, bool all) { - if(parameters == 0 || strlen(parameters) == 0){ + if(emptyString(parameters)){ ndbout << "Expected argument" << endl; return; } - connect(); Uint32 no = 0; int pars[25]; @@ -1184,11 +1537,10 @@ CommandInterpreter::executeStatus(int processId, const char* parameters, bool all) { if (! emptyString(parameters)) { - ndbout << "No parameters expected to this command." << endl; + ndbout_c("No parameters expected to this command."); return; } - connect(); ndb_mgm_node_status status; Uint32 startPhase, version; bool system; @@ -1216,7 +1568,7 @@ CommandInterpreter::executeStatus(int processId, ndbout << "Node " << processId << ": " << status_string(status); switch(status){ case NDB_MGM_NODE_STATUS_STARTING: - ndbout << " (Phase " << startPhase << ")" ; + ndbout << " (Phase " << startPhase << ")"; break; case NDB_MGM_NODE_STATUS_SHUTTING_DOWN: ndbout << " (Phase " << startPhase << ")"; @@ -1229,6 +1581,8 @@ CommandInterpreter::executeStatus(int processId, getMajor(version) , getMinor(version), getBuild(version)); + else + ndbout << endl; } @@ -1239,9 +1593,11 @@ void CommandInterpreter::executeLogLevel(int processId, const char* parameters, bool all) { - connect(); (void) all; - + if (emptyString(parameters)) { + ndbout << "Expected argument" << endl; + return; + } BaseString tmp(parameters); Vector<BaseString> spec; tmp.split(spec, "="); @@ -1267,6 +1623,8 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, return; } + ndbout << "Executing LOGLEVEL on node " << processId << flush; + struct ndb_mgm_reply reply; int result; result = ndb_mgm_set_loglevel_node(m_mgmsrv, @@ -1276,11 +1634,10 @@ CommandInterpreter::executeLogLevel(int processId, const char* parameters, &reply); if (result < 0) { - ndbout_c("Executing LOGLEVEL on node %d failed.", processId); + ndbout_c(" failed."); printError(); } else { - ndbout << "Executing LOGLEVEL on node " << processId << " OK!" - << endl; + ndbout_c(" OK!"); } } @@ -1295,7 +1652,6 @@ void CommandInterpreter::executeError(int processId, return; } - connect(); // Copy parameters since strtok will modify it char* newpar = my_strdup(parameters,MYF(MY_WME)); My_auto_ptr<char> ap1(newpar); @@ -1318,48 +1674,11 @@ void CommandInterpreter::executeError(int processId, //***************************************************************************** //***************************************************************************** -void -CommandInterpreter::executeTrace(int /*processId*/, - const char* /*parameters*/, bool /*all*/) -{ -#if 0 - if (emptyString(parameters)) { - ndbout << "Missing trace number." << endl; - return; - } - - char* newpar = my_strdup(parameters,MYF(MY_WME)); - My_auto_ptr<char> ap1(newpar); - char* firstParameter = strtok(newpar, " "); - - - int traceNo; - if (! convert(firstParameter, traceNo)) { - ndbout << "Expected an integer." << endl; - return; - } - char* allAfterFirstParameter = strtok(NULL, "\0"); - - if (! emptyString(allAfterFirstParameter)) { - ndbout << "Nothing expected after trace number." << endl; - return; - } - - int result = _mgmtSrvr.setTraceNo(processId, traceNo); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } -#endif -} - -//***************************************************************************** -//***************************************************************************** void CommandInterpreter::executeLog(int processId, const char* parameters, bool all) { - connect(); struct ndb_mgm_reply reply; Vector<const char *> blocks; if (! parseBlockSpecification(parameters, blocks)) { @@ -1427,7 +1746,6 @@ CommandInterpreter::executeTestOn(int processId, ndbout << "No parameters expected to this command." << endl; return; } - connect(); struct ndb_mgm_reply reply; int result = ndb_mgm_start_signallog(m_mgmsrv, processId, &reply); if (result != 0) { @@ -1446,7 +1764,6 @@ CommandInterpreter::executeTestOff(int processId, ndbout << "No parameters expected to this command." << endl; return; } - connect(); struct ndb_mgm_reply reply; int result = ndb_mgm_stop_signallog(m_mgmsrv, processId, &reply); if (result != 0) { @@ -1510,7 +1827,7 @@ CommandInterpreter::executeSet(int /*processId*/, } } else { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; if (configBackupFileUpdated && configPrimaryFileUpdated) { ndbout << "The configuration files are however updated and " << "the value will be used next time the process is restarted." @@ -1545,7 +1862,7 @@ void CommandInterpreter::executeGetStat(int /*processId*/, MgmtSrvr::Statistics statistics; int result = _mgmtSrvr.getStatistics(processId, statistics); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; return; } #endif @@ -1564,8 +1881,10 @@ CommandInterpreter::executeEventReporting(int processId, const char* parameters, bool all) { - connect(); - + if (emptyString(parameters)) { + ndbout << "Expected argument" << endl; + return; + } BaseString tmp(parameters); Vector<BaseString> spec; tmp.split(spec, "="); @@ -1577,59 +1896,105 @@ CommandInterpreter::executeEventReporting(int processId, spec[0].trim().ndb_toupper(); int category = ndb_mgm_match_event_category(spec[0].c_str()); if(category == NDB_MGM_ILLEGAL_EVENT_CATEGORY){ - category = atoi(spec[0].c_str()); - if(category < NDB_MGM_MIN_EVENT_CATEGORY || + if(!convert(spec[0].c_str(), category) || + category < NDB_MGM_MIN_EVENT_CATEGORY || category > NDB_MGM_MAX_EVENT_CATEGORY){ ndbout << "Unknown category: \"" << spec[0].c_str() << "\"" << endl; return; } } - - int level = atoi(spec[1].c_str()); - if(level < 0 || level > 15){ + + int level; + if (!convert(spec[1].c_str(),level)) + { ndbout << "Invalid level: " << spec[1].c_str() << endl; return; } - + + ndbout << "Executing CLUSTERLOG on node " << processId << flush; struct ndb_mgm_reply reply; int result; - result = ndb_mgm_set_loglevel_clusterlog(m_mgmsrv, - processId, // fast fix - pekka + processId, (ndb_mgm_event_category)category, level, &reply); if (result != 0) { - ndbout_c("Executing CLUSTERLOG on node %d failed", processId); + ndbout_c(" failed."); printError(); } else { - ndbout << "Executing CLUSTERLOG on node " << processId << " OK!" - << endl; + ndbout_c(" OK!"); } } /***************************************************************************** * Backup *****************************************************************************/ -void -CommandInterpreter::executeStartBackup(char* /*parameters*/) +int +CommandInterpreter::executeStartBackup(char* parameters) { - connect(); struct ndb_mgm_reply reply; unsigned int backupId; - +#if 0 int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP, 0 }; int fd = ndb_mgm_listen_event(m_mgmsrv, filter); - int result = ndb_mgm_start_backup(m_mgmsrv, &backupId, &reply); + if (fd < 0) + { + ndbout << "Initializing start of backup failed" << endl; + printError(); + return fd; + } +#endif + Vector<BaseString> args; + { + BaseString(parameters).split(args); + for (unsigned i= 0; i < args.size(); i++) + if (args[i].length() == 0) + args.erase(i--); + else + args[i].ndb_toupper(); + } + int sz= args.size(); + + int result; + if (sz == 2 && + args[1] == "NOWAIT") + { + result = ndb_mgm_start_backup(m_mgmsrv, 0, &backupId, &reply); + } + else if (sz == 1 || + (sz == 3 && + args[1] == "WAIT" && + args[2] == "COMPLETED")) + { + ndbout_c("Waiting for completed, this may take several minutes"); + result = ndb_mgm_start_backup(m_mgmsrv, 2, &backupId, &reply); + } + else if (sz == 3 && + args[1] == "WAIT" && + args[2] == "STARTED") + { + ndbout_c("Waiting for started, this may take several minutes"); + result = ndb_mgm_start_backup(m_mgmsrv, 1, &backupId, &reply); + } + else + { + invalid_command(parameters); + return -1; + } + if (result != 0) { ndbout << "Start of backup failed" << endl; printError(); +#if 0 close(fd); - return; +#endif + return result; } - +#if 0 + ndbout_c("Waiting for completed, this may take several minutes"); char *tmp; char buf[1024]; { @@ -1656,29 +2021,39 @@ CommandInterpreter::executeStartBackup(char* /*parameters*/) ndbout << tmp; } } while(tmp && tmp[0] != 0); - + close(fd); +#endif + return 0; } void CommandInterpreter::executeAbortBackup(char* parameters) { - connect(); - strtok(parameters, " "); - struct ndb_mgm_reply reply; - char* id = strtok(NULL, "\0"); int bid = -1; - if(id == 0 || sscanf(id, "%d", &bid) != 1){ - ndbout << "Invalid arguments: expected <BackupId>" << endl; - return; + struct ndb_mgm_reply reply; + if (emptyString(parameters)) + goto executeAbortBackupError1; + + { + strtok(parameters, " "); + char* id = strtok(NULL, "\0"); + if(id == 0 || sscanf(id, "%d", &bid) != 1) + goto executeAbortBackupError1; } - int result = ndb_mgm_abort_backup(m_mgmsrv, bid, &reply); - if (result != 0) { - ndbout << "Abort of backup " << bid << " failed" << endl; - printError(); - } else { - ndbout << "Abort of backup " << bid << " ordered" << endl; + { + int result= ndb_mgm_abort_backup(m_mgmsrv, bid, &reply); + if (result != 0) { + ndbout << "Abort of backup " << bid << " failed" << endl; + printError(); + } else { + ndbout << "Abort of backup " << bid << " ordered" << endl; + } } + return; + executeAbortBackupError1: + ndbout << "Invalid arguments: expected <BackupId>" << endl; + return; } #ifdef HAVE_GLOBAL_REPLICATION @@ -1717,7 +2092,6 @@ CommandInterpreter::executeRep(char* parameters) return; } - connect(); char * line = my_strdup(parameters,MYF(MY_WME)); My_auto_ptr<char> ap1((char*)line); char * firstToken = strtok(line, " "); @@ -1726,7 +2100,7 @@ CommandInterpreter::executeRep(char* parameters) unsigned int repId; - if (!strcmp(firstToken, "CONNECT")) { + if (!strcasecmp(firstToken, "CONNECT")) { char * host = strtok(NULL, "\0"); for (unsigned int i = 0; i < strlen(host); ++i) { host[i] = tolower(host[i]); @@ -1761,30 +2135,30 @@ CommandInterpreter::executeRep(char* parameters) /******** * START ********/ - if (!strcmp(firstToken, "START")) { + if (!strcasecmp(firstToken, "START")) { unsigned int req; char *startType = strtok(NULL, "\0"); if (startType == NULL) { req = GrepReq::START; - } else if (!strcmp(startType, "SUBSCRIPTION")) { + } else if (!strcasecmp(startType, "SUBSCRIPTION")) { req = GrepReq::START_SUBSCR; - } else if (!strcmp(startType, "METALOG")) { + } else if (!strcasecmp(startType, "METALOG")) { req = GrepReq::START_METALOG; - } else if (!strcmp(startType, "METASCAN")) { + } else if (!strcasecmp(startType, "METASCAN")) { req = GrepReq::START_METASCAN; - } else if (!strcmp(startType, "DATALOG")) { + } else if (!strcasecmp(startType, "DATALOG")) { req = GrepReq::START_DATALOG; - } else if (!strcmp(startType, "DATASCAN")) { + } else if (!strcasecmp(startType, "DATASCAN")) { req = GrepReq::START_DATASCAN; - } else if (!strcmp(startType, "REQUESTOR")) { + } else if (!strcasecmp(startType, "REQUESTOR")) { req = GrepReq::START_REQUESTOR; - } else if (!strcmp(startType, "TRANSFER")) { + } else if (!strcasecmp(startType, "TRANSFER")) { req = GrepReq::START_TRANSFER; - } else if (!strcmp(startType, "APPLY")) { + } else if (!strcasecmp(startType, "APPLY")) { req = GrepReq::START_APPLY; - } else if (!strcmp(startType, "DELETE")) { + } else if (!strcasecmp(startType, "DELETE")) { req = GrepReq::START_DELETE; } else { ndbout_c("Illegal argument to command 'REPLICATION START'"); @@ -1804,7 +2178,7 @@ CommandInterpreter::executeRep(char* parameters) /******** * STOP ********/ - if (!strcmp(firstToken, "STOP")) { + if (!strcasecmp(firstToken, "STOP")) { unsigned int req; char *startType = strtok(NULL, " "); unsigned int epoch = 0; @@ -1814,7 +2188,7 @@ CommandInterpreter::executeRep(char* parameters) * Stop immediately */ req = GrepReq::STOP; - } else if (!strcmp(startType, "EPOCH")) { + } else if (!strcasecmp(startType, "EPOCH")) { char *strEpoch = strtok(NULL, "\0"); if(strEpoch == NULL) { ndbout_c("Epoch expected!"); @@ -1822,23 +2196,23 @@ CommandInterpreter::executeRep(char* parameters) } req = GrepReq::STOP; epoch=atoi(strEpoch); - } else if (!strcmp(startType, "SUBSCRIPTION")) { + } else if (!strcasecmp(startType, "SUBSCRIPTION")) { req = GrepReq::STOP_SUBSCR; - } else if (!strcmp(startType, "METALOG")) { + } else if (!strcasecmp(startType, "METALOG")) { req = GrepReq::STOP_METALOG; - } else if (!strcmp(startType, "METASCAN")) { + } else if (!strcasecmp(startType, "METASCAN")) { req = GrepReq::STOP_METASCAN; - } else if (!strcmp(startType, "DATALOG")) { + } else if (!strcasecmp(startType, "DATALOG")) { req = GrepReq::STOP_DATALOG; - } else if (!strcmp(startType, "DATASCAN")) { + } else if (!strcasecmp(startType, "DATASCAN")) { req = GrepReq::STOP_DATASCAN; - } else if (!strcmp(startType, "REQUESTOR")) { + } else if (!strcasecmp(startType, "REQUESTOR")) { req = GrepReq::STOP_REQUESTOR; - } else if (!strcmp(startType, "TRANSFER")) { + } else if (!strcasecmp(startType, "TRANSFER")) { req = GrepReq::STOP_TRANSFER; - } else if (!strcmp(startType, "APPLY")) { + } else if (!strcasecmp(startType, "APPLY")) { req = GrepReq::STOP_APPLY; - } else if (!strcmp(startType, "DELETE")) { + } else if (!strcasecmp(startType, "DELETE")) { req = GrepReq::STOP_DELETE; } else { ndbout_c("Illegal argument to command 'REPLICATION STOP'"); @@ -1857,7 +2231,7 @@ CommandInterpreter::executeRep(char* parameters) /********* * STATUS *********/ - if (!strcmp(firstToken, "STATUS")) { + if (!strcasecmp(firstToken, "STATUS")) { struct rep_state repstate; int result = ndb_rep_get_status(m_repserver, &repId, &reply, &repstate); @@ -1877,7 +2251,7 @@ CommandInterpreter::executeRep(char* parameters) /********* * QUERY (see repapi.h for querable counters) *********/ - if (!strcmp(firstToken, "QUERY")) { + if (!strcasecmp(firstToken, "QUERY")) { char *query = strtok(NULL, "\0"); int queryCounter=-1; if(query != NULL) { @@ -1903,169 +2277,4 @@ CommandInterpreter::executeRep(char* parameters) } #endif // HAVE_GLOBAL_REPLICATION - -/***************************************************************************** - * CPC - *****************************************************************************/ - -#if 0 - -#if 0 -//#ifdef NDB_SOLARIS // XXX fix me -static char* strsep(char** x, const char* y) { return 0; } -#endif - -// Note this code has not been verified -#if 0 -static char * my_strsep(char **stringp, const char *delim) -{ - char *tmp= *stringp; - if (tmp == 0) - return 0; - *stringp = strtok(tmp, delim); - return tmp; -} -#endif - -void -CommandInterpreter::executeCpc(char *parameters) -{ - char *host_str = NULL, *port_str = NULL, *end; - long port = 1234; /* XXX */ - - while((host_str = my_strsep(¶meters, " \t:")) != NULL && - host_str[0] == '\0'); - - if(parameters && parameters[0] != '\0') { - while((port_str = my_strsep(¶meters, " \t:")) != NULL && - port_str[0] == '\0'); - - errno = 0; - port = strtol(port_str, &end, 0); - if(end[0] != '\0') - goto error; - if((port == LONG_MAX || port == LONG_MIN) && - errno == ERANGE) - goto error; - } - - { - SimpleCpcClient cpc(host_str, port); - bool done = false; - - if(cpc.connect() < 0) { - ndbout_c("Cannot connect to %s:%d.", cpc.getHost(), cpc.getPort()); - switch(errno) { - case ENOENT: - ndbout << ": " << "No such host" << endl; - break; - default: - ndbout << ": " << strerror(errno) << endl; - break; - } - return; - } - - while(!done) { - char *line = readline("CPC> "); - if(line != NULL) { - add_history(line); - - char *cmd = strtok(line, " "); - char *arg = strtok(NULL, ""); - - if(arg != NULL) { - while(arg[0] == ' ') - arg++; - if(strlen(arg) == 0) - arg = NULL; - } - - if(cmd != NULL) { - if(strcmp(cmd, "exit") == 0) - done = true; - else if(strcmp(cmd, "list") == 0) - cpc.cmd_list(arg); - else if(strcmp(cmd, "start") == 0) - cpc.cmd_start(arg); - else if(strcmp(cmd, "stop") == 0) - cpc.cmd_stop(arg); - else if(strcmp(cmd, "help") == 0) - cpc.cmd_help(arg); - } - } else { - done = true; - ndbout << endl; - } - } - } - return; - - error: - ndbout << "Error: expected a tcp port number, got '" << port_str << "'." - << endl; - return; -} -#endif - -#if 0 -static -void -CmdBackupCallback(const MgmtSrvr::BackupEvent & event){ - char str[255]; - - ndbout << endl; - - bool ok = false; - switch(event.Event){ - case MgmtSrvr::BackupEvent::BackupStarted: - ok = true; - BaseString::snprintf(str, sizeof(str), - "Backup %d started", event.Started.BackupId); - break; - case MgmtSrvr::BackupEvent::BackupFailedToStart: - ok = true; - BaseString::snprintf(str, sizeof(str), - "Backup failed to start (Error %d)", - event.FailedToStart.ErrorCode); - break; - case MgmtSrvr::BackupEvent::BackupCompleted: - ok = true; - BaseString::snprintf(str, sizeof(str), - "Backup %d completed", - event.Completed.BackupId); - ndbout << str << endl; - - BaseString::snprintf(str, sizeof(str), - " StartGCP: %d StopGCP: %d", - event.Completed.startGCP, event.Completed.stopGCP); - ndbout << str << endl; - - BaseString::snprintf(str, sizeof(str), - " #Records: %d #LogRecords: %d", - event.Completed.NoOfRecords, event.Completed.NoOfLogRecords); - ndbout << str << endl; - - BaseString::snprintf(str, sizeof(str), - " Data: %d bytes Log: %d bytes", - event.Completed.NoOfBytes, event.Completed.NoOfLogBytes); - break; - case MgmtSrvr::BackupEvent::BackupAborted: - ok = true; - BaseString::snprintf(str, sizeof(str), - "Backup %d has been aborted reason %d", - event.Aborted.BackupId, - event.Aborted.Reason); - break; - } - if(!ok){ - BaseString::snprintf(str, sizeof(str), - "Unknown backup event: %d", - event.Event); - - } - ndbout << str << endl; -} -#endif - template class Vector<char const*>; diff --git a/ndb/src/mgmclient/CommandInterpreter.hpp b/ndb/src/mgmclient/CommandInterpreter.hpp deleted file mode 100644 index eecc48a739e..00000000000 --- a/ndb/src/mgmclient/CommandInterpreter.hpp +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; 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 CommandInterpreter_H -#define CommandInterpreter_H - -//#define HAVE_GLOBAL_REPLICATION -//***************************************************************************** -// Author: Peter Lind -//***************************************************************************** - -#include <ndb_global.h> -#include <Vector.hpp> -#include <editline/editline.h> - -#ifdef HAVE_GLOBAL_REPLICATION -#include "../rep/repapi/repapi.h" -#endif - -#include <mgmapi.h> - -class MgmtSrvr; - -/** - * @class CommandInterpreter - * @brief Reads command line in management client - * - * This class has one public method which reads a command line - * from a stream. It then interpret that commmand line and calls a suitable - * method in the MgmtSrvr class which executes the command. - * - * For command syntax, see the HELP command. - */ -class CommandInterpreter { -public: - /** - * Constructor - * @param mgmtSrvr: Management server to use when executing commands - */ - CommandInterpreter(const char *); - ~CommandInterpreter(); - - /** - * Reads one line from the stream, parse the line to find - * a command and then calls a suitable method which executes - * the command. - * - * @return true until quit/bye/exit has been typed - */ - int readAndExecute(int _try_reconnect=-1); - -private: - /** - * Read a string, and return a pointer to it. - * - * @return NULL on EOF. - */ - char *readline_gets () - { - static char *line_read = (char *)NULL; - - /* If the buffer has already been allocated, return the memory - to the free pool. */ - if (line_read) - { - free (line_read); - line_read = (char *)NULL; - } - - /* Get a line from the user. */ - line_read = readline ("NDB> "); - - /* If the line has any text in it, save it on the history. */ - if (line_read && *line_read) - add_history (line_read); - - return (line_read); - } - - void printError(); - - /** - * Analyse the command line, after the first token. - * - * @param processId: DB process id to send command to or -1 if - * command will be sent to all DB processes. - * @param allAfterFirstToken: What the client gave after the - * first token on the command line - */ - void analyseAfterFirstToken(int processId, char* allAfterFirstTokenCstr); - - /** - * Parse the block specification part of the LOG* commands, - * things after LOG*: [BLOCK = {ALL|<blockName>+}] - * - * @param allAfterLog: What the client gave after the second token - * (LOG*) on the command line - * @param blocks, OUT: ALL or name of all the blocks - * @return: true if correct syntax, otherwise false - */ - bool parseBlockSpecification(const char* allAfterLog, - Vector<const char*>& blocks); - - /** - * A bunch of execute functions: Executes one of the commands - * - * @param processId: DB process id to send command to - * @param parameters: What the client gave after the command name - * on the command line. - * For example if complete input from user is: "1 LOGLEVEL 22" then the - * parameters argument is the string with everything after LOGLEVEL, in - * this case "22". Each function is responsible to check the parameters - * argument. - */ - void executeHelp(char* parameters); - void executeShow(char* parameters); - void executeShutdown(char* parameters); - void executeRun(char* parameters); - void executeInfo(char* parameters); - void executeClusterLog(char* parameters); - -public: - void executeStop(int processId, const char* parameters, bool all); - void executeEnterSingleUser(char* parameters); - void executeExitSingleUser(char* parameters); - void executeStart(int processId, const char* parameters, bool all); - void executeRestart(int processId, const char* parameters, bool all); - void executeLogLevel(int processId, const char* parameters, bool all); - void executeError(int processId, const char* parameters, bool all); - void executeTrace(int processId, const char* parameters, bool all); - void executeLog(int processId, const char* parameters, bool all); - void executeLogIn(int processId, const char* parameters, bool all); - void executeLogOut(int processId, const char* parameters, bool all); - void executeLogOff(int processId, const char* parameters, bool all); - void executeTestOn(int processId, const char* parameters, bool all); - void executeTestOff(int processId, const char* parameters, bool all); - void executeSet(int processId, const char* parameters, bool all); - void executeGetStat(int processId, const char* parameters, bool all); - void executeStatus(int processId, const char* parameters, bool all); - void executeEventReporting(int processId, const char* parameters, bool all); - void executeDumpState(int processId, const char* parameters, bool all); - void executeStartBackup(char * parameters); - void executeAbortBackup(char * parameters); - - void executeRep(char* parameters); - - void executeCpc(char * parameters); - -public: - bool connect(); - bool disconnect(); - - /** - * A execute function definition - */ -public: - typedef void (CommandInterpreter::* ExecuteFunction)(int processId, - const char * param, - bool all); - - struct CommandFunctionPair { - const char * command; - ExecuteFunction executeFunction; - }; -private: - /** - * - */ - void executeForAll(const char * cmd, - ExecuteFunction fun, - const char * param); - - NdbMgmHandle m_mgmsrv; - bool connected; - const char *host; - int try_reconnect; -#ifdef HAVE_GLOBAL_REPLICATION - NdbRepHandle m_repserver; - const char *rep_host; - bool rep_connected; -#endif -}; - -#endif // CommandInterpreter_H diff --git a/ndb/src/mgmclient/Makefile.am b/ndb/src/mgmclient/Makefile.am index e271c7bed53..c63e8d1bff8 100644 --- a/ndb/src/mgmclient/Makefile.am +++ b/ndb/src/mgmclient/Makefile.am @@ -1,18 +1,26 @@ +noinst_LTLIBRARIES = libndbmgmclient.la ndbtools_PROGRAMS = ndb_mgm -ndb_mgm_SOURCES = \ - main.cpp \ - CommandInterpreter.cpp \ - CpcClient.cpp +libndbmgmclient_la_SOURCES = CommandInterpreter.cpp +libndbmgmclient_la_LIBADD = ../mgmapi/libmgmapi.la \ + ../common/logger/liblogger.la \ + ../common/portlib/libportlib.la \ + ../common/util/libgeneral.la \ + ../common/portlib/libportlib.la + + +ndb_mgm_SOURCES = main.cpp include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am -INCLUDES += -I$(top_srcdir)/ndb/include/mgmapi -I$(top_srcdir)/ndb/src/common/mgmcommon +INCLUDES += -I$(top_srcdir)/ndb/include/mgmapi \ + -I$(top_srcdir)/ndb/src/common/mgmcommon -LDADD_LOC = $(top_builddir)/ndb/src/libndbclient.la \ - $(top_builddir)/ndb/src/common/editline/libeditline.a \ +LDADD_LOC = $(noinst_LTLIBRARIES) \ + ../common/portlib/libportlib.la \ + @readline_link@ \ $(top_builddir)/dbug/libdbug.a \ $(top_builddir)/mysys/libmysys.a \ $(top_builddir)/strings/libmystrings.a \ @@ -22,3 +30,29 @@ ndb_mgm_LDFLAGS = @ndb_bin_am_ldflags@ # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: ndb_mgm.dsp libndbmgmclient.dsp + +ndb_mgm.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(ndbtools_PROGRAMS) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_mgm_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +libndbmgmclient.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libndbmgmclient_la_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB diff --git a/ndb/src/mgmclient/Makefile_old b/ndb/src/mgmclient/Makefile_old deleted file mode 100644 index d1b2d60a52a..00000000000 --- a/ndb/src/mgmclient/Makefile_old +++ /dev/null @@ -1,25 +0,0 @@ -include .defs.mk - -TYPE := ndbapi - -BIN_TARGET := mgmtclient -BIN_TARGET_LIBS := -BIN_TARGET_ARCHIVES := trace logger mgmapi general mgmsrvcommon portlib repapi - -BIN_TARGET_ARCHIVES += editline - -DIRS = test_cpcd - -# Source files of non-templated classes (.cpp files) -SOURCES = \ - main.cpp \ - CommandInterpreter.cpp \ - CpcClient.cpp - -CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/include/mgmapi) \ - -I$(call fixpath,$(NDB_TOP)/src/common/mgmcommon) - -include $(NDB_TOP)/Epilogue.mk - -_bins_mkconfig : $(NDB_TOP)/bin/$(BIN_TARGET) - diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp index cc6d4bf600e..73f0bad86c0 100644 --- a/ndb/src/mgmclient/main.cpp +++ b/ndb/src/mgmclient/main.cpp @@ -15,19 +15,32 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> +#include <ndb_opts.h> + +// copied from mysql.cc to get readline +extern "C" { +#if defined( __WIN__) || defined(OS2) +#include <conio.h> +#elif !defined(__NETWARE__) +#include <readline/readline.h> +extern "C" int add_history(const char *command); /* From readline directory */ +#define HAVE_READLINE +#endif +} #include <NdbMain.h> #include <NdbHost.h> -#include <util/getarg.h> +#include <BaseString.hpp> +#include <NdbOut.hpp> #include <mgmapi.h> -#include <LocalConfig.hpp> +#include <ndb_version.h> -#include "CommandInterpreter.hpp" +#include "ndb_mgmclient.hpp" const char *progname = "ndb_mgm"; -static CommandInterpreter* com; +static Ndb_mgmclient* com; extern "C" void @@ -43,59 +56,117 @@ handler(int sig){ } } -int main(int argc, const char** argv){ - ndb_init(); - int optind = 0; +NDB_STD_OPTS_VARS; + +static const char default_prompt[]= "ndb_mgm> "; +static unsigned _try_reconnect; +static const char *prompt= default_prompt; +static char *opt_execute_str= 0; + +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_mgm"), + { "execute", 'e', + "execute command and exit", + (gptr*) &opt_execute_str, (gptr*) &opt_execute_str, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "try-reconnect", 't', + "Specify number of tries for connecting to ndb_mgmd (0 = infinite)", + (gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0, + GET_UINT, REQUIRED_ARG, 3, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void short_usage_sub(void) +{ + printf("Usage: %s [OPTIONS] [hostname [port]]\n", my_progname); +} +static void usage() +{ + short_usage_sub(); + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_mgm.trace"); +} + +static int +read_and_execute(int _try_reconnect) +{ + static char *line_read = (char *)NULL; + + /* If the buffer has already been allocated, return the memory + to the free pool. */ + if (line_read) + { + free (line_read); + line_read = (char *)NULL; + } +#ifdef HAVE_READLINE + /* Get a line from the user. */ + line_read = readline (prompt); + /* If the line has any text in it, save it on the history. */ + if (line_read && *line_read) + add_history (line_read); +#else + static char linebuffer[254]; + fputs(prompt, stdout); + linebuffer[sizeof(linebuffer)-1]=0; + line_read = fgets(linebuffer, sizeof(linebuffer)-1, stdin); + if (line_read == linebuffer) { + char *q=linebuffer; + while (*q > 31) q++; + *q=0; + line_read= strdup(linebuffer); + } +#endif + return com->execute(line_read,_try_reconnect); +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); const char *_host = 0; int _port = 0; - int _help = 0; - int _try_reconnect = 0; - - struct getargs args[] = { - { "try-reconnect", 't', arg_integer, &_try_reconnect, "Specify number of retries for connecting to ndb_mgmd, default infinite", "#" }, - { "usage", '?', arg_flag, &_help, "Print help", "" }, - }; - int num_args = sizeof(args) / sizeof(args[0]); /* Number of arguments */ - - - if(getarg(args, num_args, argc, argv, &optind) || _help) { - arg_printusage(args, num_args, progname, "[host [port]]"); - exit(1); - } + const char *load_default_groups[]= { "mysql_cluster","ndb_mgm",0 }; + + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + exit(ho_error); - argv += optind; - argc -= optind; - - LocalConfig cfg; - - if(argc >= 1) { - _host = argv[0]; - if(argc >= 2) { - _port = atoi(argv[1]); - } - } else { - if(cfg.init(0, 0) && cfg.ids.size() > 0 && cfg.ids[0].type == MgmId_TCP){ - _host = cfg.ids[0].name.c_str(); - _port = cfg.ids[0].port; - } else { - cfg.printError(); - cfg.printUsage(); - return 1; - } - } - char buf[MAXHOSTNAMELEN+10]; - BaseString::snprintf(buf, sizeof(buf), "%s:%d", _host, _port); + if(argc == 1) { + BaseString::snprintf(buf, sizeof(buf), "%s", argv[0]); + opt_connect_str= buf; + } else if (argc >= 2) { + BaseString::snprintf(buf, sizeof(buf), "%s:%s", argv[0], argv[1]); + opt_connect_str= buf; + } - ndbout << "-- NDB Cluster -- Management Client --" << endl; - printf("Connecting to Management Server: %s\n", buf); + if (!isatty(0) || opt_execute_str) + { + prompt= 0; + } signal(SIGPIPE, handler); - - com = new CommandInterpreter(buf); - while(com->readAndExecute(_try_reconnect)); + com = new Ndb_mgmclient(opt_connect_str,1); + int ret= 0; + if (!opt_execute_str) + { + ndbout << "-- NDB Cluster -- Management Client --" << endl; + while(read_and_execute(_try_reconnect)); + } + else + { + com->execute(opt_execute_str,_try_reconnect, &ret); + } delete com; - return 0; + return ret; } diff --git a/ndb/src/mgmclient/ndb_mgmclient.h b/ndb/src/mgmclient/ndb_mgmclient.h new file mode 100644 index 00000000000..b62a33999a3 --- /dev/null +++ b/ndb/src/mgmclient/ndb_mgmclient.h @@ -0,0 +1,33 @@ +/* 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_mgmclient_h +#define Ndb_mgmclient_h + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void* Ndb_mgmclient_handle; +Ndb_mgmclient_handle ndb_mgmclient_handle_create(const char *connect_string); +int ndb_mgmclient_execute(Ndb_mgmclient_handle, int argc, char** argv); +int ndb_mgmclient_handle_destroy(Ndb_mgmclient_handle); + +#ifdef __cplusplus +} +#endif + +#endif /* Ndb_mgmclient_h */ diff --git a/ndb/src/mgmclient/ndb_mgmclient.hpp b/ndb/src/mgmclient/ndb_mgmclient.hpp new file mode 100644 index 00000000000..bffdf69f920 --- /dev/null +++ b/ndb/src/mgmclient/ndb_mgmclient.hpp @@ -0,0 +1,33 @@ +/* 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_mgmclient_hpp +#define Ndb_mgmclient_hpp + +class CommandInterpreter; +class Ndb_mgmclient +{ +public: + Ndb_mgmclient(const char*,int verbose=0); + ~Ndb_mgmclient(); + int execute(const char *_line, int _try_reconnect=-1, int *error= 0); + int execute(int argc, char** argv, int _try_reconnect=-1, int *error= 0); + int disconnect(); +private: + CommandInterpreter *m_cmd; +}; + +#endif // Ndb_mgmclient_hpp diff --git a/ndb/src/mgmsrv/CommandInterpreter.cpp b/ndb/src/mgmsrv/CommandInterpreter.cpp index 2a054a01f1e..686155415d5 100644 --- a/ndb/src/mgmsrv/CommandInterpreter.cpp +++ b/ndb/src/mgmsrv/CommandInterpreter.cpp @@ -28,66 +28,12 @@ #include "ConfigInfo.hpp" #include <version.h> - - -static const char* helpTexts[] = { - "HELP Print help text", - "HELP SHOW Help for the SHOW command", -#ifdef VM_TRACE // DEBUG ONLY - "HELP DEBUG Help for debug compiled version", -#endif - "SHOW Print information about cluster", - "SHOW CONFIG Print configuration", - "SHOW PARAMETERS Print configuration parameters", - "START BACKUP Start backup\n" - "ABORT BACKUP <backup id> Aborts backup\n" - "CLUSTERLOG ON Enable Cluster logging", - "CLUSTERLOG OFF Disable Cluster logging", - "CLUSTERLOG FILTER <severity> Toggle severity filter on/off", - "CLUSTERLOG INFO Print cluster log information", - "{<id>|ALL} START Start DB node (started with -n)", - "{<id>|ALL} RESTART [-n] [-i] Restart DB node", - "{<id>|ALL} STOP Stop DB node", - "{<id>|ALL} STATUS Print status", - "{<id>|ALL} CLUSTERLOG {<category>=<level>}+ Set log level for cluster log", - "QUIT Quit management server", -}; -static const unsigned noOfHelpTexts = sizeof(helpTexts)/sizeof(const char*); - -static const char* helpTextShow = -"SHOW prints NDB Cluster information\n\n" -"SHOW Print information about cluster\n" -"SHOW CONFIG Print configuration (in initial config file format)\n" -"SHOW PARAMETERS Print information about configuration parameters\n\n" -; - -#ifdef VM_TRACE // DEBUG ONLY -static const char* helpTextDebug = -"SHOW PROPERTIES Print config properties object\n" -"{<id>|ALL} LOGLEVEL {<category>=<level>}+ Set log level\n" -"{<id>|ALL} ERROR <errorNo> Inject error into NDB node\n" -"{<id>|ALL} TRACE <traceNo> Set trace number\n" -"{<id>|ALL} LOG [BLOCK = {ALL|<block>+}] Set logging on in & out signals\n" -"{<id>|ALL} LOGIN [BLOCK = {ALL|<block>+}] Set logging on in signals\n" -"{<id>|ALL} LOGOUT [BLOCK = {ALL|<block>+}] Set logging on out signals\n" -"{<id>|ALL} LOGOFF [BLOCK = {ALL|<block>+}] Unset signal logging\n" -"{<id>|ALL} TESTON Start signal logging\n" -"{<id>|ALL} TESTOFF Stop signal logging\n" -"{<id>|ALL} SET <configParamName> <value> Update configuration variable\n" -"{<id>|ALL} DUMP <arg> Dump system state to cluster.log\n" -"{<id>|ALL} GETSTAT Print statistics\n" -"\n" -; -#endif - - +#include <m_string.h> //****************************************************************************** //****************************************************************************** CommandInterpreter::CommandInterpreter(MgmtSrvr& mgmtSrvr) : _mgmtSrvr(mgmtSrvr) { - - // _mgmtSrvr.setCallback(CmdBackupCallback); } @@ -113,6 +59,11 @@ private: void * m_ptr; }; +const char *CommandInterpreter::get_error_text(int err_no) +{ + return _mgmtSrvr.getErrorText(err_no, m_err_str, sizeof(m_err_str)); +} + //***************************************************************************** //***************************************************************************** int CommandInterpreter::readAndExecute() { @@ -140,52 +91,7 @@ int CommandInterpreter::readAndExecute() { char* firstToken = strtok(line, " "); char* allAfterFirstToken = strtok(NULL, "\0"); - if (strcmp(firstToken, "HELP") == 0) { - executeHelp(allAfterFirstToken); - return true; - } - else if (strcmp(firstToken, "?") == 0) { - executeHelp(allAfterFirstToken); - return true; - } - else if (strcmp(firstToken, "SHOW") == 0) { - executeShow(allAfterFirstToken); - return true; - } - else if (strcmp(firstToken, "CLUSTERLOG") == 0) { - executeClusterLog(allAfterFirstToken); - return true; - } - else if(strcmp(firstToken, "START") == 0 && - allAfterFirstToken != 0 && - strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ - executeStartBackup(allAfterFirstToken); - return true; - } - else if(strcmp(firstToken, "ABORT") == 0 && - allAfterFirstToken != 0 && - strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ - executeAbortBackup(allAfterFirstToken); - return true; - } - - else if(strcmp(firstToken, "ENTER") == 0 && - allAfterFirstToken != 0 && - strncmp(allAfterFirstToken, "SINGLE USER MODE ", - sizeof("SINGLE USER MODE") - 1) == 0){ - executeEnterSingleUser(allAfterFirstToken); - return true; - } - - else if(strcmp(firstToken, "EXIT") == 0 && - allAfterFirstToken != 0 && - strncmp(allAfterFirstToken, "SINGLE USER MODE ", - sizeof("SINGLE USER MODE") - 1) == 0){ - executeExitSingleUser(allAfterFirstToken); - return true; - } - - else if (strcmp(firstToken, "ALL") == 0) { + if (strcmp(firstToken, "ALL") == 0) { analyseAfterFirstToken(-1, allAfterFirstToken); } else if(strcmp(firstToken, "QUIT") == 0 || @@ -198,7 +104,6 @@ int CommandInterpreter::readAndExecute() { int processId; if (! convert(firstToken, processId)) { ndbout << "Invalid command: " << _line << "." << endl; - ndbout << "Type HELP for help." << endl << endl; return true; } if (processId < 0) { @@ -214,24 +119,10 @@ int CommandInterpreter::readAndExecute() { static const CommandInterpreter::CommandFunctionPair commands[] = { - { "START", &CommandInterpreter::executeStart } - ,{ "RESTART", &CommandInterpreter::executeRestart } - ,{ "STOP", &CommandInterpreter::executeStop } - ,{ "STATUS", &CommandInterpreter::executeStatus } - ,{ "LOGLEVEL", &CommandInterpreter::executeLogLevel } -#ifdef ERROR_INSERT - ,{ "ERROR", &CommandInterpreter::executeError } -#endif - ,{ "TRACE", &CommandInterpreter::executeTrace } - ,{ "LOG", &CommandInterpreter::executeLog } + { "TRACE", &CommandInterpreter::executeTrace } ,{ "LOGIN", &CommandInterpreter::executeLogIn } ,{ "LOGOUT", &CommandInterpreter::executeLogOut } ,{ "LOGOFF", &CommandInterpreter::executeLogOff } - ,{ "TESTON", &CommandInterpreter::executeTestOn } - ,{ "TESTOFF", &CommandInterpreter::executeTestOff } - ,{ "CLUSTERLOG", &CommandInterpreter::executeEventReporting } - ,{ "DUMP", &CommandInterpreter::executeDumpState } - ,{ "JONAS", &CommandInterpreter::jonas } }; @@ -268,16 +159,14 @@ CommandInterpreter::analyseAfterFirstToken(int processId, if(fun == 0){ ndbout << "Invalid command: " << secondToken << "." << endl; - ndbout << "Type HELP for help." << endl << endl; return; } if(processId == -1){ executeForAll(command, fun, allAfterSecondToken); } else { - if(strcmp(command, "STATUS") != 0) - ndbout << "Executing " << command << " on node: " - << processId << endl << endl; + ndbout << "Executing " << command << " on node: " + << processId << endl << endl; (this->*fun)(processId, allAfterSecondToken, false); ndbout << endl; } @@ -288,18 +177,11 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, const char * allAfterSecondToken){ NodeId nodeId = 0; - if(strcmp(cmd, "STOP") == 0 || - strcmp(cmd, "RESTART") == 0){ - ndbout << "Executing " << cmd << " on all nodes" << endl << "\n"; + while(_mgmtSrvr.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)){ + ndbout << "Executing " << cmd << " on node: " + << nodeId << endl << endl; (this->*fun)(nodeId, allAfterSecondToken, true); - } else { - while(_mgmtSrvr.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)){ - if(strcmp(cmd, "STATUS") != 0) - ndbout << "Executing " << cmd << " on node: " - << nodeId << endl << endl; - (this->*fun)(nodeId, allAfterSecondToken, true); - ndbout << endl; - } // for + ndbout << endl; } } @@ -369,620 +251,6 @@ bool CommandInterpreter::parseBlockSpecification(const char* allAfterLog, return true; } - - -//****************************************************************************** -//****************************************************************************** -void CommandInterpreter::executeHelp(char* parameters) { - - (void)parameters; // Don't want compiler warning - - if (emptyString(parameters)) { - unsigned i; - for (i = 0; i<noOfHelpTexts; i++) { - ndbout << helpTexts[i] << endl; - } - - ndbout << endl - << "<severity> = " - << "ALERT | CRITICAL | ERROR | WARNING | INFO | DEBUG" - << endl; - - ndbout << "<category> = "; - for(i = 0; i<CFG_MIN_LOGLEVEL; i++){ - ndbout << ndb_mgm_get_event_category_string((ndb_mgm_event_category)i); - if (i < CFG_MIN_LOGLEVEL - 1) { - ndbout << " | "; - } - } - ndbout << endl; - - ndbout << "<level> = " << "0 - 15" - << endl; - - ndbout << endl; - } else if (strcmp(parameters, "SHOW") == 0) { - ndbout << helpTextShow; -#ifdef VM_TRACE // DEBUG ONLY - } else if (strcmp(parameters, "DEBUG") == 0) { - ndbout << helpTextDebug; -#endif - } else { - ndbout << "Invalid argument." << endl; - } -} - -//***************************************************************************** -//***************************************************************************** - -void CommandInterpreter::executeShow(char* parameters) { - - if (emptyString(parameters)) { - ndbout << "Cluster Configuration" << endl - << "---------------------" << endl; - - NodeId nodeId = 0; - ndbout << _mgmtSrvr.getNodeCount(NDB_MGM_NODE_TYPE_NDB) - << " NDB Node(s) with" - << endl; - while (_mgmtSrvr.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)){ - ndbout << " Node Id = " << nodeId << endl; - } - ndbout << endl; - - nodeId = 0; - ndbout << _mgmtSrvr.getNodeCount(NDB_MGM_NODE_TYPE_API) - << " API Node(s) with" - << endl; - while (_mgmtSrvr.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_API)){ - ndbout << " Node Id = " << nodeId << endl; - } - ndbout << endl; - - nodeId = 0; - ndbout << _mgmtSrvr.getNodeCount(NDB_MGM_NODE_TYPE_MGM) - << " MGM Node(s) with" - << endl; - while (_mgmtSrvr.getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_MGM)){ - ndbout << " Node Id = " << nodeId << endl; - } - ndbout << endl; - - ndbout << helpTextShow; - - return; - } else if (strcmp(parameters, "PROPERTIES") == 0 || - strcmp(parameters, "PROP") == 0) { - ndbout << "_mgmtSrvr.getConfig()->print();" << endl; /* XXX */ - } else if (strcmp(parameters, "CONFIGURATION") == 0 || - strcmp(parameters, "CONFIG") == 0){ - ndbout << "_mgmtSrvr.getConfigFile()->print();" << endl; /* XXX */ - _mgmtSrvr.getConfig()->printConfigFile(); - } else if (strcmp(parameters, "PARAMETERS") == 0 || - strcmp(parameters, "PARAMS") == 0 || - strcmp(parameters, "PARAM") == 0) { - ndbout << "_mgmtSrvr.getConfigInfo()->print();" << endl; /* XXX */ - } else { - ndbout << "Invalid argument." << endl; - } -} - - -//***************************************************************************** -//***************************************************************************** -void CommandInterpreter::executeClusterLog(char* parameters) { - - if (parameters != 0 && strlen(parameters) != 0) { - int severity = 7; - int isOk = true; - char name[12]; - bool noArgs = false; - - char * tmpString = strdup(parameters); - char * tmpPtr = 0; - char * item = strtok_r(tmpString, " ", &tmpPtr); - - /******************** - * CLUSTERLOG FILTER - ********************/ - if (strcmp(item, "FILTER") == 0) { - - item = strtok_r(NULL, " ", &tmpPtr); - if (item == NULL) { - noArgs = true; - } - while (item != NULL) { - snprintf(name, 12, item); - - if (strcmp(item, "ALL") == 0) { - severity = 7; - } else if (strcmp(item, "ALERT") == 0) { - severity = 6; - } else if (strcmp(item, "CRITICAL") == 0) { - severity = 5; - } else if (strcmp(item, "ERROR") == 0) { - severity = 4; - } else if (strcmp(item, "WARNING") == 0) { - severity = 3; - } else if (strcmp(item, "INFO") == 0) { - severity = 2; - } else if (strcmp(item, "DEBUG") == 0) { - severity = 1; - } else if (strcmp(item, "OFF") == 0) { - severity = 0; - } else { - isOk = false; - } - - item = strtok_r(NULL, " ", &tmpPtr); - } // while(item != NULL){ - free(tmpString); - - if (noArgs) { - ndbout << "Missing argument(s)." << endl; - } else if (isOk) { - if (_mgmtSrvr.setEventLogFilter(severity)) { - if(strcmp(name, "ALL") == 0 || strcmp(name, "all") == 0) { - ndbout << "All severities levels enabled." << endl; - } else if(strcmp(name, "OFF") == 0 || strcmp(name, "off") == 0) { - ndbout << "Cluster logging disabled." << endl; - } else { - ndbout << name << " events enabled." << endl; - } - } else { - if(strcmp(name, "ALL") == 0) { - ndbout << "All severities levels disabled." << endl; - } else if(strcmp(name, "OFF") == 0) { - ndbout << "Cluster logging enabled." << endl; - } else { - ndbout << name << " events disabled." << endl; - } - } - } else { - ndbout << "Invalid severity level." << endl; - } - - /******************** - * CLUSTERLOG INFO - ********************/ - } else if (strcmp(item, "INFO") == 0) { - const char* names[] = {"DEBUG", "INFO", "WARNING", "ERROR", - "CRITICAL", "ALERT"}; - if (_mgmtSrvr.isEventLogFilterEnabled(0)) { // OFF - ndbout << "Cluster logging is disabled." << endl; - } - - ndbout << "Severities enabled: "; - for (int i = 0; i < 6; i++) { - if (_mgmtSrvr.isEventLogFilterEnabled(i + 1)) { - ndbout << names[i] << " "; - } - } - ndbout << endl; - - /******************** - * CLUSTERLOG OFF - ********************/ - } else if (strcmp(item, "OFF") == 0) { - if (!_mgmtSrvr.isEventLogFilterEnabled(0)) { // ON - if (_mgmtSrvr.setEventLogFilter(0)); - ndbout << "Cluster logging is disabled." << endl; - } else { - ndbout << "Cluster logging is already disabled." << endl; - } - - /******************** - * CLUSTERLOG ON - ********************/ - } else if (strcmp(item, "ON") == 0) { - if (_mgmtSrvr.isEventLogFilterEnabled(0)) { // OFF - if (_mgmtSrvr.setEventLogFilter(0)); - ndbout << "Cluster logging is enabled." << endl; - } else { - ndbout << "Cluster logging is already enabled." << endl; - } - - } else { - ndbout << "Invalid argument." << endl; - } - - } else { - ndbout << "Missing argument." << endl; - } -} - -void -stopCallback(int nodeId, void * anyData, int errCode){ - if(errCode == 0){ - if(nodeId == 0) - ndbout << "\nCluster has shutdown" << endl; - else - ndbout << "\nNode " << nodeId << " has shutdown" << endl; - } else { - MgmtSrvr * mgm = (MgmtSrvr *)anyData; - ndbout << "Node " << nodeId << " has not shutdown: " - << mgm->getErrorText(errCode) << endl; - } -} - -void -versionCallback(int nodeId, int version, void * anyData, int errCode){ - if(errCode == 0){ - MgmtSrvr * mgm = (MgmtSrvr *)anyData; - switch(mgm->getNodeType(nodeId)){ - case NDB_MGM_NODE_TYPE_MGM: - { - ndbout << "MGMT node:\t" << nodeId << " "; - ndbout_c(" (Version %d.%d.%d)", - getMajor(version) , - getMinor(version), - getBuild(version)); - } - break; - case NDB_MGM_NODE_TYPE_NDB: - { - ndbout << "DB node:\t" << nodeId << " "; - if(version == 0) - ndbout << "(no version information available)" << endl; - else { - ndbout_c(" (Version %d.%d.%d)", - getMajor(version) , - getMinor(version), - getBuild(version)); - } - } - break; - case NDB_MGM_NODE_TYPE_API: - { - ndbout << "API node:\t" << nodeId << " "; - if(version == 0) - ndbout << "(no version information available)" << endl; - else { - ndbout_c(" (Version %d.%d.%d)", - getMajor(version) , - getMinor(version), - getBuild(version)); - } - - } - break; - case NDB_MGM_NODE_TYPE_UNKNOWN: - case NDB_MGM_NODE_TYPE_REP: - abort(); - }; - - } else { - MgmtSrvr * mgm = (MgmtSrvr *)anyData; - ndbout << mgm->getErrorText(errCode) << endl; - } -} - -//***************************************************************************** -//***************************************************************************** -void CommandInterpreter::executeStop(int processId, - const char* parameters, bool all) { - - (void)parameters; // Don't want compiler warning - - int result = 0; - if(all) - result = _mgmtSrvr.stop((int *)0, false, stopCallback, this); - else - result = _mgmtSrvr.stopNode(processId, false, stopCallback, this); - - if(result != 0) - ndbout << _mgmtSrvr.getErrorText(result) << endl; -} - - -void CommandInterpreter::executeStart(int processId, const char* parameters, - bool all) { - (void)all; // Don't want compiler warning - - if (! emptyString(parameters)) { - ndbout << "No parameters expected to this command." << endl; - return; - } - - int result = _mgmtSrvr.start(processId); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } -} - -void -CommandInterpreter::executeRestart(int processId, const char* parameters, - bool all) { - - bool nostart = false; - bool initialstart = false; - - if(parameters != 0 && strlen(parameters) != 0){ - char * tmpString = strdup(parameters); - char * tmpPtr = 0; - char * item = strtok_r(tmpString, " ", &tmpPtr); - while(item != NULL){ - if(strcmp(item, "-N") == 0) - nostart = true; - if(strcmp(item, "-I") == 0) - initialstart = true; - item = strtok_r(NULL, " ", &tmpPtr); - } - free(tmpString); - } - int result; - if(all) - result = _mgmtSrvr.restart(nostart, initialstart, false, - 0, stopCallback, this); - else - result = _mgmtSrvr.restartNode(processId, nostart, initialstart, false, - stopCallback, - this); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } -} - -void -CommandInterpreter::executeDumpState(int processId, const char* parameters, - bool all) { - - (void)all; // Don't want compiler warning - - if(parameters == 0 || strlen(parameters) == 0){ - ndbout << "Expected argument" << endl; - return; - } - - Uint32 no = 0; - Uint32 pars[25]; - - char * tmpString = strdup(parameters); - char * tmpPtr = 0; - char * item = strtok_r(tmpString, " ", &tmpPtr); - while(item != NULL){ - if (0x0 <= strtoll(item, NULL, 0) && strtoll(item, NULL, 0) <= 0xffffffff) { - pars[no] = strtoll(item, NULL, 0); - } else { - ndbout << "Illegal value in argument to signal." << endl - << "(Value must be between 0 and 0xffffffff.)" - << endl; - return; - } - no++; - item = strtok_r(NULL, " ", &tmpPtr); - } - ndbout << "Sending dump signal with data:" << endl; - for (Uint32 i=0; i<no; i++) { - ndbout.setHexFormat(1) << pars[i] << " "; - if (!(i+1 & 0x3)) ndbout << endl; - } - free(tmpString); - int result = _mgmtSrvr.dumpState(processId, pars, no); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } -} - -void CommandInterpreter::executeStatus(int processId, - const char* parameters, bool all) { - - (void)all; // Don't want compiler warning - - if (! emptyString(parameters)) { - ndbout << "No parameters expected to this command." << endl; - return; - } - - ndb_mgm_node_status status; - Uint32 startPhase, version, dynamicId, nodeGroup, connectCount; - bool system; - int result = _mgmtSrvr.status(processId, - &status, &version, &startPhase, &system, - &dynamicId, &nodeGroup, &connectCount); - if(result != 0){ - ndbout << _mgmtSrvr.getErrorText(result) << endl; - return; - } - - ndbout << "Node " << processId << ": "; - switch(status){ - case NDB_MGM_NODE_STATUS_NO_CONTACT: - ndbout << "No contact" << endl; - break; - case NDB_MGM_NODE_STATUS_NOT_STARTED: - ndbout << "Not started" ; - break; - case NDB_MGM_NODE_STATUS_STARTING: - ndbout << "Starting (Start phase " << startPhase << ")" ; - break; - case NDB_MGM_NODE_STATUS_STARTED: - ndbout << "Started" ; - break; - case NDB_MGM_NODE_STATUS_SHUTTING_DOWN: - ndbout << "Shutting down " << (system == false ? "node" : "system") - << " (Phase " << startPhase << ")" - ; - break; - case NDB_MGM_NODE_STATUS_RESTARTING: - ndbout << "Restarting" ; - break; - case NDB_MGM_NODE_STATUS_SINGLEUSER: - ndbout << "Single user mode" ; - break; - default: - ndbout << "Unknown state" ; - break; - } - if(status != NDB_MGM_NODE_STATUS_NO_CONTACT){ - - ndbout_c(" (Version %d.%d.%d)", - getMajor(version) , - getMinor(version), - getBuild(version)); - - // NOTE It's possible to print dynamicId and nodeGroup here ... - // ndbout << ", " <<dynamicId<<", "<<nodeGroup<<endl; - } -} - - - -//***************************************************************************** -//***************************************************************************** -void CommandInterpreter::executeLogLevel(int processId, - const char* parameters, bool all) { -#if 0 - (void)all; // Don't want compiler warning - SetLogLevelOrd logLevel; logLevel.clear(); - - if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) { - for(Uint32 i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++) - logLevel.setLogLevel(EventLoggerBase::eventCategoryNames[i].category, 7); - } else { - - char * tmpString = strdup(parameters); - char * tmpPtr = 0; - char * item = strtok_r(tmpString, ", ", &tmpPtr); - while(item != NULL){ - char categoryTxt[255]; - int level; - const int m = sscanf(item, "%[^=]=%d", categoryTxt, &level); - if(m != 2){ - free(tmpString); - ndbout << "Invalid loglevel specification category=level" << endl; - return; - } - LogLevel::EventCategory cat; - if(!EventLoggerBase::matchEventCategory(categoryTxt, - &cat)){ - ndbout << "Invalid loglevel specification, unknown category: " - << categoryTxt << endl; - free(tmpString); - return ; - } - if(level < 0 || level > 15){ - ndbout << "Invalid loglevel specification row, level 0-15" << endl; - free(tmpString); - return ; - } - logLevel.setLogLevel(cat, level); - - item = strtok_r(NULL, ", ", &tmpPtr); - } - free(tmpString); - } - - int result = _mgmtSrvr.setNodeLogLevel(processId, logLevel); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } -#endif -} - - - -//***************************************************************************** -//***************************************************************************** -void CommandInterpreter::executeError(int processId, - const char* parameters, bool all) { - - (void)all; // Don't want compiler warning - - if (emptyString(parameters)) { - ndbout << "Missing error number." << endl; - return; - } - // Copy parameters since strtok will modify it - char* newpar = strdup(parameters); - char* firstParameter = strtok(newpar, " "); - - int errorNo; - if (! convert(firstParameter, errorNo)) { - ndbout << "Expected an integer." << endl; - free(newpar); - return; - } - - char* allAfterFirstParameter = strtok(NULL, "\0"); - if (! emptyString(allAfterFirstParameter)) { - ndbout << "Nothing expected after error number." << endl; - free(newpar); - return; - } - - int result = _mgmtSrvr.insertError(processId, errorNo); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } - free(newpar); -} - - - -//****************************************************************************** -//****************************************************************************** -void CommandInterpreter::executeTrace(int processId, - const char* parameters, bool all) { - - (void)all; // Don't want compiler warning - - if (emptyString(parameters)) { - ndbout << "Missing trace number." << endl; - return; - } - - char* newpar = strdup(parameters); - char* firstParameter = strtok(newpar, " "); - - - int traceNo; - if (! convert(firstParameter, traceNo)) { - ndbout << "Expected an integer." << endl; - free(newpar); - return; - } - - char* allAfterFirstParameter = strtok(NULL, "\0"); - - if (! emptyString(allAfterFirstParameter)) { - ndbout << "Nothing expected after trace number." << endl; - free(newpar); - return; - } - - int result = _mgmtSrvr.setTraceNo(processId, traceNo); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } - free(newpar); -} - - - -//****************************************************************************** -//****************************************************************************** -void CommandInterpreter::executeLog(int processId, - const char* parameters, bool all) { - - (void)all; // Don't want compiler warning - - Vector<BaseString> blocks; - if (! parseBlockSpecification(parameters, blocks)) { - return; - } - - int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::InOut, blocks); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } - -} - - - -//****************************************************************************** -//****************************************************************************** void CommandInterpreter::executeLogIn(int processId, const char* parameters, bool all) { @@ -995,7 +263,7 @@ void CommandInterpreter::executeLogIn(int processId, int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::In, blocks); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -1014,7 +282,7 @@ void CommandInterpreter::executeLogOut(int processId, int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Out, blocks); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } @@ -1035,215 +303,43 @@ void CommandInterpreter::executeLogOff(int processId, int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Off, blocks); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; + ndbout << get_error_text(result) << endl; } } -//****************************************************************************** -//****************************************************************************** -void CommandInterpreter::executeTestOn(int processId, - const char* parameters, bool all) { +void CommandInterpreter::executeTrace(int processId, + const char* parameters, bool all) { (void)all; // Don't want compiler warning - if (! emptyString(parameters)) { - ndbout << "No parameters expected to this command." << endl; + if (emptyString(parameters)) { + ndbout << "Missing trace number." << endl; return; } - int result = _mgmtSrvr.startSignalTracing(processId); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } - -} - -//****************************************************************************** -//****************************************************************************** -void CommandInterpreter::executeTestOff(int processId, - const char* parameters, bool all) { + char* newpar = strdup(parameters); + char* firstParameter = strtok(newpar, " "); - (void)all; // Don't want compiler warning - if (! emptyString(parameters)) { - ndbout << "No parameters expected to this command." << endl; + int traceNo; + if (! convert(firstParameter, traceNo)) { + ndbout << "Expected an integer." << endl; + free(newpar); return; } - int result = _mgmtSrvr.stopSignalTracing(processId); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } - -} - -//***************************************************************************** -//***************************************************************************** -void CommandInterpreter::executeEventReporting(int processId, - const char* parameters, - bool all) { -#if 0 - (void)all; // Don't want compiler warning - SetLogLevelOrd logLevel; logLevel.clear(); - - if (emptyString(parameters) || (strcmp(parameters, "ALL") == 0)) { - for(Uint32 i = 0; i<EventLoggerBase::noOfEventCategoryNames; i++) - logLevel.setLogLevel(EventLoggerBase::eventCategoryNames[i].category, 7); - } else { - - char * tmpString = strdup(parameters); - char * tmpPtr = 0; - char * item = strtok_r(tmpString, ", ", &tmpPtr); - while(item != NULL){ - char categoryTxt[255]; - int level; - const int m = sscanf(item, "%[^=]=%d", categoryTxt, &level); - if(m != 2){ - free(tmpString); - ndbout << "Invalid loglevel specification category=level" << endl; - return; - } - LogLevel::EventCategory cat; - if(!EventLoggerBase::matchEventCategory(categoryTxt, - &cat)){ - ndbout << "Invalid loglevel specification, unknown category: " - << categoryTxt << endl; - free(tmpString); - return ; - } - if(level < 0 || level > 15){ - ndbout << "Invalid loglevel specification row, level 0-15" << endl; - free(tmpString); - return ; - } - logLevel.setLogLevel(cat, level); - - item = strtok_r(NULL, ", ", &tmpPtr); - } - free(tmpString); - } - ndbout_c("processId %d", processId); - int result = _mgmtSrvr.setEventReportingLevel(processId, logLevel); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } -#endif -} - -void -CommandInterpreter::executeStartBackup(char* parameters) { - Uint32 backupId; - int result = _mgmtSrvr.startBackup(backupId); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } else { - // ndbout << "Start of backup ordered" << endl; - } -} + char* allAfterFirstParameter = strtok(NULL, "\0"); -void -CommandInterpreter::executeAbortBackup(char* parameters) { - strtok(parameters, " "); - char* id = strtok(NULL, "\0"); - int bid = -1; - if(id == 0 || sscanf(id, "%d", &bid) != 1){ - ndbout << "Invalid arguments: expected <BackupId>" << endl; + if (! emptyString(allAfterFirstParameter)) { + ndbout << "Nothing expected after trace number." << endl; + free(newpar); return; } - int result = _mgmtSrvr.abortBackup(bid); - if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } else { - ndbout << "Abort of backup " << bid << " ordered" << endl; - } -} - - -void -CommandInterpreter::executeEnterSingleUser(char* parameters) { - strtok(parameters, " "); - char* id = strtok(NULL, " "); - id = strtok(NULL, " "); - id = strtok(NULL, "\0"); - int nodeId = -1; - if(id == 0 || sscanf(id, "%d", &nodeId) != 1){ - ndbout << "Invalid arguments: expected <NodeId>" << endl; - return; - } - int result = _mgmtSrvr.enterSingleUser(0, nodeId,0,0); + int result = _mgmtSrvr.setTraceNo(processId, traceNo); if (result != 0) { - ndbout << _mgmtSrvr.getErrorText(result) << endl; - } else { - ndbout << "Entering single user mode, granting access for node " - << nodeId << " OK." << endl; + ndbout << get_error_text(result) << endl; } -} - -void CommandInterpreter::executeExitSingleUser(char* parameters) { - _mgmtSrvr.exitSingleUser(0,0,0,0); -} - - -#include <NdbApiSignal.hpp> - -void -CommandInterpreter::jonas(int processId, const char* parameters, bool all) { - - MgmtSrvr::Area51 tmp = _mgmtSrvr.getStuff(); - - NdbApiSignal signal(0); - Uint32 * theData = signal.getDataPtrSend(); - Uint32 data[25]; - Uint32 sec0[70]; - Uint32 sec1[123]; - - data[0] = 12; - data[1] = 13; - - unsigned i; - for(i = 0; i<70; i++) - sec0[i] = i; - - for(i = 0; i<123; i++) - sec1[i] = 70+i; - - signal.set(0, CMVMI, GSN_TESTSIG, 3); - signal.m_noOfSections = 2; - signal.m_fragmentInfo = 1; - - LinearSectionPtr ptr[3]; - - theData[0] = 3; - theData[1] = 0; - theData[2] = 7; // FragmentId - - ptr[0].sz = 2; - ptr[0].p = &data[0]; - - ptr[1].sz = 60; - ptr[1].p = &sec0[0]; - - tmp.theFacade->lock_mutex(); - tmp.theRegistry->prepareSend(&signal, 1, theData, processId, ptr); - tmp.theFacade->unlock_mutex(); - - signal.set(0, CMVMI, GSN_TESTSIG, 3); - signal.m_noOfSections = 2; - signal.m_fragmentInfo = 3; - - theData[0] = 0; - theData[1] = 1; - theData[2] = 7; // FragmentId - - ptr[0].sz = 10; - ptr[0].p = &sec0[60]; - - ptr[1].sz = 123; - ptr[1].p = &sec1[0]; - - tmp.theFacade->lock_mutex(); - tmp.theRegistry->prepareSend(&signal, 1, theData, processId, ptr); - tmp.theFacade->unlock_mutex(); + free(newpar); } diff --git a/ndb/src/mgmsrv/CommandInterpreter.hpp b/ndb/src/mgmsrv/CommandInterpreter.hpp index 3466ee76226..6b67d1a5a5f 100644 --- a/ndb/src/mgmsrv/CommandInterpreter.hpp +++ b/ndb/src/mgmsrv/CommandInterpreter.hpp @@ -17,139 +17,57 @@ #ifndef CommandInterpreter_H #define CommandInterpreter_H -//***************************************************************************** -// Author: Peter Lind -//***************************************************************************** - #include <ndb_global.h> #include <Vector.hpp> -#include <editline/editline.h> #include <BaseString.hpp> class MgmtSrvr; -/** - * @class CommandInterpreter - * @brief Reads command line in management client - * - * This class has one public method which reads a command line - * from a stream. It then interpret that commmand line and calls a suitable - * method in the MgmtSrvr class which executes the command. - * - * For command syntax, see the HELP command. - */ class CommandInterpreter { public: - /** - * Constructor - * @param mgmtSrvr: Management server to use when executing commands - */ CommandInterpreter(MgmtSrvr& mgmtSrvr); - - /** - * Reads one line from the stream, parse the line to find - * a command and then calls a suitable method which executes - * the command. - * - * @return true until quit/bye/exit has been typed - */ int readAndExecute(); private: - /** - * Read a string, and return a pointer to it. - * - * @return NULL on EOF. - */ + char m_err_str[1024]; + const char *get_error_text(int err_no); + char *readline_gets () { + static char linebuffer[254]; static char *line_read = (char *)NULL; - // Disable the default file-name completion action of TAB - // rl_bind_key ('\t', rl_insert); - /* If the buffer has already been allocated, return the memory to the free pool. */ if (line_read) - { - free (line_read); - line_read = (char *)NULL; - } + { + free (line_read); + line_read = (char *)NULL; + } /* Get a line from the user. */ - line_read = readline ("NDB> "); - - /* If the line has any text in it, save it on the history. */ - if (line_read && *line_read) - add_history (line_read); - + fputs("ndb_mgmd> ", stdout); + linebuffer[sizeof(linebuffer)-1]=0; + line_read = fgets(linebuffer, sizeof(linebuffer)-1, stdin); + if (line_read == linebuffer) { + char *q=linebuffer; + while (*q > 31) q++; + *q=0; + line_read= strdup(linebuffer); + } return (line_read); } - /** - * Analyse the command line, after the first token. - * - * @param processId: DB process id to send command to or -1 if - * command will be sent to all DB processes. - * @param allAfterFirstToken: What the client gave after the - * first token on the command line - */ void analyseAfterFirstToken(int processId, char* allAfterFirstTokenCstr); - - /** - * Parse the block specification part of the LOG* commands, - * things after LOG*: [BLOCK = {ALL|<blockName>+}] - * - * @param allAfterLog: What the client gave after the second token - * (LOG*) on the command line - * @param blocks, OUT: ALL or name of all the blocks - * @return: true if correct syntax, otherwise false - */ bool parseBlockSpecification(const char* allAfterLog, Vector<BaseString>& blocks); - - /** - * A bunch of execute functions: Executes one of the commands - * - * @param processId: DB process id to send command to - * @param parameters: What the client gave after the command name - * on the command line. - * For example if complete input from user is: "1 LOGLEVEL 22" then the - * parameters argument is the string with everything after LOGLEVEL, in this - * case "22". Each function is responsible to check the parameters argument. - */ - void executeHelp(char* parameters); - void executeShow(char* parameters); - void executeRun(char* parameters); - void executeInfo(char* parameters); - void executeClusterLog(char* parameters); public: - void executeStop(int processId, const char* parameters, bool all); - void executeStart(int processId, const char* parameters, bool all); - void executeRestart(int processId, const char* parameters, bool all); - void executeLogLevel(int processId, const char* parameters, bool all); - void executeError(int processId, const char* parameters, bool all); void executeTrace(int processId, const char* parameters, bool all); - void executeLog(int processId, const char* parameters, bool all); void executeLogIn(int processId, const char* parameters, bool all); void executeLogOut(int processId, const char* parameters, bool all); void executeLogOff(int processId, const char* parameters, bool all); - void executeTestOn(int processId, const char* parameters, bool all); - void executeTestOff(int processId, const char* parameters, bool all); - void executeStatus(int processId, const char* parameters, bool all); - void executeEnterSingleUser(char* parameters); - void executeExitSingleUser(char* parameters); - void executeEventReporting(int processId, const char* parameters, bool all); - void executeDumpState(int processId, const char* parameters, bool all); - void executeStartBackup(char * pars); - void executeAbortBackup(char * pars); - - void jonas(int processId, const char* parameters, bool all); - /** - * A execute function definition - */ public: typedef void (CommandInterpreter::* ExecuteFunction)(int processId, const char * param, diff --git a/ndb/src/mgmsrv/Config.cpp b/ndb/src/mgmsrv/Config.cpp index f9c6a23f909..5ff9cbe04ad 100644 --- a/ndb/src/mgmsrv/Config.cpp +++ b/ndb/src/mgmsrv/Config.cpp @@ -53,27 +53,27 @@ Config::printAllNameValuePairs(NdbOut &out, if(!section->contains(n)) continue; - if (m_info.getStatus(section, n) == ConfigInfo::INTERNAL) + if (m_info.getStatus(section, n) == ConfigInfo::CI_INTERNAL) continue; - if (m_info.getStatus(section, n) == ConfigInfo::DEPRICATED) + if (m_info.getStatus(section, n) == ConfigInfo::CI_DEPRICATED) continue; - if (m_info.getStatus(section, n) == ConfigInfo::NOTIMPLEMENTED) + if (m_info.getStatus(section, n) == ConfigInfo::CI_NOTIMPLEMENTED) continue; out << n << ": "; switch (m_info.getType(section, n)) { - case ConfigInfo::INT: + case ConfigInfo::CI_INT: MGM_REQUIRE(prop->get(n, &int_value)); out << int_value; break; - case ConfigInfo::INT64: + case ConfigInfo::CI_INT64: MGM_REQUIRE(prop->get(n, &int_64)); out << int_64; break; - case ConfigInfo::BOOL: + case ConfigInfo::CI_BOOL: MGM_REQUIRE(prop->get(n, &int_value)); if (int_value) { out << "Y"; @@ -81,11 +81,11 @@ Config::printAllNameValuePairs(NdbOut &out, out << "N"; } break; - case ConfigInfo::STRING: + case ConfigInfo::CI_STRING: MGM_REQUIRE(prop->get(n, &str_value)); out << str_value; break; - case ConfigInfo::SECTION: + case ConfigInfo::CI_SECTION: out << "SECTION"; break; } diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index ad346b30ead..07310e3a8b8 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -15,12 +15,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> +#include <ndb_opt_defaults.h> #include <NdbTCP.h> #include "ConfigInfo.hpp" #include <mgmapi_config_parameters.h> #include <ndb_limits.h> #include "InitConfigFileParser.hpp" +#include <m_string.h> + +extern my_bool opt_ndb_shm; #define MAX_LINE_LENGTH 255 #define KEY_INTERNAL 0 @@ -78,11 +82,12 @@ static bool transformSystem(InitConfigFileParser::Context & ctx, const char *); static bool transformExternalSystem(InitConfigFileParser::Context & ctx, const char *); static bool transformNode(InitConfigFileParser::Context & ctx, const char *); static bool transformExtNode(InitConfigFileParser::Context & ctx, const char *); +static bool checkConnectionSupport(InitConfigFileParser::Context & ctx, const char *); static bool transformConnection(InitConfigFileParser::Context & ctx, const char *); static bool applyDefaultValues(InitConfigFileParser::Context & ctx, const char *); static bool checkMandatory(InitConfigFileParser::Context & ctx, const char *); static bool fixPortNumber(InitConfigFileParser::Context & ctx, const char *); -static bool fixShmkey(InitConfigFileParser::Context & ctx, const char *); +static bool fixShmKey(InitConfigFileParser::Context & ctx, const char *); static bool checkDbConstraints(InitConfigFileParser::Context & ctx, const char *); static bool checkConnectionConstraints(InitConfigFileParser::Context &, const char *); static bool checkTCPConstraints(InitConfigFileParser::Context &, const char *); @@ -94,6 +99,7 @@ static bool fixDepricated(InitConfigFileParser::Context & ctx, const char *); static bool saveInConfigValues(InitConfigFileParser::Context & ctx, const char *); static bool fixFileSystemPath(InitConfigFileParser::Context & ctx, const char * data); static bool fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data); +static bool fixShmUniqueId(InitConfigFileParser::Context & ctx, const char * data); const ConfigInfo::SectionRule ConfigInfo::m_SectionRules[] = { @@ -107,6 +113,13 @@ ConfigInfo::m_SectionRules[] = { { "REP", transformNode, 0 }, { "EXTERNAL REP", transformExtNode, 0 }, + { MGM_TOKEN, fixShmUniqueId, 0 }, + + { "TCP", checkConnectionSupport, 0 }, + { "SHM", checkConnectionSupport, 0 }, + { "SCI", checkConnectionSupport, 0 }, + { "OSE", checkConnectionSupport, 0 }, + { "TCP", transformConnection, 0 }, { "SHM", transformConnection, 0 }, { "SCI", transformConnection, 0 }, @@ -129,15 +142,19 @@ ConfigInfo::m_SectionRules[] = { { "TCP", fixHostname, "HostName1" }, { "TCP", fixHostname, "HostName2" }, + { "SHM", fixHostname, "HostName1" }, + { "SHM", fixHostname, "HostName2" }, { "SCI", fixHostname, "HostName1" }, { "SCI", fixHostname, "HostName2" }, + { "SHM", fixHostname, "HostName1" }, + { "SHM", fixHostname, "HostName2" }, { "OSE", fixHostname, "HostName1" }, { "OSE", fixHostname, "HostName2" }, { "TCP", fixPortNumber, 0 }, // has to come after fixHostName { "SHM", fixPortNumber, 0 }, // has to come after fixHostName { "SCI", fixPortNumber, 0 }, // has to come after fixHostName - //{ "SHM", fixShmKey, 0 }, + { "SHM", fixShmKey, 0 }, /** * fixExtConnection must be after fixNodeId @@ -168,6 +185,8 @@ ConfigInfo::m_SectionRules[] = { { "TCP", checkTCPConstraints, "HostName2" }, { "SCI", checkTCPConstraints, "HostName1" }, { "SCI", checkTCPConstraints, "HostName2" }, + { "SHM", checkTCPConstraints, "HostName1" }, + { "SHM", checkTCPConstraints, "HostName2" }, { "*", checkMandatory, 0 }, @@ -192,6 +211,9 @@ static bool sanity_checks(Vector<ConfigInfo::ConfigRuleSection>§ions, static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>§ions, struct InitConfigFileParser::Context &ctx, const char * rule_data); +static bool set_connection_priorities(Vector<ConfigInfo::ConfigRuleSection>§ions, + struct InitConfigFileParser::Context &ctx, + const char * rule_data); static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>§ions, struct InitConfigFileParser::Context &ctx, const char * rule_data); @@ -203,6 +225,7 @@ const ConfigInfo::ConfigRule ConfigInfo::m_ConfigRules[] = { { sanity_checks, 0 }, { add_node_connections, 0 }, + { set_connection_priorities, 0 }, { add_server_ports, 0 }, { check_node_vs_replicas, 0 }, { 0, 0 } @@ -256,9 +279,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "COMPUTER", "COMPUTER", "Computer section", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, 0, 0, 0 }, @@ -267,9 +290,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Id", "COMPUTER", "Name of computer", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, @@ -278,9 +301,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName", "COMPUTER", "Hostname of computer (e.g. mysql.com)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, @@ -289,9 +312,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ByteOrder", "COMPUTER", 0, - ConfigInfo::DEPRICATED, + ConfigInfo::CI_DEPRICATED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -304,9 +327,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "SYSTEM", "SYSTEM", "System section", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, (const char *)CFG_SECTION_SYSTEM, 0, 0 }, @@ -315,9 +338,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Name", "SYSTEM", "Name of system (NDB Cluster)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, @@ -326,9 +349,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ReplicationRole", "SYSTEM", "Role in Global Replication (None, Primary, or Standby)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -337,9 +360,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "PrimaryMGMNode", "SYSTEM", "Node id of Primary "MGM_TOKEN_PRINT" node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -349,9 +372,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ConfigGenerationNumber", "SYSTEM", "Configuration generation number", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -364,9 +387,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { DB_TOKEN, DB_TOKEN, "Node section", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, (const char *)NODE_TYPE_DB, 0, 0 }, @@ -376,9 +399,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName", DB_TOKEN, "Name of computer for this node", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -387,9 +410,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "System", DB_TOKEN, "Name of system for this node", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -398,9 +421,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Id", DB_TOKEN, "Number identifying the database node ("DB_TOKEN_PRINT")", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "1", STR_VALUE(MAX_NODES) }, @@ -410,9 +433,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ServerPort", DB_TOKEN, "Port used to setup transporter", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, UNDEFINED, "1", STR_VALUE(MAX_INT_RNIL) }, @@ -422,9 +445,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NoOfReplicas", DB_TOKEN, "Number of copies of all data in the database (1-4)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "1", "4" }, @@ -434,9 +457,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfAttributes", DB_TOKEN, "Total number of attributes stored in database. I.e. sum over all tables", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1000", "32", STR_VALUE(MAX_INT_RNIL) }, @@ -446,9 +469,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfTables", DB_TOKEN, "Total number of tables stored in the database", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "128", "8", STR_VALUE(MAX_INT_RNIL) }, @@ -458,9 +481,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfOrderedIndexes", DB_TOKEN, "Total number of ordered indexes that can be defined in the system", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "128", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -470,9 +493,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfUniqueHashIndexes", DB_TOKEN, "Total number of unique hash indexes that can be defined in the system", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "64", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -482,9 +505,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfIndexes", DB_TOKEN, "Total number of indexes that can be defined in the system", - ConfigInfo::DEPRICATED, + ConfigInfo::CI_DEPRICATED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "128", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -494,9 +517,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfConcurrentIndexOperations", DB_TOKEN, "Total number of index operations that can execute simultaneously on one "DB_TOKEN_PRINT" node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "8K", "0", STR_VALUE(MAX_INT_RNIL) @@ -507,9 +530,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfTriggers", DB_TOKEN, "Total number of triggers that can be defined in the system", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "768", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -519,9 +542,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfFiredTriggers", DB_TOKEN, "Total number of triggers that can fire simultaneously in one "DB_TOKEN_PRINT" node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "4000", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -531,9 +554,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ExecuteOnComputer", DB_TOKEN, "String referencing an earlier defined COMPUTER", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -542,9 +565,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfSavedMessages", DB_TOKEN, "Max number of error messages in error log and max number of trace files", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "25", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -554,9 +577,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LockPagesInMainMemory", DB_TOKEN, "If set to yes, then NDB Cluster data will not be swapped out to disk", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "false", "false", "true" }, @@ -566,9 +589,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "TimeBetweenWatchDogCheck", DB_TOKEN, "Time between execution checks inside a database node", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "6000", "70", STR_VALUE(MAX_INT_RNIL) }, @@ -578,9 +601,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "StopOnError", DB_TOKEN, "If set to N, "DB_TOKEN_PRINT" automatically restarts/recovers in case of node failure", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "true", "false", "true" }, @@ -590,9 +613,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "RestartOnErrorInsert", DB_TOKEN, "See src/kernel/vm/Emulator.hpp NdbRestartType for details", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "2", "0", "4" }, @@ -602,9 +625,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfConcurrentOperations", DB_TOKEN, "Max number of operation records in transaction coordinator", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "32k", "32", STR_VALUE(MAX_INT_RNIL) }, @@ -614,9 +637,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfLocalOperations", DB_TOKEN, "Max number of operation records defined in the local storage node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, UNDEFINED, "32", STR_VALUE(MAX_INT_RNIL) }, @@ -626,9 +649,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfLocalScans", DB_TOKEN, "Max number of fragment scans in parallel in the local storage node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, UNDEFINED, "32", STR_VALUE(MAX_INT_RNIL) }, @@ -638,9 +661,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "BatchSizePerLocalScan", DB_TOKEN, "Used to calculate the number of lock records for scan with hold lock", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, STR_VALUE(DEF_BATCH_SIZE), "1", STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) }, @@ -650,9 +673,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfConcurrentTransactions", DB_TOKEN, "Max number of transaction executing concurrently on the "DB_TOKEN_PRINT" node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "4096", "32", STR_VALUE(MAX_INT_RNIL) }, @@ -662,9 +685,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfConcurrentScans", DB_TOKEN, "Max number of scans executing concurrently on the "DB_TOKEN_PRINT" node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "256", "2", "500" }, @@ -674,9 +697,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "TransactionBufferMemory", DB_TOKEN, "Dynamic buffer space (in bytes) for key and attribute data allocated for each "DB_TOKEN_PRINT" node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1M", "1K", STR_VALUE(MAX_INT_RNIL) }, @@ -686,9 +709,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "IndexMemory", DB_TOKEN, "Number bytes on each "DB_TOKEN_PRINT" node allocated for storing indexes", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT64, + ConfigInfo::CI_INT64, "18M", "1M", "1024G" }, @@ -698,9 +721,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "DataMemory", DB_TOKEN, "Number bytes on each "DB_TOKEN_PRINT" node allocated for storing data", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT64, + ConfigInfo::CI_INT64, "80M", "1M", "1024G" }, @@ -710,9 +733,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "UndoIndexBuffer", DB_TOKEN, "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing UNDO logs for index part", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "2M", "1M", STR_VALUE(MAX_INT_RNIL)}, @@ -722,9 +745,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "UndoDataBuffer", DB_TOKEN, "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing UNDO logs for data part", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "16M", "1M", STR_VALUE(MAX_INT_RNIL)}, @@ -734,9 +757,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "RedoBuffer", DB_TOKEN, "Number bytes on each "DB_TOKEN_PRINT" node allocated for writing REDO logs", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "8M", "1M", STR_VALUE(MAX_INT_RNIL)}, @@ -746,9 +769,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LongMessageBuffer", DB_TOKEN, "Number bytes on each "DB_TOKEN_PRINT" node allocated for internal long messages", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1M", "512k", STR_VALUE(MAX_INT_RNIL)}, @@ -758,9 +781,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "StartPartialTimeout", DB_TOKEN, "Time to wait before trying to start wo/ all nodes. 0=Wait forever", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "30000", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -770,9 +793,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "StartPartitionedTimeout", DB_TOKEN, "Time to wait before trying to start partitioned. 0=Wait forever", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "60000", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -782,9 +805,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "StartFailureTimeout", DB_TOKEN, "Time to wait before terminating. 0=Wait forever", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -794,9 +817,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HeartbeatIntervalDbDb", DB_TOKEN, "Time between "DB_TOKEN_PRINT"-"DB_TOKEN_PRINT" heartbeats. "DB_TOKEN_PRINT" considered dead after 3 missed HBs", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1500", "10", STR_VALUE(MAX_INT_RNIL) }, @@ -806,9 +829,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HeartbeatIntervalDbApi", DB_TOKEN, "Time between "API_TOKEN_PRINT"-"DB_TOKEN_PRINT" heartbeats. "API_TOKEN_PRINT" connection closed after 3 missed HBs", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1500", "100", STR_VALUE(MAX_INT_RNIL) }, @@ -818,9 +841,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "TimeBetweenLocalCheckpoints", DB_TOKEN, "Time between taking snapshots of the database (expressed in 2log of bytes)", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "20", "0", "31" }, @@ -830,9 +853,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "TimeBetweenGlobalCheckpoints", DB_TOKEN, "Time between doing group commit of transactions to disk", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "2000", "10", "32000" }, @@ -842,9 +865,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NoOfFragmentLogFiles", DB_TOKEN, "No of 16 Mbyte Redo log files in each of 4 file sets belonging to "DB_TOKEN_PRINT" node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "8", "1", STR_VALUE(MAX_INT_RNIL) }, @@ -854,9 +877,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfOpenFiles", DB_TOKEN, "Max number of files open per "DB_TOKEN_PRINT" node.(One thread is created per file)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "40", "20", "256" }, @@ -867,9 +890,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "TimeBetweenInactiveTransactionAbortCheck", DB_TOKEN, "Time between inactive transaction checks", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1000", "1000", STR_VALUE(MAX_INT_RNIL) }, @@ -883,9 +906,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "to execute or send another part (query, statement) of the transaction.\n" "If the application takes too long time, the transaction gets aborted.\n" "Timeout set to 0 means that we don't timeout at all on application wait.", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, STR_VALUE(MAX_INT_RNIL), "0", STR_VALUE(MAX_INT_RNIL) }, @@ -898,9 +921,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "This is the time the transaction coordinator waits for each database node\n" "of the transaction to execute a request. If the database node takes too\n" "long time, the transaction gets aborted.", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1200", "50", STR_VALUE(MAX_INT_RNIL) }, @@ -910,9 +933,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NoOfDiskPagesToDiskDuringRestartTUP", DB_TOKEN, "?", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "40", "1", STR_VALUE(MAX_INT_RNIL) }, @@ -922,9 +945,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NoOfDiskPagesToDiskAfterRestartTUP", DB_TOKEN, "?", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "40", "1", STR_VALUE(MAX_INT_RNIL) }, @@ -934,9 +957,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NoOfDiskPagesToDiskDuringRestartACC", DB_TOKEN, "?", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "20", "1", STR_VALUE(MAX_INT_RNIL) }, @@ -946,9 +969,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NoOfDiskPagesToDiskAfterRestartACC", DB_TOKEN, "?", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "20", "1", STR_VALUE(MAX_INT_RNIL) }, @@ -959,9 +982,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Diskless", DB_TOKEN, "Run wo/ disk", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "false", "false", "true"}, @@ -971,9 +994,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Discless", DB_TOKEN, "Diskless", - ConfigInfo::DEPRICATED, + ConfigInfo::CI_DEPRICATED, true, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "false", "false", "true"}, @@ -985,9 +1008,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ArbitrationTimeout", DB_TOKEN, "Max time (milliseconds) database partion waits for arbitration signal", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "3000", "10", STR_VALUE(MAX_INT_RNIL) }, @@ -997,9 +1020,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "DataDir", DB_TOKEN, "Data directory for this node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MYSQLCLUSTERDIR, 0, 0 }, @@ -1008,9 +1031,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "FileSystemPath", DB_TOKEN, "Path to directory where the "DB_TOKEN_PRINT" node stores its data (directory must exist)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1019,9 +1042,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LogLevelStartup", DB_TOKEN, "Node startup info printed on stdout", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1", "0", "15" }, @@ -1031,9 +1054,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LogLevelShutdown", DB_TOKEN, "Node shutdown info printed on stdout", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", "15" }, @@ -1043,9 +1066,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LogLevelStatistic", DB_TOKEN, "Transaction, operation, transporter info printed on stdout", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", "15" }, @@ -1055,9 +1078,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LogLevelCheckpoint", DB_TOKEN, "Local and Global checkpoint info printed on stdout", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", "15" }, @@ -1067,9 +1090,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LogLevelNodeRestart", DB_TOKEN, "Node restart, node failure info printed on stdout", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", "15" }, @@ -1079,9 +1102,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LogLevelConnection", DB_TOKEN, "Node connect/disconnect info printed on stdout", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", "15" }, @@ -1091,9 +1114,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LogLevelError", DB_TOKEN, "Transporter, heartbeat errors printed on stdout", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", "15" }, @@ -1103,9 +1126,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LogLevelInfo", DB_TOKEN, "Heartbeat and log info printed on stdout", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", "15" }, @@ -1118,9 +1141,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ParallelBackups", DB_TOKEN, "Maximum number of parallel backups", - ConfigInfo::NOTIMPLEMENTED, + ConfigInfo::CI_NOTIMPLEMENTED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1", "1", "1" }, @@ -1130,9 +1153,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "BackupDataDir", DB_TOKEN, "Path to where to store backups", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1141,9 +1164,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "BackupMemory", DB_TOKEN, "Total memory allocated for backups per node (in bytes)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "4M", // sum of BackupDataBufferSize and BackupLogBufferSize "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1153,9 +1176,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "BackupDataBufferSize", DB_TOKEN, "Default size of databuffer for a backup (in bytes)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "2M", // remember to change BackupMemory "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1165,9 +1188,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "BackupLogBufferSize", DB_TOKEN, "Default size of logbuffer for a backup (in bytes)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "2M", // remember to change BackupMemory "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1177,9 +1200,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "BackupWriteSize", DB_TOKEN, "Default size of filesystem writes made by backup (in bytes)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "32K", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1192,9 +1215,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "REP", "REP", "Node section", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, (const char *)NODE_TYPE_REP, 0, 0 }, @@ -1204,9 +1227,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName", "REP", "Name of computer for this node", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1215,9 +1238,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "System", "REP", "Name of system for this node", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1226,9 +1249,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Id", "REP", "Number identifying replication node (REP)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "1", STR_VALUE(MAX_NODES) }, @@ -1238,9 +1261,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ExecuteOnComputer", "REP", "String referencing an earlier defined COMPUTER", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, @@ -1249,9 +1272,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HeartbeatIntervalRepRep", "REP", "Time between REP-REP heartbeats. Connection closed after 3 missed HBs", - ConfigInfo::USED, + ConfigInfo::CI_USED, true, - ConfigInfo::INT, + ConfigInfo::CI_INT, "3000", "100", STR_VALUE(MAX_INT_RNIL) }, @@ -1264,9 +1287,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { API_TOKEN, API_TOKEN, "Node section", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, (const char *)NODE_TYPE_API, 0, 0 }, @@ -1276,9 +1299,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName", API_TOKEN, "Name of computer for this node", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1287,9 +1310,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "System", API_TOKEN, "Name of system for this node", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1298,9 +1321,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Id", API_TOKEN, "Number identifying application node ("API_TOKEN_PRINT")", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "1", STR_VALUE(MAX_NODES) }, @@ -1310,9 +1333,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ExecuteOnComputer", API_TOKEN, "String referencing an earlier defined COMPUTER", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1321,9 +1344,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ArbitrationRank", API_TOKEN, "If 0, then "API_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", "2" }, @@ -1333,9 +1356,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ArbitrationDelay", API_TOKEN, "When asked to arbitrate, arbitrator waits this long before voting (msec)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1345,9 +1368,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxScanBatchSize", "API", "The maximum collective batch size for one scan", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, STR_VALUE(MAX_SCAN_BATCH_SIZE), "32k", "16M" }, @@ -1357,9 +1380,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "BatchByteSize", "API", "The default batch size in bytes", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, STR_VALUE(SCAN_BATCH_SIZE), "1k", "1M" }, @@ -1369,9 +1392,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "BatchSize", "API", "The default batch size in number of records", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, STR_VALUE(DEF_BATCH_SIZE), "1", STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) }, @@ -1384,9 +1407,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { MGM_TOKEN, MGM_TOKEN, "Node section", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, (const char *)NODE_TYPE_MGM, 0, 0 }, @@ -1396,9 +1419,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName", MGM_TOKEN, "Name of computer for this node", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1407,9 +1430,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "DataDir", MGM_TOKEN, "Data directory for this node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MYSQLCLUSTERDIR, 0, 0 }, @@ -1418,9 +1441,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "System", MGM_TOKEN, "Name of system for this node", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1429,9 +1452,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Id", MGM_TOKEN, "Number identifying the management server node ("MGM_TOKEN_PRINT")", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "1", STR_VALUE(MAX_NODES) }, @@ -1441,9 +1464,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "LogDestination", MGM_TOKEN, "String describing where logmessages are sent", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, 0, 0, 0 }, @@ -1452,9 +1475,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ExecuteOnComputer", MGM_TOKEN, "String referencing an earlier defined COMPUTER", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, 0, 0, 0 }, @@ -1463,9 +1486,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "MaxNoOfSavedEvents", MGM_TOKEN, "", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "100", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1475,10 +1498,10 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "PortNumber", MGM_TOKEN, "Port number to give commands to/fetch configurations from management server", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, - NDB_BASE_PORT, + ConfigInfo::CI_INT, + NDB_PORT, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1487,10 +1510,10 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "PortNumberStats", MGM_TOKEN, "Port number used to get statistical information from a management server", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, - "2199", + ConfigInfo::CI_INT, + UNDEFINED, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1499,9 +1522,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ArbitrationRank", MGM_TOKEN, "If 0, then "MGM_TOKEN_PRINT" is not arbitrator. Kernel selects arbitrators in order 1, 2", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1", "0", "2" }, @@ -1511,9 +1534,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ArbitrationDelay", MGM_TOKEN, "", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1526,9 +1549,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "TCP", "TCP", "Connection section", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, (const char *)CONNECTION_TYPE_TCP, 0, 0 }, @@ -1538,9 +1561,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName1", "TCP", "Name/IP of computer on one side of the connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1549,9 +1572,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName2", "TCP", "Name/IP of computer on one side of the connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1560,9 +1583,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId1", "TCP", "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, @@ -1571,20 +1594,31 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId2", "TCP", "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, { + CFG_CONNECTION_GROUP, + "Group", + "TCP", + "", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_INT, + "55", + "0", "200" }, + + { CFG_CONNECTION_SEND_SIGNAL_ID, "SendSignalId", "TCP", "Sends id in each signal. Used in trace files.", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "true", "false", "true" }, @@ -1595,9 +1629,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Checksum", "TCP", "If checksum is enabled, all signals between nodes are checked for errors", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "false", "false", "true" }, @@ -1607,9 +1641,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "PortNumber", "TCP", "Port used for this transporter", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1619,9 +1653,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "SendBufferMemory", "TCP", "Bytes of buffer for signals sent from this node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "256K", "16K", STR_VALUE(MAX_INT_RNIL) }, @@ -1631,9 +1665,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ReceiveBufferMemory", "TCP", "Bytes of buffer for signals received by this node", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "64K", "16K", STR_VALUE(MAX_INT_RNIL) }, @@ -1643,9 +1677,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Proxy", "TCP", "", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1654,9 +1688,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId1_System", "TCP", "System for node 1 in connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1665,9 +1699,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId2_System", "TCP", "System for node 2 in connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1680,54 +1714,99 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "SHM", "SHM", "Connection section", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, (const char *)CONNECTION_TYPE_SHM, 0, 0 }, { - CFG_CONNECTION_NODE_1, - "NodeId1", + CFG_CONNECTION_HOSTNAME_1, + "HostName1", "SHM", - "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", - ConfigInfo::USED, + "Name/IP of computer on one side of the connection", + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, - MANDATORY, + ConfigInfo::CI_STRING, + UNDEFINED, 0, 0 }, - + + { + CFG_CONNECTION_HOSTNAME_2, + "HostName2", + "SHM", + "Name/IP of computer on one side of the connection", + ConfigInfo::CI_INTERNAL, + false, + ConfigInfo::CI_STRING, + UNDEFINED, + 0, 0 }, + { CFG_CONNECTION_SERVER_PORT, "PortNumber", "SHM", "Port used for this transporter", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "0", STR_VALUE(MAX_INT_RNIL) }, { + CFG_SHM_SIGNUM, + "Signum", + "SHM", + "Signum to be used for signalling", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_INT, + UNDEFINED, + "0", + STR_VALUE(MAX_INT_RNIL) }, + + { + CFG_CONNECTION_NODE_1, + "NodeId1", + "SHM", + "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_STRING, + MANDATORY, + 0, 0 }, + + { CFG_CONNECTION_NODE_2, "NodeId2", "SHM", "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MANDATORY, 0, 0 }, { + CFG_CONNECTION_GROUP, + "Group", + "SHM", + "", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_INT, + "35", + "0", "200" }, + + { CFG_CONNECTION_SEND_SIGNAL_ID, "SendSignalId", "SHM", "Sends id in each signal. Used in trace files.", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "false", "false", "true" }, @@ -1738,9 +1817,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Checksum", "SHM", "If checksum is enabled, all signals between nodes are checked for errors", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "true", "false", "true" }, @@ -1750,10 +1829,10 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ShmKey", "SHM", "A shared memory key", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, - MANDATORY, + ConfigInfo::CI_INT, + "0", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1762,9 +1841,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ShmSize", "SHM", "Size of shared memory segment", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1M", "4K", STR_VALUE(MAX_INT_RNIL) }, @@ -1774,9 +1853,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId1_System", "SHM", "System for node 1 in connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1785,9 +1864,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId2_System", "SHM", "System for node 2 in connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1799,9 +1878,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "SCI", "SCI", "Connection section", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, (const char *)CONNECTION_TYPE_SCI, 0, 0 }, @@ -1811,9 +1890,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId1", "SCI", "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MANDATORY, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1823,21 +1902,32 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId2", "SCI", "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, MANDATORY, "0", STR_VALUE(MAX_INT_RNIL) }, { + CFG_CONNECTION_GROUP, + "Group", + "SCI", + "", + ConfigInfo::CI_USED, + false, + ConfigInfo::CI_INT, + "15", + "0", "200" }, + + { CFG_CONNECTION_HOSTNAME_1, "HostName1", "SCI", "Name/IP of computer on one side of the connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1846,9 +1936,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName2", "SCI", "Name/IP of computer on one side of the connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1857,9 +1947,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "PortNumber", "SCI", "Port used for this transporter", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1869,9 +1959,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Host1SciId0", "SCI", "SCI-node id for adapter 0 on Host1 (a computer can have two adapters)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1881,9 +1971,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Host1SciId1", "SCI", "SCI-node id for adapter 1 on Host1 (a computer can have two adapters)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1893,9 +1983,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Host2SciId0", "SCI", "SCI-node id for adapter 0 on Host2 (a computer can have two adapters)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1905,9 +1995,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Host2SciId1", "SCI", "SCI-node id for adapter 1 on Host2 (a computer can have two adapters)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "0", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -1917,9 +2007,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "SendSignalId", "SCI", "Sends id in each signal. Used in trace files.", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "true", "false", "true" }, @@ -1929,9 +2019,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Checksum", "SCI", "If checksum is enabled, all signals between nodes are checked for errors", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "false", "false", "true" }, @@ -1941,9 +2031,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "SendLimit", "SCI", "Transporter send buffer contents are sent when this no of bytes is buffered", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "8K", "128", "32K" }, @@ -1953,9 +2043,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "SharedBufferSize", "SCI", "Size of shared memory segment", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1M", "64K", STR_VALUE(MAX_INT_RNIL) }, @@ -1965,9 +2055,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId1_System", "SCI", "System for node 1 in connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1976,9 +2066,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId2_System", "SCI", "System for node 2 in connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -1990,9 +2080,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "OSE", "OSE", "Connection section", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::SECTION, + ConfigInfo::CI_SECTION, (const char *)CONNECTION_TYPE_OSE, 0, 0 }, @@ -2002,9 +2092,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName1", "OSE", "Name of computer on one side of the connection", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -2013,9 +2103,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "HostName2", "OSE", "Name of computer on one side of the connection", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -2024,9 +2114,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId1", "OSE", "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, MANDATORY, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -2036,9 +2126,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId2", "OSE", "Id of node ("DB_TOKEN_PRINT", "API_TOKEN_PRINT" or "MGM_TOKEN_PRINT") on one side of the connection", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, UNDEFINED, "0", STR_VALUE(MAX_INT_RNIL) }, @@ -2048,9 +2138,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "SendSignalId", "OSE", "Sends id in each signal. Used in trace files.", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "true", "false", "true" }, @@ -2060,9 +2150,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "Checksum", "OSE", "If checksum is enabled, all signals between nodes are checked for errors", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::BOOL, + ConfigInfo::CI_BOOL, "false", "false", "true" }, @@ -2072,9 +2162,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "PrioASignalSize", "OSE", "Size of priority A signals (in bytes)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1000", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -2084,9 +2174,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "PrioBSignalSize", "OSE", "Size of priority B signals (in bytes)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "1000", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -2096,9 +2186,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "ReceiveArraySize", "OSE", "Number of OSE signals checked for correct ordering (in no of OSE signals)", - ConfigInfo::USED, + ConfigInfo::CI_USED, false, - ConfigInfo::INT, + ConfigInfo::CI_INT, "10", "0", STR_VALUE(MAX_INT_RNIL) }, @@ -2108,9 +2198,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId1_System", "OSE", "System for node 1 in connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, @@ -2119,9 +2209,9 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { "NodeId2_System", "OSE", "System for node 2 in connection", - ConfigInfo::INTERNAL, + ConfigInfo::CI_INTERNAL, false, - ConfigInfo::STRING, + ConfigInfo::CI_STRING, UNDEFINED, 0, 0 }, }; @@ -2169,7 +2259,7 @@ ConfigInfo::ConfigInfo() } switch (param._type) { - case BOOL: + case CI_BOOL: { bool tmp_bool; require(InitConfigFileParser::convertStringToBool(param._min, tmp_bool)); @@ -2178,8 +2268,8 @@ ConfigInfo::ConfigInfo() pinfo.put64("Max", tmp_bool); break; } - case INT: - case INT64: + case CI_INT: + case CI_INT64: { Uint64 tmp_uint64; require(InitConfigFileParser::convertStringToUint64(param._min, tmp_uint64)); @@ -2188,10 +2278,10 @@ ConfigInfo::ConfigInfo() pinfo.put64("Max", tmp_uint64); break; } - case SECTION: + case CI_SECTION: pinfo.put("SectionType", (Uint32)UintPtr(param._default)); break; - case STRING: + case CI_STRING: break; } @@ -2209,7 +2299,7 @@ ConfigInfo::ConfigInfo() // Replace section with modified section m_info.put(param._section, section, true); - if(param._type != ConfigInfo::SECTION){ + if(param._type != ConfigInfo::CI_SECTION){ Properties * p; if(!m_systemDefaults.getCopy(param._section, &p)){ p = new Properties(true); @@ -2218,20 +2308,20 @@ ConfigInfo::ConfigInfo() param._default != MANDATORY){ switch (param._type) { - case SECTION: + case CI_SECTION: break; - case STRING: + case CI_STRING: require(p->put(param._fname, param._default)); break; - case BOOL: + case CI_BOOL: { bool tmp_bool; require(InitConfigFileParser::convertStringToBool(param._default, default_bool)); require(p->put(param._fname, default_bool)); break; } - case INT: - case INT64: + case CI_INT: + case CI_INT64: { Uint64 tmp_uint64; require(InitConfigFileParser::convertStringToUint64(param._default, default_uint64)); @@ -2253,7 +2343,7 @@ ConfigInfo::ConfigInfo() exit(-1); } - if(m_ParamInfo[i]._type == ConfigInfo::SECTION) + if(m_ParamInfo[i]._type == ConfigInfo::CI_SECTION) continue; const Properties * p = getInfo(m_ParamInfo[i]._section); @@ -2413,9 +2503,9 @@ void ConfigInfo::print(const char* section) const { Properties::Iterator it(sec); for (const char* n = it.first(); n != NULL; n = it.next()) { // Skip entries with different F- and P-names - if (getStatus(sec, n) == ConfigInfo::INTERNAL) continue; - if (getStatus(sec, n) == ConfigInfo::DEPRICATED) continue; - if (getStatus(sec, n) == ConfigInfo::NOTIMPLEMENTED) continue; + if (getStatus(sec, n) == ConfigInfo::CI_INTERNAL) continue; + if (getStatus(sec, n) == ConfigInfo::CI_DEPRICATED) continue; + if (getStatus(sec, n) == ConfigInfo::CI_NOTIMPLEMENTED) continue; print(sec, n); } } @@ -2425,7 +2515,7 @@ void ConfigInfo::print(const Properties * section, ndbout << parameter; // ndbout << getDescription(section, parameter) << endl; switch (getType(section, parameter)) { - case ConfigInfo::BOOL: + case ConfigInfo::CI_BOOL: ndbout << " (Boolean value)" << endl; ndbout << getDescription(section, parameter) << endl; if (getDefault(section, parameter) == false) { @@ -2440,8 +2530,8 @@ void ConfigInfo::print(const Properties * section, ndbout << endl; break; - case ConfigInfo::INT: - case ConfigInfo::INT64: + case ConfigInfo::CI_INT: + case ConfigInfo::CI_INT64: ndbout << " (Non-negative Integer)" << endl; ndbout << getDescription(section, parameter) << endl; if (getDefault(section, parameter) == (UintPtr)MANDATORY) { @@ -2456,7 +2546,7 @@ void ConfigInfo::print(const Properties * section, ndbout << endl; break; - case ConfigInfo::STRING: + case ConfigInfo::CI_STRING: ndbout << " (String)" << endl; ndbout << getDescription(section, parameter) << endl; if (getDefault(section, parameter) == (UintPtr)MANDATORY) { @@ -2466,7 +2556,7 @@ void ConfigInfo::print(const Properties * section, } ndbout << endl; break; - case ConfigInfo::SECTION: + case ConfigInfo::CI_SECTION: break; } } @@ -2654,11 +2744,50 @@ transformExtNode(InitConfigFileParser::Context & ctx, const char * data){ } /** - * Connection rule: Update "NoOfConnections" + * Connection rule: Check support of connection */ bool -transformConnection(InitConfigFileParser::Context & ctx, const char * data){ +checkConnectionSupport(InitConfigFileParser::Context & ctx, const char * data) +{ + int error= 0; + if (strcasecmp("TCP",ctx.fname) == 0) + { + // always enabled + } + else if (strcasecmp("SHM",ctx.fname) == 0) + { +#ifndef NDB_SHM_TRANSPORTER + error= 1; +#endif + } + else if (strcasecmp("SCI",ctx.fname) == 0) + { +#ifndef NDB_SCI_TRANSPORTER + error= 1; +#endif + } + else if (strcasecmp("OSE",ctx.fname) == 0) + { +#ifndef NDB_OSE_TRANSPORTER + error= 1; +#endif + } + if (error) + { + ctx.reportError("Binary not compiled with this connection support, " + "[%s] starting at line: %d", + ctx.fname, ctx.m_sectionLineno); + return false; + } + return true; +} +/** + * Connection rule: Update "NoOfConnections" + */ +bool +transformConnection(InitConfigFileParser::Context & ctx, const char * data) +{ Uint32 connections = 0; ctx.m_userProperties.get("NoOfConnections", &connections); BaseString::snprintf(ctx.pname, sizeof(ctx.pname), "Connection_%d", connections); @@ -2746,26 +2875,26 @@ applyDefaultValues(InitConfigFileParser::Context & ctx, ConfigInfo::Status st = ctx.m_info->getStatus(ctx.m_currentInfo, name); if(!ctx.m_currentSection->contains(name)){ switch (ctx.m_info->getType(ctx.m_currentInfo, name)){ - case ConfigInfo::INT: - case ConfigInfo::BOOL:{ + case ConfigInfo::CI_INT: + case ConfigInfo::CI_BOOL:{ Uint32 val = 0; ::require(defaults->get(name, &val)); ctx.m_currentSection->put(name, val); break; } - case ConfigInfo::INT64:{ + case ConfigInfo::CI_INT64:{ Uint64 val = 0; ::require(defaults->get(name, &val)); ctx.m_currentSection->put64(name, val); break; } - case ConfigInfo::STRING:{ + case ConfigInfo::CI_STRING:{ const char * val; ::require(defaults->get(name, &val)); ctx.m_currentSection->put(name, val); break; } - case ConfigInfo::SECTION: + case ConfigInfo::CI_SECTION: break; } } @@ -2947,7 +3076,13 @@ fixHostname(InitConfigFileParser::Context & ctx, const char * data){ require(ctx.m_currentSection->get(buf, &id)); const Properties * node; - require(ctx.m_config->get("Node", id, &node)); + if(!ctx.m_config->get("Node", id, &node)) + { + ctx.reportError("Unknown node: \"%d\" specified in connection " + "[%s] starting at line: %d", + id, ctx.fname, ctx.m_sectionLineno); + return false; + } const char * hostname; require(node->get("HostName", &hostname)); @@ -3010,7 +3145,7 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ if(!(ctx.m_userDefaults && ctx.m_userDefaults->get("PortNumber", &base)) && !ctx.m_systemDefaults->get("PortNumber", &base)) { - base= strtoll(NDB_BASE_PORT,0,0)+2; + base= strtoll(NDB_TCP_BASE_PORT,0,0); // ctx.reportError("Cannot retrieve base port number"); // return false; } @@ -3025,15 +3160,75 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ << "per connection, please remove from config. " << "Will be changed to " << port << endl; ctx.m_currentSection->put("PortNumber", port, true); - } else + } + else + { ctx.m_currentSection->put("PortNumber", port); - + } DBUG_PRINT("info", ("connection %d-%d port %d host %s", id1, id2, port, hostname.c_str())); DBUG_RETURN(true); } +static bool +fixShmUniqueId(InitConfigFileParser::Context & ctx, const char * data) +{ + DBUG_ENTER("fixShmUniqueId"); + Uint32 nodes= 0; + ctx.m_userProperties.get(ctx.fname, &nodes); + if (nodes == 1) // first management server + { + Uint32 portno= atoi(NDB_PORT); + ctx.m_currentSection->get("PortNumber", &portno); + ctx.m_userProperties.put("ShmUniqueId", portno); + } + DBUG_RETURN(true); +} + +static +bool +fixShmKey(InitConfigFileParser::Context & ctx, const char *) +{ + DBUG_ENTER("fixShmKey"); + { + static int last_signum= -1; + Uint32 signum; + if(!ctx.m_currentSection->get("Signum", &signum)) + { + signum= OPT_NDB_SHM_SIGNUM_DEFAULT; + if (signum <= 0) + { + ctx.reportError("Unable to set default parameter for [SHM]Signum" + " please specify [SHM DEFAULT]Signum"); + return false; + } + ctx.m_currentSection->put("Signum", signum); + DBUG_PRINT("info",("Added Signum=%u", signum)); + } + if ( last_signum != (int)signum && last_signum >= 0 ) + { + ctx.reportError("All shared memory transporters must have same [SHM]Signum defined." + " Use [SHM DEFAULT]Signum"); + return false; + } + last_signum= (int)signum; + } + { + Uint32 id1= 0, id2= 0, key= 0; + require(ctx.m_currentSection->get("NodeId1", &id1)); + require(ctx.m_currentSection->get("NodeId2", &id2)); + if(!ctx.m_currentSection->get("ShmKey", &key)) + { + require(ctx.m_userProperties.get("ShmUniqueId", &key)); + key= key << 16 | (id1 > id2 ? id1 << 8 | id2 : id2 << 8 | id1); + ctx.m_currentSection->put("ShmKey", key); + DBUG_PRINT("info",("Added ShmKey=0x%x", key)); + } + } + DBUG_RETURN(true); +} + /** * DB Node rule: Check various constraints */ @@ -3165,7 +3360,7 @@ transform(InitConfigFileParser::Context & ctx, require(ctx.m_currentSection->getTypeOf(oldName, &oldType)); ConfigInfo::Type newType = ctx.m_info->getType(ctx.m_currentInfo, newName); if(!((oldType == PropertiesType_Uint32 || oldType == PropertiesType_Uint64) - && (newType == ConfigInfo::INT || newType == ConfigInfo::INT64 || newType == ConfigInfo::BOOL))){ + && (newType == ConfigInfo::CI_INT || newType == ConfigInfo::CI_INT64 || newType == ConfigInfo::CI_BOOL))){ ndbout << "oldType: " << (int)oldType << ", newType: " << (int)newType << endl; ctx.reportError("Unable to handle type conversion w.r.t deprication %s %s" "- [%s] starting at line: %d", @@ -3176,7 +3371,7 @@ transform(InitConfigFileParser::Context & ctx, Uint64 oldVal; require(ctx.m_currentSection->get(oldName, &oldVal)); - Uint64 newVal = (Uint64)(oldVal * mul + add); + Uint64 newVal = (Uint64)((Int64)oldVal * mul + add); if(!ctx.m_info->verify(ctx.m_currentInfo, newName, newVal)){ ctx.reportError("Unable to handle deprication, new value not within bounds" "%s %s - [%s] starting at line: %d", @@ -3185,9 +3380,9 @@ transform(InitConfigFileParser::Context & ctx, return false; } - if(newType == ConfigInfo::INT || newType == ConfigInfo::BOOL){ + if(newType == ConfigInfo::CI_INT || newType == ConfigInfo::CI_BOOL){ require(dst.put(newName, (Uint32)newVal)); - } else if(newType == ConfigInfo::INT64) { + } else if(newType == ConfigInfo::CI_INT64) { require(dst.put64(newName, newVal)); } return true; @@ -3269,7 +3464,7 @@ saveInConfigValues(InitConfigFileParser::Context & ctx, const char * data){ require(sec->get("Status", &status)); require(sec->get("SectionType", &typeVal)); - if(id == KEY_INTERNAL || status == ConfigInfo::INTERNAL){ + if(id == KEY_INTERNAL || status == ConfigInfo::CI_INTERNAL){ ndbout_c("skipping section %s", ctx.fname); break; } @@ -3348,11 +3543,51 @@ sanity_checks(Vector<ConfigInfo::ConfigRuleSection>§ions, return true; } +static void +add_a_connection(Vector<ConfigInfo::ConfigRuleSection>§ions, + struct InitConfigFileParser::Context &ctx, + Uint32 nodeId1, Uint32 nodeId2, bool use_shm) +{ + ConfigInfo::ConfigRuleSection s; + const char *hostname1= 0, *hostname2= 0; + const Properties *tmp; + + require(ctx.m_config->get("Node", nodeId1, &tmp)); + tmp->get("HostName", &hostname1); + + require(ctx.m_config->get("Node", nodeId2, &tmp)); + tmp->get("HostName", &hostname2); + + char buf[16]; + s.m_sectionData= new Properties(true); + BaseString::snprintf(buf, sizeof(buf), "%u", nodeId1); + s.m_sectionData->put("NodeId1", buf); + BaseString::snprintf(buf, sizeof(buf), "%u", nodeId2); + s.m_sectionData->put("NodeId2", buf); + + if (use_shm && + hostname1 && hostname1[0] && + hostname2 && hostname2[0] && + strcmp(hostname1,hostname2) == 0) + { + s.m_sectionType= BaseString("SHM"); + DBUG_PRINT("info",("adding SHM connection %d %d",nodeId1,nodeId2)); + } + else + { + s.m_sectionType= BaseString("TCP"); + DBUG_PRINT("info",("adding TCP connection %d %d",nodeId1,nodeId2)); + } + + sections.push_back(s); +} + static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>§ions, struct InitConfigFileParser::Context &ctx, const char * rule_data) { + DBUG_ENTER("add_node_connections"); Uint32 i; Properties * props= ctx.m_config; Properties p_connections(true); @@ -3377,9 +3612,10 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>§ions, ctx.m_userProperties.get("NoOfNodes", &nNodes); Properties p_db_nodes(true); - Properties p_api_mgm_nodes(true); + Properties p_api_nodes(true); + Properties p_mgm_nodes(true); - Uint32 i_db= 0, i_api_mgm= 0, n; + Uint32 i_db= 0, i_api= 0, i_mgm= 0, n; for (i= 0, n= 0; n < nNodes; i++){ const Properties * tmp; if(!props->get("Node", i, &tmp)) continue; @@ -3390,9 +3626,10 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>§ions, if (strcmp(type,DB_TOKEN) == 0) p_db_nodes.put("", i_db++, i); - else if (strcmp(type,API_TOKEN) == 0 || - strcmp(type,MGM_TOKEN) == 0) - p_api_mgm_nodes.put("", i_api_mgm++, i); + else if (strcmp(type,API_TOKEN) == 0) + p_api_nodes.put("", i_api++, i); + else if (strcmp(type,MGM_TOKEN) == 0) + p_mgm_nodes.put("", i_mgm++, i); } Uint32 nodeId1, nodeId2, dummy; @@ -3401,39 +3638,39 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>§ions, for (Uint32 j= i+1;; j++){ if(!p_db_nodes.get("", j, &nodeId2)) break; if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) { - ConfigInfo::ConfigRuleSection s; - s.m_sectionType= BaseString("TCP"); - s.m_sectionData= new Properties(true); - char buf[16]; - BaseString::snprintf(buf, sizeof(buf), "%u", nodeId1); - s.m_sectionData->put("NodeId1", buf); - BaseString::snprintf(buf, sizeof(buf), "%u", nodeId2); - s.m_sectionData->put("NodeId2", buf); - sections.push_back(s); + add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm); } } } - for (i= 0; p_api_mgm_nodes.get("", i, &nodeId1); i++){ + for (i= 0; p_api_nodes.get("", i, &nodeId1); i++){ if(!p_connections.get("", nodeId1, &dummy)) { for (Uint32 j= 0;; j++){ if(!p_db_nodes.get("", j, &nodeId2)) break; - ConfigInfo::ConfigRuleSection s; - s.m_sectionType= BaseString("TCP"); - s.m_sectionData= new Properties(true); - char buf[16]; - BaseString::snprintf(buf, sizeof(buf), "%u", nodeId1); - s.m_sectionData->put("NodeId1", buf); - BaseString::snprintf(buf, sizeof(buf), "%u", nodeId2); - s.m_sectionData->put("NodeId2", buf); - sections.push_back(s); + add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm); } } } - return true; + for (i= 0; p_mgm_nodes.get("", i, &nodeId1); i++){ + if(!p_connections.get("", nodeId1, &dummy)) { + for (Uint32 j= 0;; j++){ + if(!p_db_nodes.get("", j, &nodeId2)) break; + add_a_connection(sections,ctx,nodeId1,nodeId2,0); + } + } + } + + DBUG_RETURN(true); } +static bool set_connection_priorities(Vector<ConfigInfo::ConfigRuleSection>§ions, + struct InitConfigFileParser::Context &ctx, + const char * rule_data) +{ + DBUG_ENTER("set_connection_priorities"); + DBUG_RETURN(true); +} static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>§ions, struct InitConfigFileParser::Context &ctx, @@ -3442,7 +3679,7 @@ static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>§ions, #if 0 Properties * props= ctx.m_config; Properties computers(true); - Uint32 port_base = NDB_BASE_PORT+2; + Uint32 port_base = NDB_TCP_BASE_PORT; Uint32 nNodes; ctx.m_userProperties.get("NoOfNodes", &nNodes); diff --git a/ndb/src/mgmsrv/ConfigInfo.hpp b/ndb/src/mgmsrv/ConfigInfo.hpp index 512505cbd30..dff8b34bf4a 100644 --- a/ndb/src/mgmsrv/ConfigInfo.hpp +++ b/ndb/src/mgmsrv/ConfigInfo.hpp @@ -38,11 +38,11 @@ static const char* UNDEFINED = 0; // Default value for undefined */ class ConfigInfo { public: - enum Type { BOOL, INT, INT64, STRING, SECTION }; - enum Status { USED, ///< Active - DEPRICATED, ///< Can be, but shouldn't - NOTIMPLEMENTED, ///< Is ignored. - INTERNAL ///< Not configurable by the user + enum Type { CI_BOOL, CI_INT, CI_INT64, CI_STRING, CI_SECTION }; + enum Status { CI_USED, ///< Active + CI_DEPRICATED, ///< Can be, but shouldn't + CI_NOTIMPLEMENTED, ///< Is ignored. + CI_INTERNAL ///< Not configurable by the user }; /** diff --git a/ndb/src/mgmsrv/InitConfigFileParser.cpp b/ndb/src/mgmsrv/InitConfigFileParser.cpp index fdfe7823fc2..822e10c89aa 100644 --- a/ndb/src/mgmsrv/InitConfigFileParser.cpp +++ b/ndb/src/mgmsrv/InitConfigFileParser.cpp @@ -21,6 +21,7 @@ #include "MgmtErrorReporter.hpp" #include <NdbOut.hpp> #include "ConfigInfo.hpp" +#include <m_string.h> const int MAX_LINE_LENGTH = 1024; // Max length of line of text in config file static void trim(char *); @@ -213,57 +214,58 @@ InitConfigFileParser::parseConfig(FILE * file) { // Parse Name-Value Pair //**************************************************************************** -bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) { - - char tmpLine[MAX_LINE_LENGTH]; - char fname[MAX_LINE_LENGTH], rest[MAX_LINE_LENGTH]; - char* t; - const char *separator_list[]= {":", "=", 0}; - const char *separator= 0; - +bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) +{ if (ctx.m_currentSection == NULL){ ctx.reportError("Value specified outside section"); return false; } - strncpy(tmpLine, line, MAX_LINE_LENGTH); - // ************************************* - // Check if a separator exists in line + // Split string at first occurrence of + // '=' or ':' // ************************************* - for(int i= 0; separator_list[i] != 0; i++) { - if(strchr(tmpLine, separator_list[i][0])) { - separator= separator_list[i]; - break; - } - } - if (separator == 0) { + Vector<BaseString> tmp_string_split; + if (BaseString(line).split(tmp_string_split, + "=:", 2) != 2) + { ctx.reportError("Parse error"); return false; } - // ******************************************* - // Get pointer to substring before separator - // ******************************************* - t = strtok(tmpLine, separator); + // ************************************* + // Remove all after # + // ************************************* + + Vector<BaseString> tmp_string_split2; + tmp_string_split[1].split(tmp_string_split2, + "#", 2); + tmp_string_split[1]=tmp_string_split2[0]; - // ***************************************** - // Count number of tokens before separator - // ***************************************** - if (sscanf(t, "%120s%120s", fname, rest) != 1) { - ctx.reportError("Multiple names before \'%c\'", separator[0]); - return false; + // ************************************* + // Remove leading and trailing chars + // ************************************* + { + for (int i = 0; i < 2; i++) + tmp_string_split[i].trim("\r\n \t"); } + + // ************************************* + // First in split is fname + // ************************************* + + const char *fname= tmp_string_split[0].c_str(); + if (!ctx.m_currentInfo->contains(fname)) { ctx.reportError("[%s] Unknown parameter: %s", ctx.fname, fname); return false; } ConfigInfo::Status status = m_info->getStatus(ctx.m_currentInfo, fname); - if (status == ConfigInfo::NOTIMPLEMENTED) { + if (status == ConfigInfo::CI_NOTIMPLEMENTED) { ctx.reportWarning("[%s] %s not yet implemented", ctx.fname, fname); } - if (status == ConfigInfo::DEPRICATED) { + if (status == ConfigInfo::CI_DEPRICATED) { const char * desc = m_info->getDescription(ctx.m_currentInfo, fname); if(desc){ ctx.reportWarning("[%s] %s is depricated, use %s instead", @@ -273,24 +275,11 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) { } } - // ****************************************** - // Get pointer to substring after separator - // ****************************************** - t = strtok(NULL, "\0"); - if (t == NULL) { - ctx.reportError("No value for parameter"); - return false; - } - - // ****************************************** - // Remove prefix and postfix spaces and tabs - // ******************************************* - trim(t); - // *********************** // Store name-value pair // *********************** - return storeNameValuePair(ctx, fname, t); + + return storeNameValuePair(ctx, fname, tmp_string_split[1].c_str()); } @@ -316,7 +305,7 @@ InitConfigFileParser::storeNameValuePair(Context& ctx, const ConfigInfo::Type type = m_info->getType(ctx.m_currentInfo, fname); switch(type){ - case ConfigInfo::BOOL: { + case ConfigInfo::CI_BOOL: { bool value_bool; if (!convertStringToBool(value, value_bool)) { ctx.reportError("Illegal boolean value for parameter %s", fname); @@ -325,8 +314,8 @@ InitConfigFileParser::storeNameValuePair(Context& ctx, MGM_REQUIRE(ctx.m_currentSection->put(pname, value_bool)); break; } - case ConfigInfo::INT: - case ConfigInfo::INT64:{ + case ConfigInfo::CI_INT: + case ConfigInfo::CI_INT64:{ Uint64 value_int; if (!convertStringToUint64(value, value_int)) { ctx.reportError("Illegal integer value for parameter %s", fname); @@ -339,17 +328,17 @@ InitConfigFileParser::storeNameValuePair(Context& ctx, m_info->getMax(ctx.m_currentInfo, fname)); return false; } - if(type == ConfigInfo::INT){ + if(type == ConfigInfo::CI_INT){ MGM_REQUIRE(ctx.m_currentSection->put(pname, (Uint32)value_int)); } else { MGM_REQUIRE(ctx.m_currentSection->put64(pname, value_int)); } break; } - case ConfigInfo::STRING: + case ConfigInfo::CI_STRING: MGM_REQUIRE(ctx.m_currentSection->put(pname, value)); break; - case ConfigInfo::SECTION: + case ConfigInfo::CI_SECTION: abort(); } return true; @@ -385,7 +374,7 @@ bool InitConfigFileParser::convertStringToUint64(const char* s, errno = 0; char* p; - long long v = strtoll(s, &p, log10base); + Int64 v = strtoll(s, &p, log10base); if (errno != 0) return false; diff --git a/ndb/src/mgmsrv/Makefile.am b/ndb/src/mgmsrv/Makefile.am index 3b57b027827..50e0b6023ad 100644 --- a/ndb/src/mgmsrv/Makefile.am +++ b/ndb/src/mgmsrv/Makefile.am @@ -24,7 +24,6 @@ INCLUDES_LOC = -I$(top_srcdir)/ndb/src/ndbapi \ -I$(top_srcdir)/ndb/src/common/mgmcommon LDADD_LOC = $(top_builddir)/ndb/src/libndbclient.la \ - $(top_builddir)/ndb/src/common/editline/libeditline.a \ $(top_builddir)/dbug/libdbug.a \ $(top_builddir)/mysys/libmysys.a \ $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@ @@ -33,8 +32,7 @@ LDADD_LOC = $(top_builddir)/ndb/src/libndbclient.la \ DEFS_LOC = -DDEFAULT_MYSQL_HOME="\"$(MYSQLBASEdir)\"" \ -DDATADIR="\"$(MYSQLDATAdir)\"" \ -DSHAREDIR="\"$(MYSQLSHAREdir)\"" \ - -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\"" \ - -DNDB_BASE_PORT="\"@ndb_port_base@\"" + -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\"" include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapi.mk.am @@ -43,3 +41,17 @@ ndb_mgmd_LDFLAGS = @ndb_bin_am_ldflags@ # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: ndb_mgmd.dsp + +ndb_mgmd.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(ndbbin_PROGRAMS) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_mgmd_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) diff --git a/ndb/src/mgmsrv/Makefile_old b/ndb/src/mgmsrv/Makefile_old deleted file mode 100644 index c99875ae8b6..00000000000 --- a/ndb/src/mgmsrv/Makefile_old +++ /dev/null @@ -1,41 +0,0 @@ -include .defs.mk - -TYPE := ndbapi mgmapiclient - -BIN_TARGET := mgmtsrvr -BIN_TARGET_LIBS := -BIN_TARGET_ARCHIVES := NDB_API mgmsrvcommon mgmapi general - -ifneq ($(USE_EDITLINE), N) -BIN_TARGET_ARCHIVES += editline -DIRS := mkconfig -endif -BIN_TARGET_ARCHIVES += general - -BIN_FLAGS += $(TERMCAP_LIB) - -# Source files of non-templated classes (.cpp files) -SOURCES = \ - MgmtSrvr.cpp \ - MgmtSrvrGeneralSignalHandling.cpp \ - main.cpp \ - Services.cpp \ - convertStrToInt.cpp \ - NodeLogLevel.cpp \ - NodeLogLevelList.cpp \ - SignalQueue.cpp \ - MgmtSrvrConfig.cpp - -ifeq ($(findstring OSE, $(NDB_OS)),) -SOURCES += CommandInterpreter.cpp -endif - -CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/src/ndbapi) \ - -I$(call fixpath,$(NDB_TOP)/src/mgmapi) \ - -I$(call fixpath,$(NDB_TOP)/include/mgmapi) \ - -I$(call fixpath,$(NDB_TOP)/src/common/mgmcommon) - -include $(NDB_TOP)/Epilogue.mk - -_bins_mkconfig : $(NDB_TOP)/bin/$(BIN_TARGET) - diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 29df10630f3..3bc00b18f50 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -49,9 +49,12 @@ #include <NdbAutoPtr.hpp> +#include <ndberror.h> + #include <mgmapi.h> #include <mgmapi_configuration.hpp> #include <mgmapi_config_parameters.h> +#include <m_string.h> //#define MGM_SRV_DEBUG #ifdef MGM_SRV_DEBUG @@ -67,12 +70,7 @@ void * MgmtSrvr::logLevelThread_C(void* m) { MgmtSrvr *mgm = (MgmtSrvr*)m; - my_thread_init(); mgm->logLevelThreadRun(); - - my_thread_end(); - NdbThread_Exit(0); - /* NOTREACHED */ return 0; } @@ -80,12 +78,7 @@ void * MgmtSrvr::signalRecvThread_C(void *m) { MgmtSrvr *mgm = (MgmtSrvr*)m; - my_thread_init(); mgm->signalRecvThreadRun(); - - my_thread_end(); - NdbThread_Exit(0); - /* NOTREACHED */ return 0; } @@ -123,15 +116,14 @@ MgmtSrvr::signalRecvThreadRun() while(!_isStopThread) { SigMatch *handler = NULL; NdbApiSignal *signal = NULL; - if(m_signalRecvQueue.waitFor(siglist, handler, signal, DEFAULT_TIMEOUT)) { + if(m_signalRecvQueue.waitFor(siglist, &handler, &signal, DEFAULT_TIMEOUT)) { if(handler->function != 0) (this->*handler->function)(signal); } } -}; - +} -EventLogger g_EventLogger; +extern EventLogger g_eventLogger; static NdbOut& operator<<(NdbOut& out, const LogLevel & ll) @@ -151,7 +143,7 @@ MgmtSrvr::logLevelThreadRun() * Handle started nodes */ EventSubscribeReq req; - req = m_statisticsListner.m_clients[0].m_logLevel; + req = m_event_listner[0].m_logLevel; req.blockRef = _ownReference; SetLogLevelOrd ord; @@ -197,7 +189,7 @@ MgmtSrvr::logLevelThreadRun() void MgmtSrvr::startEventLog() { - g_EventLogger.setCategory("MgmSrvr"); + g_eventLogger.setCategory("MgmSrvr"); ndb_mgm_configuration_iterator * iter = ndb_mgm_create_configuration_iterator ((ndb_mgm_configuration*)_config->m_configValues, CFG_SECTION_NODE); @@ -223,8 +215,9 @@ MgmtSrvr::startEventLog() logdest.assfmt("FILE:filename=%s,maxsize=1000000,maxfiles=6", clusterLog); } - if(!g_EventLogger.addHandler(logdest)) { - ndbout << "Warning: could not add log destination \"" << logdest.c_str() << "\"" << endl; + if(!g_eventLogger.addHandler(logdest)) { + ndbout << "Warning: could not add log destination \"" + << logdest.c_str() << "\"" << endl; } } @@ -242,38 +235,29 @@ public: }; bool -MgmtSrvr::setEventLogFilter(int severity) +MgmtSrvr::setEventLogFilter(int severity, int enable) { - bool enabled = true; Logger::LoggerLevel level = (Logger::LoggerLevel)severity; - if (g_EventLogger.isEnable(level)) { - g_EventLogger.disable(level); - enabled = false; + if (enable > 0) { + g_eventLogger.enable(level); + } else if (enable == 0) { + g_eventLogger.disable(level); + } else if (g_eventLogger.isEnable(level)) { + g_eventLogger.disable(level); } else { - g_EventLogger.enable(level); + g_eventLogger.enable(level); } - - return enabled; + return g_eventLogger.isEnable(level); } bool MgmtSrvr::isEventLogFilterEnabled(int severity) { - return g_EventLogger.isEnable((Logger::LoggerLevel)severity); + return g_eventLogger.isEnable((Logger::LoggerLevel)severity); } static ErrorItem errorTable[] = { - {200, "Backup undefined error"}, - {202, "Backup failed to allocate buffers (check configuration)"}, - {203, "Backup failed to setup fs buffers (check configuration)"}, - {204, "Backup failed to allocate tables (check configuration)"}, - {205, "Backup failed to insert file header (check configuration)"}, - {206, "Backup failed to insert table list (check configuration)"}, - {207, "Backup failed to allocate table memory (check configuration)"}, - {208, "Backup failed to allocate file record (check configuration)"}, - {209, "Backup failed to allocate attribute record (check configuration)"}, - {MgmtSrvr::NO_CONTACT_WITH_PROCESS, "No contact with the process (dead ?)."}, {MgmtSrvr::PROCESS_NOT_CONFIGURED, "The process is not configured."}, {MgmtSrvr::WRONG_PROCESS_TYPE, @@ -399,22 +383,29 @@ MgmtSrvr::getPort() const { } /* Constructor */ -MgmtSrvr::MgmtSrvr(NodeId nodeId, - const BaseString &configFilename, - LocalConfig &local_config, - Config * config): +int MgmtSrvr::init() +{ + if ( _ownNodeId > 0) + return 0; + return -1; +} + +MgmtSrvr::MgmtSrvr(SocketServer *socket_server, + const char *config_filename, + const char *connect_string) : _blockNumber(1), // Hard coded block number since it makes it easy to send // signals to other management servers. + m_socket_server(socket_server), _ownReference(0), - m_local_config(local_config), - m_allocated_resources(*this), theSignalIdleList(NULL), theWaitState(WAIT_SUBSCRIBE_CONF), - m_statisticsListner(this) + m_event_listner(this) { DBUG_ENTER("MgmtSrvr::MgmtSrvr"); + _ownNodeId= 0; + _config = NULL; _isStopThread = false; @@ -425,12 +416,48 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, theFacade = 0; m_newConfig = NULL; - m_configFilename = configFilename; + if (config_filename) + m_configFilename.assign(config_filename); + else + m_configFilename.assign("config.ini"); m_nextConfigGenerationNumber = 0; - _config = (config == 0 ? readConfig() : config); - + m_config_retriever= new ConfigRetriever(connect_string, + NDB_VERSION, NDB_MGM_NODE_TYPE_MGM); + // if connect_string explicitly given or + // no config filename is given then + // first try to allocate nodeid from another management server + if ((connect_string || config_filename == NULL) && + (m_config_retriever->do_connect(0,0,0) == 0)) + { + int tmp_nodeid= 0; + tmp_nodeid= m_config_retriever->allocNodeId(0 /*retry*/,0 /*delay*/); + if (tmp_nodeid == 0) + { + ndbout_c(m_config_retriever->getErrorString()); + exit(-1); + } + // read config from other managent server + _config= fetchConfig(); + if (_config == 0) + { + ndbout << m_config_retriever->getErrorString() << endl; + exit(-1); + } + _ownNodeId= tmp_nodeid; + } + + if (_ownNodeId == 0) + { + // read config locally + _config= readConfig(); + if (_config == 0) { + ndbout << "Unable to read config file" << endl; + exit(-1); + } + } + theMgmtWaitForResponseCondPtr = NdbCondition_Create(); m_configMutex = NdbMutex_Create(); @@ -442,9 +469,11 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, nodeTypes[i] = (enum ndb_mgm_node_type)-1; m_connect_address[i].s_addr= 0; } + { - ndb_mgm_configuration_iterator * iter = ndb_mgm_create_configuration_iterator - (config->m_configValues, CFG_SECTION_NODE); + ndb_mgm_configuration_iterator + *iter = ndb_mgm_create_configuration_iterator(_config->m_configValues, + CFG_SECTION_NODE); for(ndb_mgm_first(iter); ndb_mgm_valid(iter); ndb_mgm_next(iter)){ unsigned type, id; if(ndb_mgm_get_int_parameter(iter, CFG_TYPE_OF_SECTION, &type) != 0) @@ -477,69 +506,51 @@ MgmtSrvr::MgmtSrvr(NodeId nodeId, } _props = NULL; - _ownNodeId= 0; - NodeId tmp= nodeId; BaseString error_string; -#if 0 - char my_hostname[256]; - struct sockaddr_in tmp_addr; - SOCKET_SIZE_TYPE addrlen= sizeof(tmp_addr); - if (!g_no_nodeid_checks) { - if (gethostname(my_hostname, sizeof(my_hostname))) { - ndbout << "error: gethostname() - " << strerror(errno) << endl; - exit(-1); - } - if (Ndb_getInAddr(&(((sockaddr_in*)&tmp_addr)->sin_addr),my_hostname)) { - ndbout << "error: Ndb_getInAddr(" << my_hostname << ") - " - << strerror(errno) << endl; - exit(-1); - } - } - if (!alloc_node_id(&tmp, NDB_MGM_NODE_TYPE_MGM, - (struct sockaddr *)&tmp_addr, - &addrlen, error_string)){ - ndbout << "Unable to obtain requested nodeid: " - << error_string.c_str() << endl; - exit(-1); - } -#else - if (!alloc_node_id(&tmp, NDB_MGM_NODE_TYPE_MGM, - 0, 0, error_string)){ - ndbout << "Unable to obtain requested nodeid: " - << error_string.c_str() << endl; + + if ((m_node_id_mutex = NdbMutex_Create()) == 0) + { + ndbout << "mutex creation failed line = " << __LINE__ << endl; exit(-1); } -#endif - _ownNodeId = tmp; + if (_ownNodeId == 0) // we did not get node id from other server + { + NodeId tmp= m_config_retriever->get_configuration_nodeid(); + + if (!alloc_node_id(&tmp, NDB_MGM_NODE_TYPE_MGM, + 0, 0, error_string)){ + ndbout << "Unable to obtain requested nodeid: " + << error_string.c_str() << endl; + exit(-1); + } + _ownNodeId = tmp; + } { DBUG_PRINT("info", ("verifyConfig")); - ConfigRetriever cr(m_local_config, NDB_VERSION, NDB_MGM_NODE_TYPE_MGM); - if (!cr.verifyConfig(config->m_configValues, _ownNodeId)) { - ndbout << cr.getErrorString() << endl; + if (!m_config_retriever->verifyConfig(_config->m_configValues, + _ownNodeId)) + { + ndbout << m_config_retriever->getErrorString() << endl; exit(-1); } } + // Setup clusterlog as client[0] in m_event_listner { - MgmStatService::StatListener se; - se.m_socket = -1; + Ndb_mgmd_event_service::Event_listener se; + se.m_socket = NDB_INVALID_SOCKET; for(size_t t = 0; t<LogLevel::LOGLEVEL_CATEGORIES; t++){ se.m_logLevel.setLogLevel((LogLevel::EventCategory)t, 7); } se.m_logLevel.setLogLevel(LogLevel::llError, 15); + se.m_logLevel.setLogLevel(LogLevel::llConnection, 8); se.m_logLevel.setLogLevel(LogLevel::llBackup, 15); - m_statisticsListner.m_clients.push_back(se); - m_statisticsListner.m_logLevel = se.m_logLevel; + m_event_listner.m_clients.push_back(se); + m_event_listner.m_logLevel = se.m_logLevel; } - if ((m_node_id_mutex = NdbMutex_Create()) == 0) - { - ndbout << "mutex creation failed line = " << __LINE__ << endl; - exit(-1); - } - DBUG_VOID_RETURN; } @@ -656,6 +667,8 @@ MgmtSrvr::~MgmtSrvr() NdbThread_WaitFor(m_signalRecvThread, &res); NdbThread_Destroy(&m_signalRecvThread); } + if (m_config_retriever) + delete m_config_retriever; } //**************************************************************************** @@ -1829,18 +1842,21 @@ MgmtSrvr::dumpState(int processId, const Uint32 args[], Uint32 no) //**************************************************************************** //**************************************************************************** -const char* MgmtSrvr::getErrorText(int errorCode) +const char* MgmtSrvr::getErrorText(int errorCode, char *buf, int buf_sz) { - static char text[255]; for (int i = 0; i < noOfErrorCodes; ++i) { if (errorCode == errorTable[i]._errorCode) { - return errorTable[i]._errorText; + BaseString::snprintf(buf, buf_sz, errorTable[i]._errorText); + buf[buf_sz-1]= 0; + return buf; } } - - BaseString::snprintf(text, 255, "Unknown management server error code %d", errorCode); - return text; + + ndb_error_string(errorCode, buf, buf_sz); + buf[buf_sz-1]= 0; + + return buf; } void @@ -1963,7 +1979,7 @@ MgmtSrvr::handleReceivedSignal(NdbApiSignal* signal) } default: - g_EventLogger.error("Unknown signal received. SignalNumber: " + g_eventLogger.error("Unknown signal received. SignalNumber: " "%i from (%d, %x)", gsn, refToNode(signal->theSendersBlockRef), @@ -2039,7 +2055,7 @@ MgmtSrvr::handleStopReply(NodeId nodeId, Uint32 errCode) error: if(errCode != 0){ - g_EventLogger.error("Unexpected signal received. SignalNumber: %i from %d", + g_eventLogger.error("Unexpected signal received. SignalNumber: %i from %d", GSN_STOP_REF, nodeId); } } @@ -2047,21 +2063,18 @@ MgmtSrvr::handleStopReply(NodeId nodeId, Uint32 errCode) void MgmtSrvr::handleStatus(NodeId nodeId, bool alive) { + DBUG_ENTER("MgmtSrvr::handleStatus"); + Uint32 theData[25]; + theData[1] = nodeId; if (alive) { m_started_nodes.push_back(nodeId); - Uint32 theData[25]; theData[0] = EventReport::Connected; - theData[1] = nodeId; - eventReport(_ownNodeId, theData); } else { handleStopReply(nodeId, 0); - - Uint32 theData[25]; theData[0] = EventReport::Disconnected; - theData[1] = nodeId; - - eventReport(_ownNodeId, theData); } + eventReport(_ownNodeId, theData); + DBUG_VOID_RETURN; } //**************************************************************************** @@ -2082,8 +2095,11 @@ void MgmtSrvr::nodeStatusNotification(void* mgmSrv, Uint32 nodeId, bool alive, bool nfComplete) { + DBUG_ENTER("MgmtSrvr::nodeStatusNotification"); + DBUG_PRINT("enter",("nodeid= %d, alive= %d, nfComplete= %d", nodeId, alive, nfComplete)); if(!(!alive && nfComplete)) ((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive); + DBUG_VOID_RETURN; } enum ndb_mgm_node_type @@ -2095,6 +2111,25 @@ MgmtSrvr::getNodeType(NodeId nodeId) const return nodeTypes[nodeId]; } +void +MgmtSrvr::get_connected_nodes(NodeBitmask &connected_nodes) const +{ + if (theFacade && theFacade->theClusterMgr) + { + for(Uint32 i = 0; i < MAX_NODES; i++) + { + if (getNodeType(i) == NDB_MGM_NODE_TYPE_NDB) + { + const ClusterMgr::Node &node= theFacade->theClusterMgr->getNodeInfo(i); + if (node.connected) + { + connected_nodes.bitOR(node.m_state.m_connected_nodes); + } + } + } + } +} + bool MgmtSrvr::alloc_node_id(NodeId * nodeId, enum ndb_mgm_node_type type, @@ -2107,7 +2142,7 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId, *nodeId, type, client_addr)); if (g_no_nodeid_checks) { if (*nodeId == 0) { - error_string.appfmt("no-nodeid-ckecks set in manegment server.\n" + error_string.appfmt("no-nodeid-checks set in management server.\n" "node id must be set explicitly in connectstring"); DBUG_RETURN(false); } @@ -2116,16 +2151,11 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId, Guard g(m_node_id_mutex); int no_mgm= 0; NodeBitmask connected_nodes(m_reserved_nodes); - for(Uint32 i = 0; i < MAX_NODES; i++) + get_connected_nodes(connected_nodes); { - if (getNodeType(i) == NDB_MGM_NODE_TYPE_NDB && - theFacade && theFacade->theClusterMgr) { - const ClusterMgr::Node &node= theFacade->theClusterMgr->getNodeInfo(i); - if (node.connected) { - connected_nodes.bitOR(node.m_state.m_connected_nodes); - } - } else if (getNodeType(i) == NDB_MGM_NODE_TYPE_MGM) - no_mgm++; + for(Uint32 i = 0; i < MAX_NODES; i++) + if (getNodeType(i) == NDB_MGM_NODE_TYPE_MGM) + no_mgm++; } bool found_matching_id= false; bool found_matching_type= false; @@ -2184,6 +2214,18 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId, if (*nodeId != 0 || type != NDB_MGM_NODE_TYPE_MGM || no_mgm == 1) { // any match is ok + + if (config_hostname == 0 && + *nodeId == 0 && + type != NDB_MGM_NODE_TYPE_MGM) + { + if (!id_found) // only set if not set earlier + id_found= tmp; + continue; /* continue looking for a nodeid with specified + * hostname + */ + } + assert(id_found == 0); id_found= tmp; break; } @@ -2228,6 +2270,10 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId, m_connect_address[id_found].s_addr= 0; } m_reserved_nodes.set(id_found); + char tmp_str[128]; + m_reserved_nodes.getText(tmp_str); + g_eventLogger.info("Mgmt server state: nodeid %d reserved for ip %s, m_reserved_nodes %s.", + id_found, get_connect_address(id_found), tmp_str); DBUG_RETURN(true); } @@ -2252,8 +2298,9 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId, if (found_matching_type) if (found_free_node) error_string.appfmt("Connection done from wrong host ip %s.", - inet_ntoa(((struct sockaddr_in *) - (client_addr))->sin_addr)); + (client_addr)? + inet_ntoa(((struct sockaddr_in *) + (client_addr))->sin_addr):""); else error_string.appfmt("No free node id found for %s.", type_string.c_str()); @@ -2284,6 +2331,36 @@ MgmtSrvr::alloc_node_id(NodeId * nodeId, error_string.appfmt("No node defined with id=%d in config file.", *nodeId); } + + g_eventLogger.warning("Allocate nodeid (%d) failed. Connection from ip %s. " + "Returned error string \"%s\"", + *nodeId, + client_addr != 0 ? inet_ntoa(((struct sockaddr_in *)(client_addr))->sin_addr) : "<none>", + error_string.c_str()); + + NodeBitmask connected_nodes2; + get_connected_nodes(connected_nodes2); + { + BaseString tmp_connected, tmp_not_connected; + for(Uint32 i = 0; i < MAX_NODES; i++) + { + if (connected_nodes2.get(i)) + { + if (!m_reserved_nodes.get(i)) + tmp_connected.appfmt(" %d", i); + } + else if (m_reserved_nodes.get(i)) + { + tmp_not_connected.appfmt(" %d", i); + } + } + if (tmp_connected.length() > 0) + g_eventLogger.info("Mgmt server state: node id's %s connected but not reserved", + tmp_connected.c_str()); + if (tmp_not_connected.length() > 0) + g_eventLogger.info("Mgmt server state: node id's %s not connected but reserved", + tmp_not_connected.c_str()); + } DBUG_RETURN(false); } @@ -2313,16 +2390,16 @@ MgmtSrvr::eventReport(NodeId nodeId, const Uint32 * theData) EventReport::EventType type = eventReport->getEventType(); // Log event - g_EventLogger.log(type, theData, nodeId, - &m_statisticsListner.m_clients[0].m_logLevel); - m_statisticsListner.log(type, theData, nodeId); + g_eventLogger.log(type, theData, nodeId, + &m_event_listner[0].m_logLevel); + m_event_listner.log(type, theData, nodeId); } /*************************************************************************** * Backup ***************************************************************************/ int -MgmtSrvr::startBackup(Uint32& backupId, bool waitCompleted) +MgmtSrvr::startBackup(Uint32& backupId, int waitCompleted) { bool next; NodeId nodeId = 0; @@ -2344,11 +2421,16 @@ MgmtSrvr::startBackup(Uint32& backupId, bool waitCompleted) req->backupDataLen = 0; int result; - if (waitCompleted) { - result = sendRecSignal(nodeId, WAIT_BACKUP_COMPLETED, signal, true); + if (waitCompleted == 2) { + result = sendRecSignal(nodeId, WAIT_BACKUP_COMPLETED, + signal, true, 30*60*1000 /*30 secs*/); + } + else if (waitCompleted == 1) { + result = sendRecSignal(nodeId, WAIT_BACKUP_STARTED, + signal, true, 5*60*1000 /*5 mins*/); } else { - result = sendRecSignal(nodeId, WAIT_BACKUP_STARTED, signal, true); + result = sendRecSignal(nodeId, NO_WAIT, signal, true); } if (result == -1) { return SEND_OR_RECEIVE_FAILED; @@ -2427,18 +2509,31 @@ MgmtSrvr::abortBackup(Uint32 backupId) void MgmtSrvr::backupCallback(BackupEvent & event) { + DBUG_ENTER("MgmtSrvr::backupCallback"); m_lastBackupEvent = event; switch(event.Event){ case BackupEvent::BackupFailedToStart: + DBUG_PRINT("info",("BackupEvent::BackupFailedToStart")); + theWaitState = NO_WAIT; + break; case BackupEvent::BackupAborted: + DBUG_PRINT("info",("BackupEvent::BackupAborted")); + theWaitState = NO_WAIT; + break; case BackupEvent::BackupCompleted: + DBUG_PRINT("info",("BackupEvent::BackupCompleted")); theWaitState = NO_WAIT; break; case BackupEvent::BackupStarted: if(theWaitState == WAIT_BACKUP_STARTED) + { + DBUG_PRINT("info",("BackupEvent::BackupStarted NO_WAIT")); theWaitState = NO_WAIT; + } else { + DBUG_PRINT("info",("BackupEvent::BackupStarted")); + } } - return; + DBUG_VOID_RETURN; } @@ -2532,10 +2627,15 @@ MgmtSrvr::Allocated_resources::~Allocated_resources() { Guard g(m_mgmsrv.m_node_id_mutex); if (!m_reserved_nodes.isclear()) { + m_mgmsrv.m_reserved_nodes.bitANDC(m_reserved_nodes); // node has been reserved, force update signal to ndb nodes global_flag_send_heartbeat_now= 1; + + char tmp_str[128]; + m_mgmsrv.m_reserved_nodes.getText(tmp_str); + g_eventLogger.info("Mgmt server state: nodeid %d freed, m_reserved_nodes %s.", + get_nodeid(), tmp_str); } - m_mgmsrv.m_reserved_nodes.bitANDC(m_reserved_nodes); } void @@ -2544,6 +2644,17 @@ MgmtSrvr::Allocated_resources::reserve_node(NodeId id) m_reserved_nodes.set(id); } +NodeId +MgmtSrvr::Allocated_resources::get_nodeid() const +{ + for(Uint32 i = 0; i < MAX_NODES; i++) + { + if (m_reserved_nodes.get(i)) + return i; + } + return 0; +} + int MgmtSrvr::setDbParameter(int node, int param, const char * value, BaseString& msg){ @@ -2586,7 +2697,7 @@ MgmtSrvr::setDbParameter(int node, int param, const char * value, int p_type; unsigned val_32; - unsigned long long val_64; + Uint64 val_64; const char * val_char; do { p_type = 0; @@ -2648,9 +2759,9 @@ MgmtSrvr::setDbParameter(int node, int param, const char * value, template class Vector<SigMatch>; #if __SUNPRO_CC != 0x560 -template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch*&, NdbApiSignal*&, unsigned); +template bool SignalQueue::waitFor<SigMatch>(Vector<SigMatch>&, SigMatch**, NdbApiSignal**, unsigned); #endif template class MutexVector<unsigned short>; -template class MutexVector<MgmStatService::StatListener>; +template class MutexVector<Ndb_mgmd_event_service::Event_listener>; template class MutexVector<EventSubscribeReq>; diff --git a/ndb/src/mgmsrv/MgmtSrvr.hpp b/ndb/src/mgmsrv/MgmtSrvr.hpp index a5f21b6bc4a..6378e763363 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.hpp +++ b/ndb/src/mgmsrv/MgmtSrvr.hpp @@ -43,27 +43,34 @@ class Config; class SetLogLevelOrd; class SocketServer; -class MgmStatService : public EventLoggerBase +class Ndb_mgmd_event_service : public EventLoggerBase { friend class MgmtSrvr; public: - struct StatListener : public EventLoggerBase { + struct Event_listener : public EventLoggerBase { NDB_SOCKET_TYPE m_socket; }; private: class MgmtSrvr * m_mgmsrv; - MutexVector<StatListener> m_clients; + MutexVector<Event_listener> m_clients; public: - MgmStatService(class MgmtSrvr * m) : m_clients(5) { + Ndb_mgmd_event_service(class MgmtSrvr * m) : m_clients(5) { m_mgmsrv = m; } - void add_listener(const StatListener&); + void add_listener(const Event_listener&); + void update_max_log_level(const LogLevel&); + void update_log_level(const LogLevel&); void log(int eventType, const Uint32* theData, NodeId nodeId); - void stopSessions(); + void stop_sessions(); + + Event_listener& operator[](unsigned i) { return m_clients[i]; } + const Event_listener& operator[](unsigned i) const { return m_clients[i]; } + void lock() { m_clients.lock(); } + void unlock(){ m_clients.unlock(); } }; /** @@ -96,7 +103,10 @@ public: // methods to reserve/allocate resources which // will be freed when running destructor void reserve_node(NodeId id); - bool is_reserved(NodeId nodeId) { return m_reserved_nodes.get(nodeId);} + bool is_reserved(NodeId nodeId) { return m_reserved_nodes.get(nodeId); } + bool is_reserved(NodeBitmask mask) { return !mask.bitAND(m_reserved_nodes).isclear(); } + bool isclear() { return m_reserved_nodes.isclear(); } + NodeId get_nodeid() const; private: MgmtSrvr &m_mgmsrv; NodeBitmask m_reserved_nodes; @@ -119,7 +129,7 @@ public: * @param serverity the log level/serverity. * @return true if the severity was enabled. */ - bool setEventLogFilter(int severity); + bool setEventLogFilter(int severity, int enable); /** * Returns true if the log level/severity is enabled. @@ -172,10 +182,10 @@ public: /* Constructor */ - MgmtSrvr(NodeId nodeId, /* Local nodeid */ - const BaseString &config_filename, /* Where to save config */ - LocalConfig &local_config, /* Ndb.cfg filename */ - Config * config); + MgmtSrvr(SocketServer *socket_server, + const char *config_filename, /* Where to save config */ + const char *connect_string); + int init(); NodeId getOwnNodeId() const {return _ownNodeId;}; /** @@ -354,7 +364,7 @@ public: /** * Backup functionallity */ - int startBackup(Uint32& backupId, bool waitCompleted = false); + int startBackup(Uint32& backupId, int waitCompleted= 2); int abortBackup(Uint32 backupId); int performBackup(Uint32* backupId); @@ -463,7 +473,7 @@ public: * @param errorCode: Error code to get a match error text for. * @return The error text. */ - const char* getErrorText(int errorCode); + const char* getErrorText(int errorCode, char *buf, int buf_sz); /** * Get configuration @@ -499,6 +509,9 @@ public: int setDbParameter(int node, int parameter, const char * value, BaseString&); const char *get_connect_address(Uint32 node_id) { return inet_ntoa(m_connect_address[node_id]); } + void get_connected_nodes(NodeBitmask &connected_nodes) const; + SocketServer *get_socket_server() { return m_socket_server; } + //************************************************************************** private: //************************************************************************** @@ -525,16 +538,16 @@ private: int _blockNumber; NodeId _ownNodeId; + SocketServer *m_socket_server; + BlockReference _ownReference; NdbMutex *m_configMutex; const Config * _config; Config * m_newConfig; - LocalConfig &m_local_config; BaseString m_configFilename; Uint32 m_nextConfigGenerationNumber; NodeBitmask m_reserved_nodes; - Allocated_resources m_allocated_resources; struct in_addr m_connect_address[MAX_NODES]; //************************************************************************** @@ -655,7 +668,7 @@ private: */ static void signalReceivedNotification(void* mgmtSrvr, NdbApiSignal* signal, - class LinearSectionPtr ptr[3]); + struct LinearSectionPtr ptr[3]); /** * Called from "outside" of MgmtSrvr when a DB process has died. @@ -726,8 +739,8 @@ private: LogLevel m_nodeLogLevel[MAX_NODES]; enum ndb_mgm_node_type nodeTypes[MAX_NODES]; friend class MgmApiSession; - friend class MgmStatService; - MgmStatService m_statisticsListner; + friend class Ndb_mgmd_event_service; + Ndb_mgmd_event_service m_event_listner; /** * Handles the thread wich upon a 'Node is started' event will @@ -747,6 +760,9 @@ private: Config *_props; int send(class NdbApiSignal* signal, Uint32 node, Uint32 node_type); + + ConfigRetriever *m_config_retriever; + public: /** * This method does not exist diff --git a/ndb/src/mgmsrv/MgmtSrvrConfig.cpp b/ndb/src/mgmsrv/MgmtSrvrConfig.cpp index 1d51061e909..6c4b4e9ae3c 100644 --- a/ndb/src/mgmsrv/MgmtSrvrConfig.cpp +++ b/ndb/src/mgmsrv/MgmtSrvrConfig.cpp @@ -272,30 +272,20 @@ MgmtSrvr::saveConfig(const Config *conf) { Config * MgmtSrvr::readConfig() { - Config *conf = NULL; - if(m_configFilename.length() != 0) { - /* Use config file */ - InitConfigFileParser parser; - conf = parser.parseConfig(m_configFilename.c_str()); - - if(conf == NULL) { - /* Try to get configuration from other MGM server */ - return fetchConfig(); - } - } + Config *conf; + InitConfigFileParser parser; + conf = parser.parseConfig(m_configFilename.c_str()); return conf; } Config * MgmtSrvr::fetchConfig() { - ConfigRetriever cr(m_local_config, NDB_VERSION, NODE_TYPE_MGM); - struct ndb_mgm_configuration * tmp = cr.getConfig(); + struct ndb_mgm_configuration * tmp = m_config_retriever->getConfig(); if(tmp != 0){ Config * conf = new Config(); conf->m_configValues = tmp; return conf; } - return 0; } diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 5b552836955..8ba8c2fe87e 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -29,7 +29,7 @@ #include <ConfigValues.hpp> #include <mgmapi_configuration.hpp> - +#include <Vector.hpp> #include "Services.hpp" extern bool g_StopServer; @@ -132,6 +132,7 @@ ParserRow<MgmApiSession> commands[] = { MGM_ARG("user", String, Mandatory, "Password"), MGM_ARG("password", String, Mandatory, "Password"), MGM_ARG("public key", String, Mandatory, "Public key"), + MGM_ARG("endian", String, Optional, "Endianness"), MGM_CMD("get version", &MgmApiSession::getVersion, ""), @@ -175,6 +176,7 @@ ParserRow<MgmApiSession> commands[] = { MGM_ARG("args", String, Mandatory, "Args(space separated int's)"), MGM_CMD("start backup", &MgmApiSession::startBackup, ""), + MGM_ARG("completed", Int, Optional ,"Wait until completed"), MGM_CMD("abort backup", &MgmApiSession::abortBackup, ""), MGM_ARG("id", Int, Mandatory, "Backup id"), @@ -207,16 +209,17 @@ ParserRow<MgmApiSession> commands[] = { MGM_CMD("set loglevel", &MgmApiSession::setLogLevel, ""), MGM_ARG("node", Int, Mandatory, "Node"), - MGM_ARG("category", String, Mandatory, "Event category"), + MGM_ARG("category", Int, Mandatory, "Event category"), MGM_ARG("level", Int, Mandatory, "Log level (0-15)"), MGM_CMD("set cluster loglevel", &MgmApiSession::setClusterLogLevel, ""), MGM_ARG("node", Int, Mandatory, "Node"), - MGM_ARG("category", String, Mandatory, "Event category"), + MGM_ARG("category", Int, Mandatory, "Event category"), MGM_ARG("level", Int, Mandatory, "Log level (0-15)"), MGM_CMD("set logfilter", &MgmApiSession::setLogFilter, ""), MGM_ARG("level", Int, Mandatory, "Severety level"), + MGM_ARG("enable", Int, Mandatory, "1=disable, 0=enable, -1=toggle"), MGM_CMD("config lock", &MgmApiSession::configLock, ""), @@ -242,6 +245,10 @@ ParserRow<MgmApiSession> commands[] = { MGM_ARG("node", Int, Optional, "Node"), MGM_ARG("filter", String, Mandatory, "Event category"), + MGM_CMD("purge stale sessions", &MgmApiSession::purge_stale_sessions, ""), + + MGM_CMD("check connection", &MgmApiSession::check_connection, ""), + MGM_END() }; @@ -280,8 +287,8 @@ MgmApiSession::runSession() { /* Backwards compatibility for old NDBs that still use * the old "GET CONFIG" command. */ - - for(size_t i=0; i<strlen(ctx.m_currentToken); i++) + size_t i; + for(i=0; i<strlen(ctx.m_currentToken); i++) ctx.m_currentToken[i] = toupper(ctx.m_currentToken[i]); if(strncmp("GET CONFIG ", @@ -382,6 +389,8 @@ MgmApiSession::get_nodeid(Parser_t::Context &, const char * user; const char * password; const char * public_key; + const char * endian= NULL; + union { long l; char c[sizeof(long)]; } endian_check; args.get("version", &version); args.get("nodetype", &nodetype); @@ -390,7 +399,17 @@ MgmApiSession::get_nodeid(Parser_t::Context &, args.get("user", &user); args.get("password", &password); args.get("public key", &public_key); - + args.get("endian", &endian); + + endian_check.l = 1; + if(endian + && strcmp(endian,(endian_check.c[sizeof(long)-1])?"big":"little")!=0) { + m_output->println(cmd); + m_output->println("result: Node does not have the same endianness as the management server."); + m_output->println(""); + return; + } + bool compatible; switch (nodetype) { case NODE_TYPE_MGM: @@ -577,7 +596,7 @@ MgmApiSession::insertError(Parser<MgmApiSession>::Context &, m_output->println("insert error reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -595,7 +614,7 @@ MgmApiSession::setTrace(Parser<MgmApiSession>::Context &, m_output->println("set trace reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -611,85 +630,30 @@ MgmApiSession::getVersion(Parser<MgmApiSession>::Context &, m_output->println("string: %s", NDB_VERSION_STRING); m_output->println(""); } -#if 0 - -/***************************************************************************** - * BACKUP - *****************************************************************************/ - -int completed; -MgmtSrvr::BackupEvent globalEvent; - -static void -completedCallback(const MgmtSrvr::BackupEvent & event){ - - ndbout << "WaitCallback" << endl; - // Save event in the latestEvent var - - switch(event.Event){ - case MgmtSrvr::BackupEvent::BackupCompleted: - case MgmtSrvr::BackupEvent::BackupFailedToStart: - globalEvent = event; - completed = 1; - break; - } -} void MgmApiSession::startBackup(Parser<MgmApiSession>::Context &, - Properties const &) { + Properties const &args) { + DBUG_ENTER("MgmApiSession::startBackup"); unsigned backupId; + Uint32 completed= 2; int result; - MgmtSrvr::BackupCallback prevCallback; - prevCallback = m_mgmsrv.setCallback(completedCallback); - completed = 0; - result = m_mgmsrv.startBackup(backupId); - if (result == 0){ - - // Wait for the callback to call our condition - // waitFor(); - while (completed == 0) - NdbSleep_SecSleep(0); - - if (globalEvent.Event == MgmtSrvr::BackupEvent::BackupFailedToStart) - result = globalEvent.FailedToStart.ErrorCode; - else - backupId = globalEvent.Completed.BackupId; - } + args.get("completed", &completed); - // restore old callback - m_mgmsrv.setCallback(prevCallback); + result = m_mgmsrv.startBackup(backupId, completed); m_output->println("start backup reply"); if(result != 0) - m_output->println("result: %s(%d)", m_mgmsrv.getErrorText(result), result); - else{ - m_output->println("result: Ok"); - m_output->println("id: %d", backupId); + { + m_output->println("result: %s", get_error_text(result)); } - m_output->println(""); - -} -#endif - -void -MgmApiSession::startBackup(Parser<MgmApiSession>::Context &, - Properties const &) { - unsigned backupId; - int result; - - result = m_mgmsrv.startBackup(backupId, true); - - m_output->println("start backup reply"); - if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); else{ m_output->println("result: Ok"); m_output->println("id: %d", backupId); } m_output->println(""); - + DBUG_VOID_RETURN; } void @@ -703,7 +667,7 @@ MgmApiSession::abortBackup(Parser<MgmApiSession>::Context &, m_output->println("abort backup reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -725,7 +689,7 @@ MgmApiSession::repCommand(Parser<MgmApiSession>::Context &, m_output->println("global replication reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else{ m_output->println("result: Ok"); m_output->println("id: %d", repReqId); @@ -747,7 +711,7 @@ MgmApiSession::dumpState(Parser<MgmApiSession>::Context &, int result = m_mgmsrv.dumpState(node, args_str.c_str()); m_output->println("dump state reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -763,68 +727,84 @@ MgmApiSession::bye(Parser<MgmApiSession>::Context &, void MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &, Properties const &args) { - Uint32 node, level, category; + const char *reply= "set cluster loglevel reply"; + Uint32 node, level, cat; BaseString errorString; SetLogLevelOrd logLevel; int result; + DBUG_ENTER("MgmApiSession::setClusterLogLevel"); args.get("node", &node); - args.get("category", &category); + args.get("category", &cat); args.get("level", &level); + DBUG_PRINT("enter",("node=%d, category=%d, level=%d", node, cat, level)); + /* XXX should use constants for this value */ if(level > 15) { - errorString.assign("Invalied loglevel"); - goto error; + m_output->println(reply); + m_output->println("result: Invalid loglevel %d", level); + m_output->println(""); + DBUG_VOID_RETURN; } - EventSubscribeReq req; - req.blockRef = 0; - req.noOfEntries = 1; - req.theData[0] = (category << 16) | level; - m_mgmsrv.m_log_level_requests.push_back(req); - - m_output->println("set cluster loglevel reply"); + LogLevel::EventCategory category= + (LogLevel::EventCategory)(cat-(int)CFG_MIN_LOGLEVEL); + + m_mgmsrv.m_event_listner.lock(); + if (m_mgmsrv.m_event_listner[0].m_logLevel.setLogLevel(category,level)) + { + m_output->println(reply); + m_output->println("result: Invalid category %d", category); + m_output->println(""); + m_mgmsrv.m_event_listner.unlock(); + DBUG_VOID_RETURN; + } + m_mgmsrv.m_event_listner.unlock(); + + { + LogLevel ll; + ll.setLogLevel(category,level); + m_mgmsrv.m_event_listner.update_max_log_level(ll); + } + + m_output->println(reply); m_output->println("result: Ok"); m_output->println(""); - return; -error: - m_output->println("set cluster loglevel reply"); - m_output->println("result: %s", errorString.c_str()); - m_output->println(""); + DBUG_VOID_RETURN; } void MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &, Properties const &args) { - Uint32 node = 0, level = 0, category; + Uint32 node = 0, level = 0, cat; BaseString errorString; SetLogLevelOrd logLevel; int result; logLevel.clear(); args.get("node", &node); - args.get("category", &category); + args.get("category", &cat); args.get("level", &level); /* XXX should use constants for this value */ if(level > 15) { - errorString.assign("Invalied loglevel"); - goto error; + m_output->println("set loglevel reply"); + m_output->println("result: Invalid loglevel", errorString.c_str()); + m_output->println(""); + return; + } + + LogLevel::EventCategory category= + (LogLevel::EventCategory)(cat-(int)CFG_MIN_LOGLEVEL); + + { + LogLevel ll; + ll.setLogLevel(category,level); + m_mgmsrv.m_event_listner.update_max_log_level(ll); } - EventSubscribeReq req; - req.blockRef = node; - req.noOfEntries = 1; - req.theData[0] = (category << 16) | level; - m_mgmsrv.m_log_level_requests.push_back(req); - m_output->println("set loglevel reply"); m_output->println("result: Ok"); m_output->println(""); - return; - error: - m_output->println("set loglevel reply"); - m_output->println("result: %s", errorString.c_str()); - m_output->println(""); } void @@ -838,7 +818,7 @@ MgmApiSession::stopSignalLog(Parser<MgmApiSession>::Context &, m_output->println("stop signallog"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -878,7 +858,7 @@ MgmApiSession::restart(Parser<MgmApiSession>::Context &, m_output->println("restart reply"); if(result != 0){ - m_output->println("result: %d-%s", result, m_mgmsrv.getErrorText(result)); + m_output->println("result: %d-%s", result, get_error_text(result)); } else m_output->println("result: Ok"); m_output->println("restarted: %d", restarted); @@ -902,7 +882,7 @@ MgmApiSession::restartAll(Parser<MgmApiSession>::Context &, m_output->println("restart reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println("restarted: %d", count); @@ -1033,7 +1013,7 @@ MgmApiSession::stop(Parser<MgmApiSession>::Context &, m_output->println("stop reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println("stopped: %d", stopped); @@ -1055,7 +1035,7 @@ MgmApiSession::stopAll(Parser<MgmApiSession>::Context &, m_output->println("stop reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println("stopped: %d", stopped); @@ -1071,7 +1051,7 @@ MgmApiSession::enterSingleUser(Parser<MgmApiSession>::Context &, int result = m_mgmsrv.enterSingleUser(&stopped, nodeId); m_output->println("enter single user reply"); if(result != 0) { - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); } else { m_output->println("result: Ok"); @@ -1086,7 +1066,7 @@ MgmApiSession::exitSingleUser(Parser<MgmApiSession>::Context &, int result = m_mgmsrv.exitSingleUser(&stopped, false); m_output->println("exit single user reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -1104,7 +1084,7 @@ MgmApiSession::startSignalLog(Parser<MgmApiSession>::Context &, m_output->println("start signallog reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -1149,7 +1129,7 @@ MgmApiSession::logSignals(Parser<MgmApiSession>::Context &, m_output->println("log signals reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -1166,7 +1146,7 @@ MgmApiSession::start(Parser<MgmApiSession>::Context &, m_output->println("start reply"); if(result != 0) - m_output->println("result: %s", m_mgmsrv.getErrorText(result)); + m_output->println("result: %s", get_error_text(result)); else m_output->println("result: Ok"); m_output->println(""); @@ -1192,10 +1172,12 @@ void MgmApiSession::setLogFilter(Parser_t::Context &ctx, const class Properties &args) { Uint32 level; + Uint32 enable; args.get("level", &level); + args.get("enable", &enable); - int result = m_mgmsrv.setEventLogFilter(level); + int result = m_mgmsrv.setEventLogFilter(level, enable); m_output->println("set logfilter reply"); m_output->println("result: %d", result); @@ -1249,21 +1231,17 @@ operator<<(NdbOut& out, const LogLevel & ll) } void -MgmStatService::log(int eventType, const Uint32* theData, NodeId nodeId){ +Ndb_mgmd_event_service::log(int eventType, const Uint32* theData, NodeId nodeId){ - Uint32 threshold = 0; - LogLevel::EventCategory cat= LogLevel::llInvalid; + Uint32 threshold; + LogLevel::EventCategory cat; + Logger::LoggerLevel severity; int i; + DBUG_ENTER("Ndb_mgmd_event_service::log"); + DBUG_PRINT("enter",("eventType=%d, nodeid=%d", eventType, nodeId)); - for(i = 0; (unsigned)i<EventLogger::matrixSize; i++){ - if(EventLogger::matrix[i].eventType == eventType){ - cat = EventLogger::matrix[i].eventCategory; - threshold = EventLogger::matrix[i].threshold; - break; - } - } - if (cat == LogLevel::llInvalid) - return; + if (EventLoggerBase::event_lookup(eventType,cat,threshold,severity)) + DBUG_VOID_RETURN; char m_text[256]; EventLogger::getText(m_text, sizeof(m_text), eventType, theData, nodeId); @@ -1272,7 +1250,7 @@ MgmStatService::log(int eventType, const Uint32* theData, NodeId nodeId){ m_clients.lock(); for(i = m_clients.size() - 1; i >= 0; i--){ if(threshold <= m_clients[i].m_logLevel.getLogLevel(cat)){ - if(m_clients[i].m_socket >= 0 && + if(m_clients[i].m_socket != NDB_INVALID_SOCKET && println_socket(m_clients[i].m_socket, MAX_WRITE_TIMEOUT, m_text) == -1){ copy.push_back(m_clients[i].m_socket); @@ -1293,23 +1271,22 @@ MgmStatService::log(int eventType, const Uint32* theData, NodeId nodeId){ tmp.set_max(m_clients[i].m_logLevel); } m_clients.unlock(); - - if(!(tmp == m_logLevel)){ - m_logLevel = tmp; - EventSubscribeReq req; - req = tmp; - req.blockRef = 0; - m_mgmsrv->m_log_level_requests.push_back(req); - } + update_log_level(tmp); } + DBUG_VOID_RETURN; } void -MgmStatService::add_listener(const StatListener& client){ - m_clients.push_back(client); - LogLevel tmp = m_logLevel; - tmp.set_max(client.m_logLevel); - +Ndb_mgmd_event_service::update_max_log_level(const LogLevel &log_level) +{ + LogLevel tmp= m_logLevel; + tmp.set_max(log_level); + update_log_level(tmp); +} + +void +Ndb_mgmd_event_service::update_log_level(const LogLevel &tmp) +{ if(!(tmp == m_logLevel)){ m_logLevel = tmp; EventSubscribeReq req; @@ -1320,13 +1297,21 @@ MgmStatService::add_listener(const StatListener& client){ } void -MgmStatService::stopSessions(){ +Ndb_mgmd_event_service::add_listener(const Event_listener& client){ + m_clients.push_back(client); + update_max_log_level(client.m_logLevel); +} + +void +Ndb_mgmd_event_service::stop_sessions(){ + m_clients.lock(); for(int i = m_clients.size() - 1; i >= 0; i--){ - if(m_clients[i].m_socket >= 0){ + if(m_clients[i].m_socket != NDB_INVALID_SOCKET){ NDB_CLOSE_SOCKET(m_clients[i].m_socket); m_clients.erase(i); } } + m_clients.unlock(); } void @@ -1360,7 +1345,7 @@ MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx, int result = 0; BaseString msg; - MgmStatService::StatListener le; + Ndb_mgmd_event_service::Event_listener le; le.m_socket = m_socket; Vector<BaseString> list; @@ -1405,10 +1390,10 @@ MgmApiSession::listen_event(Parser<MgmApiSession>::Context & ctx, goto done; } - m_mgmsrv.m_statisticsListner.add_listener(le); + m_mgmsrv.m_event_listner.add_listener(le); m_stop = true; - m_socket = -1; + m_socket = NDB_INVALID_SOCKET; done: m_output->println("listen event"); @@ -1418,6 +1403,55 @@ done: m_output->println(""); } +struct PurgeStruct +{ + NodeBitmask free_nodes;/* free nodes as reported + * by ndbd in apiRegReqConf + */ + BaseString *str; +}; + +void +MgmApiSession::stop_session_if_not_connected(SocketServer::Session *_s, void *data) +{ + MgmApiSession *s= (MgmApiSession *)_s; + struct PurgeStruct &ps= *(struct PurgeStruct *)data; + if (s->m_allocated_resources->is_reserved(ps.free_nodes)) + { + ps.str->appfmt(" %d", s->m_allocated_resources->get_nodeid()); + s->stopSession(); + } +} + +void +MgmApiSession::purge_stale_sessions(Parser_t::Context &ctx, + const class Properties &args) +{ + struct PurgeStruct ps; + BaseString str; + ps.str = &str; + + m_mgmsrv.get_connected_nodes(ps.free_nodes); + ps.free_nodes.bitXORC(NodeBitmask()); // invert connected_nodes to get free nodes + + m_mgmsrv.get_socket_server()->foreachSession(stop_session_if_not_connected,&ps); + + m_output->println("purge stale sessions reply"); + if (str.length() > 0) + m_output->println("purged:%s",str.c_str()); + m_output->println("result: Ok"); + m_output->println(""); +} + +void +MgmApiSession::check_connection(Parser_t::Context &ctx, + const class Properties &args) +{ + m_output->println("check connection reply"); + m_output->println("result: Ok"); + m_output->println(""); +} + template class MutexVector<int>; template class Vector<ParserRow<MgmApiSession> const*>; template class Vector<unsigned short>; diff --git a/ndb/src/mgmsrv/Services.hpp b/ndb/src/mgmsrv/Services.hpp index e47820826b6..8627343b1cf 100644 --- a/ndb/src/mgmsrv/Services.hpp +++ b/ndb/src/mgmsrv/Services.hpp @@ -28,7 +28,9 @@ /** Undefine this to remove backwards compatibility for "GET CONFIG". */ #define MGM_GET_CONFIG_BACKWARDS_COMPAT -class MgmApiSession : public SocketServer::Session { +class MgmApiSession : public SocketServer::Session +{ + static void stop_session_if_not_connected(SocketServer::Session *_s, void *data); private: typedef Parser<MgmApiSession> Parser_t; @@ -37,10 +39,13 @@ private: OutputStream *m_output; Parser_t *m_parser; MgmtSrvr::Allocated_resources *m_allocated_resources; + char m_err_str[1024]; void getConfig_common(Parser_t::Context &ctx, const class Properties &args, bool compat = false); + const char *get_error_text(int err_no) + { return m_mgmsrv.getErrorText(err_no, m_err_str, sizeof(m_err_str)); } public: MgmApiSession(class MgmtSrvr & mgm, NDB_SOCKET_TYPE sock); @@ -84,6 +89,9 @@ public: void setParameter(Parser_t::Context &ctx, const class Properties &args); void listen_event(Parser_t::Context &ctx, const class Properties &args); + + void purge_stale_sessions(Parser_t::Context &ctx, const class Properties &args); + void check_connection(Parser_t::Context &ctx, const class Properties &args); void repCommand(Parser_t::Context &ctx, const class Properties &args); }; @@ -99,7 +107,7 @@ public: m_mgmsrv = mgmsrv; } - MgmApiSession * newSession(NDB_SOCKET_TYPE socket){ + SocketServer::Session * newSession(NDB_SOCKET_TYPE socket){ return new MgmApiSession(* m_mgmsrv, socket); } }; diff --git a/ndb/src/mgmsrv/SignalQueue.hpp b/ndb/src/mgmsrv/SignalQueue.hpp index 76acaf2289a..bacbad53415 100644 --- a/ndb/src/mgmsrv/SignalQueue.hpp +++ b/ndb/src/mgmsrv/SignalQueue.hpp @@ -47,8 +47,8 @@ public: NodeId nodeid = 0, Uint32 timeout = DEFAULT_TIMEOUT); template<class T> bool waitFor(Vector<T> &t, - T *&handler, - NdbApiSignal *&signal, + T **handler, + NdbApiSignal **signal, Uint32 timeout = DEFAULT_TIMEOUT); private: NdbMutex *m_mutex; /* Locks all data in SignalQueue */ @@ -75,8 +75,8 @@ private: template<class T> bool SignalQueue::waitFor(Vector<T> &t, - T *&handler, - NdbApiSignal *&signal, + T **handler, + NdbApiSignal **signal, Uint32 timeout) { Guard g(m_mutex); @@ -88,8 +88,8 @@ SignalQueue::waitFor(Vector<T> &t, for(size_t i = 0; i < t.size(); i++) { if(t[i].check(m_signalQueueHead->signal)) { - handler = &t[i]; - signal = pop(); + * handler = &t[i]; + * signal = pop(); return true; } } diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index 5ee48e4cfcc..61b83b86538 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -15,6 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> +#include <ndb_opts.h> #include "MgmtSrvr.hpp" #include "EventLogger.hpp" @@ -33,7 +34,6 @@ #include <ndb_version.h> #include <ConfigRetriever.hpp> #include <mgmapi_config_parameters.h> -#include <getarg.h> #include <NdbAutoPtr.hpp> @@ -62,7 +62,6 @@ struct MgmGlobals { int non_interactive; int interactive; const char * config_filename; - const char * local_config_filename; /** Stuff found in environment or in local config */ NodeId localNodeId; @@ -70,9 +69,6 @@ struct MgmGlobals { char * interface_name; int port; - /** The configuration of the cluster */ - Config * cluster_config; - /** The Mgmt Server */ MgmtSrvr * mgmObject; @@ -83,55 +79,94 @@ struct MgmGlobals { int g_no_nodeid_checks= 0; static MgmGlobals glob; - /****************************************************************************** * Function prototypes ******************************************************************************/ -static bool readLocalConfig(); -static bool readGlobalConfig(); - /** * Global variables */ bool g_StopServer; -extern EventLogger g_EventLogger; +extern EventLogger g_eventLogger; extern int global_mgmt_server_check; -int _print_version = 0; -#ifndef DBUG_OFF -const char *debug_option= 0; + +enum ndb_mgmd_options { + OPT_INTERACTIVE = NDB_STD_OPTIONS_LAST, + OPT_NO_NODEID_CHECKS, + OPT_NO_DAEMON +}; +NDB_STD_OPTS_VARS; + +#if NDB_VERSION_MAJOR <= 4 +#undef OPT_NDB_CONNECTSTRING +#define OPT_NDB_CONNECTSTRING 1023 +#else + #endif -struct getargs args[] = { - { "version", 'v', arg_flag, &_print_version, - "Print ndb_mgmd version",""}, - { "config-file", 'c', arg_string, &glob.config_filename, - "Specify cluster configuration file (default config.ini if available)", - "filename"}, -#ifndef DBUG_OFF - { "debug", 0, arg_string, &debug_option, - "Specify debug options e.g. d:t:i:o,out.trace", "options"}, +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_mgmd"), + { "config-file", 'f', "Specify cluster configuration file", + (gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "daemon", 'd', "Run ndb_mgmd in daemon mode (default)", + (gptr*) &glob.daemon, (gptr*) &glob.daemon, 0, + GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, + { "interactive", OPT_INTERACTIVE, + "Run interactive. Not supported but provided for testing purposes", + (gptr*) &glob.interactive, (gptr*) &glob.interactive, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "no-nodeid-checks", OPT_NO_NODEID_CHECKS, + "Do not provide any node id checks", + (gptr*) &g_no_nodeid_checks, (gptr*) &g_no_nodeid_checks, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "nodaemon", OPT_NO_DAEMON, + "Don't run as daemon, but don't read from stdin", + (gptr*) &glob.non_interactive, (gptr*) &glob.non_interactive, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, +#if NDB_VERSION_MAJOR <= 4 + { "config-file", 'c', + "-c provided for backwards compatability, will be removed in 5.0." + " Use -f instead", + (gptr*) &glob.config_filename, (gptr*) &glob.config_filename, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, #endif - { "daemon", 'd', arg_flag, &glob.daemon, - "Run ndb_mgmd in daemon mode (default)",""}, - { NULL, 'l', arg_string, &glob.local_config_filename, - "Specify configuration file connect string (default Ndb.cfg if available)", - "filename"}, - { "interactive", 0, arg_flag, &glob.interactive, - "Run interactive. Not supported but provided for testing purposes", ""}, - { "no-nodeid-checks", 0, arg_flag, &g_no_nodeid_checks, - "Do not provide any node id checks", ""}, - { "nodaemon", 0, arg_flag, &glob.non_interactive, - "Don't run as daemon, but don't read from stdin", "non-interactive"} + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; - -int num_args = sizeof(args) / sizeof(args[0]); +static void short_usage_sub(void) +{ + printf("Usage: %s [OPTIONS]\n", my_progname); +} +static void usage() +{ + short_usage_sub(); + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_mgmd.trace"); +#if NDB_VERSION_MAJOR <= 4 + switch (optid) { + case 'c': + printf("Warning: -c will be removed in 5.0, use -f instead\n"); + break; + } +#endif + return 0; +} /* * MAIN */ -NDB_MAIN(mgmsrv){ - ndb_init(); +int main(int argc, char** argv) +{ + NDB_INIT(argv[0]); /** * OSE specific. Enable shared ownership of file system resources. @@ -144,57 +179,32 @@ NDB_MAIN(mgmsrv){ global_mgmt_server_check = 1; - int optind = 0; - if(getarg(args, num_args, argc, argv, &optind)) { - arg_printusage(args, num_args, progname, ""); - exit(1); - } + const char *load_default_groups[]= { "mysql_cluster","ndb_mgmd",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + exit(ho_error); if (glob.interactive || glob.non_interactive) { glob.daemon= 0; } -#ifndef DBUG_OFF - if (debug_option) - DBUG_PUSH(debug_option); -#endif - - if (_print_version) { - ndbPrintVersion(); - exit(0); - } - - if(glob.config_filename == NULL) { - glob.config_filename= "config.ini"; - } glob.socketServer = new SocketServer(); MgmApiService * mapi = new MgmApiService(); - /**************************** - * Read configuration files * - ****************************/ - LocalConfig local_config; - if(!local_config.init(0,glob.local_config_filename)){ - local_config.printError(); - goto error_end; - } - glob.localNodeId = local_config._ownNodeId; + glob.mgmObject = new MgmtSrvr(glob.socketServer, + glob.config_filename, + opt_connect_str); - if (!readGlobalConfig()) + if (glob.mgmObject->init()) goto error_end; - glob.mgmObject = new MgmtSrvr(glob.localNodeId, - BaseString(glob.config_filename), - local_config, - glob.cluster_config); + my_setwd(NdbConfig_get_path(0), MYF(0)); - chdir(NdbConfig_get_path(0)); - - glob.cluster_config = 0; glob.localNodeId= glob.mgmObject->getOwnNodeId(); - if (glob.localNodeId == 0) { goto error_end; } @@ -253,7 +263,9 @@ NDB_MAIN(mgmsrv){ } } +#ifndef NDB_WIN32 signal(SIGPIPE, SIG_IGN); +#endif { BaseString error_string; if(!glob.mgmObject->start(error_string)){ @@ -271,12 +283,12 @@ NDB_MAIN(mgmsrv){ BaseString::snprintf(msg, sizeof(msg), "NDB Cluster Management Server. %s", NDB_VERSION_STRING); ndbout_c(msg); - g_EventLogger.info(msg); + g_eventLogger.info(msg); BaseString::snprintf(msg, 256, "Id: %d, Command port: %d", glob.localNodeId, glob.port); ndbout_c(msg); - g_EventLogger.info(msg); + g_eventLogger.info(msg); g_StopServer = false; glob.socketServer->startServer(); @@ -292,10 +304,10 @@ NDB_MAIN(mgmsrv){ NdbSleep_MilliSleep(500); } - g_EventLogger.info("Shutting down server..."); + g_eventLogger.info("Shutting down server..."); glob.socketServer->stopServer(); glob.socketServer->stopSessions(); - g_EventLogger.info("Shutdown complete"); + g_eventLogger.info("Shutdown complete"); return 0; error_end: return 1; @@ -305,9 +317,7 @@ MgmGlobals::MgmGlobals(){ // Default values port = 0; config_filename = NULL; - local_config_filename = NULL; interface_name = 0; - cluster_config = 0; daemon = 1; non_interactive = 0; interactive = 0; @@ -320,27 +330,6 @@ MgmGlobals::~MgmGlobals(){ delete socketServer; if (mgmObject) delete mgmObject; - if (cluster_config) - delete cluster_config; if (interface_name) free(interface_name); } - -/** - * @fn readGlobalConfig - * @param glob : Global variables - * @return true if success, false otherwise. - */ -static bool -readGlobalConfig() { - if(glob.config_filename == NULL) - return false; - - /* Use config file */ - InitConfigFileParser parser; - glob.cluster_config = parser.parseConfig(glob.config_filename); - if(glob.cluster_config == 0){ - return false; - } - return true; -} diff --git a/ndb/src/ndbapi/ClusterMgr.cpp b/ndb/src/ndbapi/ClusterMgr.cpp index e10b2e1d82c..1fe0cedbd6c 100644 --- a/ndb/src/ndbapi/ClusterMgr.cpp +++ b/ndb/src/ndbapi/ClusterMgr.cpp @@ -54,7 +54,6 @@ runClusterMgr_C(void * me) #ifdef NDB_OSE NdbSleep_MilliSleep(50); #endif - NdbThread_Exit(0); return NULL; } @@ -560,10 +559,7 @@ extern "C" void* runArbitMgr_C(void* me) { - my_thread_init(); ((ArbitMgr*) me)->threadMain(); - my_thread_end(); - NdbThread_Exit(0); return NULL; } diff --git a/ndb/src/ndbapi/DictCache.cpp b/ndb/src/ndbapi/DictCache.cpp index 12300ce216f..afdb37aa53f 100644 --- a/ndb/src/ndbapi/DictCache.cpp +++ b/ndb/src/ndbapi/DictCache.cpp @@ -24,10 +24,12 @@ Ndb_local_table_info * Ndb_local_table_info::create(NdbTableImpl *table_impl, Uint32 sz) { - void *data= malloc(sizeof(NdbTableImpl)+sz-1); + if (sz % 8 != 0) // round to Uint64 + sz += 8 - sz % 8; + void *data= malloc(sizeof(NdbTableImpl)+sz-8); if (data == 0) return 0; - memset(data,0,sizeof(NdbTableImpl)+sz-1); + memset(data,0,sizeof(NdbTableImpl)+sz-8); new (data) Ndb_local_table_info(table_impl); return (Ndb_local_table_info *) data; } diff --git a/ndb/src/ndbapi/DictCache.hpp b/ndb/src/ndbapi/DictCache.hpp index 0dc853306fa..58c08a93e61 100644 --- a/ndb/src/ndbapi/DictCache.hpp +++ b/ndb/src/ndbapi/DictCache.hpp @@ -25,6 +25,7 @@ #include <UtilBuffer.hpp> #include <NdbDictionary.hpp> #include <Ndb.hpp> +#include <NdbCondition.h> #include "NdbLinHash.hpp" class Ndb_local_table_info { @@ -32,7 +33,7 @@ public: static Ndb_local_table_info *create(NdbTableImpl *table_impl, Uint32 sz=0); static void destroy(Ndb_local_table_info *); NdbTableImpl *m_table_impl; - char m_local_data[1]; + Uint64 m_local_data[1]; private: Ndb_local_table_info(NdbTableImpl *table_impl); ~Ndb_local_table_info(); diff --git a/ndb/src/ndbapi/Makefile.am b/ndb/src/ndbapi/Makefile.am index 06128e047b6..9f8a851b995 100644 --- a/ndb/src/ndbapi/Makefile.am +++ b/ndb/src/ndbapi/Makefile.am @@ -47,3 +47,17 @@ include $(top_srcdir)/ndb/config/type_ndbapi.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libndbapi.dsp + +libndbapi.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LTLIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libndbapi_la_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB $(LDADD) diff --git a/ndb/src/ndbapi/Makefile_old b/ndb/src/ndbapi/Makefile_old deleted file mode 100644 index 54de9ba96f4..00000000000 --- a/ndb/src/ndbapi/Makefile_old +++ /dev/null @@ -1,60 +0,0 @@ -include .defs.mk - -TYPE := ndbapi - -PIC_ARCHIVE := Y -NONPIC_ARCHIVE := Y -ARCHIVE_TARGET := ndbapi - -A_LIB := Y -SO_LIB := Y -PIC_LIB := Y -LIB_TARGET := NDB_API - -LIB_TARGET_ARCHIVES := $(ARCHIVE_TARGET) \ - transporter \ - general \ - signaldataprint \ - mgmapi mgmsrvcommon \ - portlib \ - logger \ - trace - -DIRS := signal-sender - -CFLAGS_TransporterFacade.cpp := -I$(call fixpath,$(NDB_TOP)/src/mgmapi) -CFLAGS_ClusterMgr.cpp := -I$(call fixpath,$(NDB_TOP)/src/mgmapi) - -# Source files of non-templated classes (.cpp files) -SOURCES = \ - TransporterFacade.cpp \ - ClusterMgr.cpp \ - Ndb.cpp \ - NdbPoolImpl.cpp NdbPool.cpp \ - Ndblist.cpp \ - Ndbif.cpp \ - Ndbinit.cpp \ - ndberror.c Ndberr.cpp NdbErrorOut.cpp \ - NdbConnection.cpp \ - NdbConnectionScan.cpp \ - NdbOperation.cpp \ - NdbOperationSearch.cpp \ - NdbOperationInt.cpp \ - NdbOperationDefine.cpp \ - NdbOperationExec.cpp \ - NdbResultSet.cpp \ - NdbScanOperation.cpp NdbScanFilter.cpp \ - NdbIndexOperation.cpp \ - NdbEventOperation.cpp \ - NdbEventOperationImpl.cpp \ - NdbApiSignal.cpp \ - NdbRecAttr.cpp \ - NdbUtil.cpp \ - NdbReceiver.cpp \ - NdbDictionary.cpp NdbDictionaryImpl.cpp DictCache.cpp - NdbBlob.cpp - -include $(NDB_TOP)/Epilogue.mk - -### -# Backward compatible diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index d7b8a695fe2..b5493622b70 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -22,7 +22,7 @@ Name: Ndb.cpp ******************************************************************************/ #include <ndb_global.h> -#include <pthread.h> + #include "NdbApiSignal.hpp" #include "NdbImpl.hpp" @@ -46,7 +46,6 @@ Connect to any node which has no connection at the moment. NdbConnection* Ndb::doConnect(Uint32 tConNode) { Uint32 tNode; - Uint32 i = 0;; Uint32 tAnyAlive = 0; int TretCode; @@ -65,38 +64,51 @@ NdbConnection* Ndb::doConnect(Uint32 tConNode) // We will connect to any node. Make sure that we have connections to all // nodes. //**************************************************************************** - Uint32 tNoOfDbNodes = theNoOfDBnodes; - i = theCurrentConnectIndex; - UintR Tcount = 0; - do { - if (i >= tNoOfDbNodes) { - i = 0; - }//if - Tcount++; - tNode = theDBnodes[i]; - TretCode = NDB_connect(tNode); - if ((TretCode == 1) || (TretCode == 2)) { + if (theImpl->m_optimized_node_selection) + { + Ndb_cluster_connection_node_iter &node_iter= + theImpl->m_node_iter; + theImpl->m_ndb_cluster_connection.init_get_next_node(node_iter); + while ((tNode= theImpl->m_ndb_cluster_connection.get_next_node(node_iter))) + { + TretCode= NDB_connect(tNode); + if ((TretCode == 1) || + (TretCode == 2)) + { //**************************************************************************** // We have connections now to the desired node. Return //**************************************************************************** - if (theCurrentConnectIndex == i) { - theCurrentConnectCounter++; - if (theCurrentConnectCounter == 8) { - theCurrentConnectCounter = 1; - theCurrentConnectIndex++; - }//if - } else { - // Set to 2 because we have already connected to a node - // when we get here. - theCurrentConnectCounter = 2; - theCurrentConnectIndex = i; + return getConnectedNdbConnection(tNode); + } else if (TretCode != 0) { + tAnyAlive= 1; }//if - return getConnectedNdbConnection(tNode); - } else if (TretCode != 0) { - tAnyAlive = 1; - }//if - i++; - } while (Tcount < tNoOfDbNodes); + } + } + else // just do a regular round robin + { + Uint32 tNoOfDbNodes= theImpl->theNoOfDBnodes; + Uint32 &theCurrentConnectIndex= theImpl->theCurrentConnectIndex; + UintR Tcount = 0; + do { + theCurrentConnectIndex++; + if (theCurrentConnectIndex >= tNoOfDbNodes) + theCurrentConnectIndex = 0; + + Tcount++; + tNode= theImpl->theDBnodes[theCurrentConnectIndex]; + TretCode= NDB_connect(tNode); + if ((TretCode == 1) || + (TretCode == 2)) + { +//**************************************************************************** +// We have connections now to the desired node. Return +//**************************************************************************** + return getConnectedNdbConnection(tNode); + } else if (TretCode != 0) { + tAnyAlive= 1; + }//if + } while (Tcount < tNoOfDbNodes); + } //**************************************************************************** // We were unable to find a free connection. If no node alive we will report // error code for cluster failure otherwise connection failure. @@ -161,8 +173,8 @@ Ndb::NDB_connect(Uint32 tNode) tReturnCode = tp->sendSignal(tSignal, tNode); releaseSignal(tSignal); if (tReturnCode != -1) { - theWaiter.m_node = tNode; - theWaiter.m_state = WAIT_TC_SEIZE; + theImpl->theWaiter.m_node = tNode; + theImpl->theWaiter.m_state = WAIT_TC_SEIZE; tReturnCode = receiveResponse(); }//if } else { @@ -211,8 +223,9 @@ Ndb::doDisconnect() NdbConnection* tNdbCon; CHECK_STATUS_MACRO_VOID; - DBUG_PRINT("info", ("theNoOfDBnodes=%d", theNoOfDBnodes)); - Uint32 tNoOfDbNodes = theNoOfDBnodes; + Uint32 tNoOfDbNodes = theImpl->theNoOfDBnodes; + Uint8 *theDBnodes= theImpl->theDBnodes; + DBUG_PRINT("info", ("theNoOfDBnodes=%d", tNoOfDbNodes)); UintR i; for (i = 0; i < tNoOfDbNodes; i++) { Uint32 tNode = theDBnodes[i]; @@ -254,50 +267,28 @@ Ndb::waitUntilReady(int timeout) DBUG_RETURN(-1); } - do { - if ((id = theNode) != 0) { - unsigned int foundAliveNode = 0; - TransporterFacade *tp = TransporterFacade::instance(); - tp->lock_mutex(); - for (unsigned int i = 0; i < theNoOfDBnodes; i++) { - const NodeId nodeId = theDBnodes[i]; - //************************************************ - // If any node is answering, ndb is answering - //************************************************ - if (tp->get_node_alive(nodeId) != 0) { - foundAliveNode++; - }//if - }//for - - tp->unlock_mutex(); - if (foundAliveNode == theNoOfDBnodes) { - DBUG_RETURN(0); - }//if - if (foundAliveNode > 0) { - noChecksSinceFirstAliveFound++; - }//if - if (noChecksSinceFirstAliveFound > 30) { - DBUG_RETURN(0); - }//if - }//if theNode != 0 + while (theNode == 0) { if (secondsCounter >= timeout) - break; + { + theError.code = 4269; + DBUG_RETURN(-1); + } NdbSleep_MilliSleep(100); milliCounter += 100; if (milliCounter >= 1000) { secondsCounter++; milliCounter = 0; }//if - } while (1); - if (id == 0) { - theError.code = 4269; + } + + if (theImpl->m_ndb_cluster_connection.wait_until_ready + (timeout-secondsCounter,30) < 0) + { + theError.code = 4009; DBUG_RETURN(-1); } - if (noChecksSinceFirstAliveFound > 0) { - DBUG_RETURN(0); - }//if - theError.code = 4009; - DBUG_RETURN(-1); + + DBUG_RETURN(0); } /***************************************************************************** @@ -322,8 +313,8 @@ Ndb::startTransaction(Uint32 aPriority, const char * keyData, Uint32 keyLen) */ Uint32 nodeId; if(keyData != 0) { - Uint32 fragmentId = computeFragmentId(keyData, keyLen); - nodeId = guessPrimaryNode(fragmentId); + nodeId = 0; // guess not supported + // nodeId = m_ndb_cluster_connection->guess_primary_node(keyData, keyLen); } else { nodeId = 0; }//if @@ -384,44 +375,6 @@ Ndb::hupp(NdbConnection* pBuddyTrans) }//if }//Ndb::hupp() -NdbConnection* -Ndb::startTransactionDGroup(Uint32 aPriority, const char * keyData, int type) -{ - - char DGroup[4]; - if ((keyData == NULL) || - (type > 1)) { - theError.code = 4118; - return NULL; - }//if - if (theInitState == Initialised) { - theError.code = 0; - checkFailedNode(); - /** - * If the user supplied key data - * We will make a qualified quess to which node is the primary for the - * the fragment and contact that node - */ - Uint32 fragmentId; - if (type == 0) { - DGroup[0] = keyData[0]; - DGroup[1] = keyData[1]; - DGroup[2] = 0x30; - DGroup[3] = 0x30; - fragmentId = computeFragmentId(&DGroup[0], 4); - } else { - Uint32 hashValue = ((keyData[0] - 0x30) * 10) + (keyData[1] - 0x30); - fragmentId = getFragmentId(hashValue); - }//if - Uint32 nodeId = guessPrimaryNode(fragmentId); - NdbConnection* trans= startTransactionLocal(aPriority, nodeId); - DBUG_PRINT("exit", ("start DGroup trans: 0x%x transid: 0x%llx", - trans, trans ? trans->getTransactionId() : 0)); - return trans; - } else { - return NULL; - }//if -}//Ndb::startTransaction() NdbConnection* Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId) @@ -1021,118 +974,6 @@ Ndb::opTupleIdOnNdb(Uint32 aTableId, Uint64 opValue, Uint32 op) return ~0; } -static const Uint32 MAX_KEY_LEN_64_WORDS = 4; -static const Uint32 MAX_KEY_LEN_32_WORDS = 8; -static const Uint32 MAX_KEY_LEN_BYTES = 32; - -Uint32 -Ndb::computeFragmentId(const char * keyData, Uint32 keyLen) -{ - Uint64 tempData[MAX_KEY_LEN_64_WORDS]; - - const Uint32 usedKeyLen = (keyLen + 3) >> 2; // In words - const char * usedKeyData = 0; - - /** - * If key data buffer is not aligned (on 64 bit boundary) - * or key len is not a multiple of 4 - * Use temp data - */ - if(((((UintPtr)keyData) & 7) == 0) && ((keyLen & 3) == 0)) { - usedKeyData = keyData; - } else { - memcpy(&tempData[0], keyData, keyLen); - const int slack = keyLen & 3; - if(slack > 0) { - memset(&((char *)&tempData[0])[keyLen], 0, (4 - slack)); - }//if - usedKeyData = (char *)&tempData[0]; - }//if - - Uint32 hashValue = md5_hash((Uint64 *)usedKeyData, usedKeyLen); - - hashValue >>= startTransactionNodeSelectionData.kValue; - return getFragmentId(hashValue); -}//Ndb::computeFragmentId() - -Uint32 -Ndb::getFragmentId(Uint32 hashValue) -{ - Uint32 fragmentId = hashValue & - startTransactionNodeSelectionData.hashValueMask; - if(fragmentId < startTransactionNodeSelectionData.hashpointerValue) { - fragmentId = hashValue & - ((startTransactionNodeSelectionData.hashValueMask << 1) + 1); - }//if - return fragmentId; -} - -Uint32 -Ndb::guessPrimaryNode(Uint32 fragmentId){ - //ASSERT(((fragmentId > 0) && fragmentId < - // startTransactionNodeSelectionData.noOfFragments), "Invalid fragementId"); - - return startTransactionNodeSelectionData.fragment2PrimaryNodeMap[fragmentId]; -} - -void -Ndb::StartTransactionNodeSelectionData::init(Uint32 noOfNodes, - Uint32 nodeIds[]) { - kValue = 6; - noOfFragments = 2 * noOfNodes; - - /** - * Compute hashValueMask and hashpointerValue - */ - { - Uint32 topBit = (1 << 31); - for(int i = 31; i>=0; i--){ - if((noOfFragments & topBit) != 0) - break; - topBit >>= 1; - } - hashValueMask = topBit - 1; - hashpointerValue = noOfFragments - (hashValueMask + 1); - } - - /** - * This initialization depends on - * the fact that: - * primary node for fragment i = i % noOfNodes - * - * This algorithm should be implemented in Dbdih - */ - { - if (fragment2PrimaryNodeMap != 0) - abort(); - - fragment2PrimaryNodeMap = new Uint32[noOfFragments]; - Uint32 i; - for(i = 0; i<noOfNodes; i++){ - fragment2PrimaryNodeMap[i] = nodeIds[i]; - } - - // Sort them (bubble sort) - for(i = 0; i<noOfNodes-1; i++) - for(Uint32 j = i+1; j<noOfNodes; j++) - if(fragment2PrimaryNodeMap[i] > fragment2PrimaryNodeMap[j]){ - Uint32 tmp = fragment2PrimaryNodeMap[i]; - fragment2PrimaryNodeMap[i] = fragment2PrimaryNodeMap[j]; - fragment2PrimaryNodeMap[j] = tmp; - } - - for(i = 0; i<noOfNodes; i++){ - fragment2PrimaryNodeMap[i+noOfNodes] = fragment2PrimaryNodeMap[i]; - } - } -} - -void -Ndb::StartTransactionNodeSelectionData::release(){ - delete [] fragment2PrimaryNodeMap; - fragment2PrimaryNodeMap = 0; -} - Uint32 convertEndian(Uint32 Data) { @@ -1386,6 +1227,7 @@ Ndb::printState(const char* fmt, ...) va_end(ap); NdbMutex_Lock(ndb_print_state_mutex); bool dups = false; + unsigned i; ndbout << buf << " ndb=" << hex << this << dec; #ifndef NDB_WIN32 ndbout << " thread=" << (int)pthread_self(); @@ -1406,21 +1248,21 @@ Ndb::printState(const char* fmt, ...) ndbout << "!! DUPS !!" << endl; dups = true; } - for (unsigned i = 0; i < theNoOfPreparedTransactions; i++) + for (i = 0; i < theNoOfPreparedTransactions; i++) thePreparedTransactionsArray[i]->printState(); ndbout << "sent: " << theNoOfSentTransactions<< endl; if (checkdups(theSentTransactionsArray, theNoOfSentTransactions)) { ndbout << "!! DUPS !!" << endl; dups = true; } - for (unsigned i = 0; i < theNoOfSentTransactions; i++) + for (i = 0; i < theNoOfSentTransactions; i++) theSentTransactionsArray[i]->printState(); ndbout << "completed: " << theNoOfCompletedTransactions<< endl; if (checkdups(theCompletedTransactionsArray, theNoOfCompletedTransactions)) { ndbout << "!! DUPS !!" << endl; dups = true; } - for (unsigned i = 0; i < theNoOfCompletedTransactions; i++) + for (i = 0; i < theNoOfCompletedTransactions; i++) theCompletedTransactionsArray[i]->printState(); NdbMutex_Unlock(ndb_print_state_mutex); } diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index feab95d8ca5..f72361b86ac 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -21,6 +21,7 @@ #include <NdbIndexOperation.hpp> #include <NdbRecAttr.hpp> #include <NdbBlob.hpp> +#include "NdbBlobImpl.hpp" #include <NdbScanOperation.hpp> #ifdef NDB_BLOB_DEBUG @@ -33,21 +34,24 @@ ndbout << prefix << " " << hex << (void*)this << " " << cname; \ ndbout << " " << dec << __LINE__ << " " << x << " " << *this << endl; \ } while (0) -#else -#define DBG(x) -#endif static char* ndb_blob_debug(const Uint32* data, unsigned size) { - static char buf[128 + 1]; // MT irrelevant + static char buf[200]; // MT irrelevant buf[0] = 0; - for (unsigned i = 0; i < size && i < 128 / 4; i++) { - sprintf(buf + strlen(buf), "%*s%08x", i != 0, "", data[i]); + for (unsigned i = 0; i < size; i++) { + unsigned n = strlen(buf); + if (n + 10 < sizeof(buf)) + sprintf(buf + n, "%*s%08x", i != 0, "", data[i]); } return buf; } +#else +#define DBG(x) +#endif + /* * Reading index table directly (as a table) is faster but there are * bugs or limitations. Keep the code and make possible to choose. @@ -82,34 +86,36 @@ void NdbBlob::getBlobTableName(char* btname, const NdbTableImpl* t, const NdbColumnImpl* c) { assert(t != 0 && c != 0 && c->getBlobType()); - memset(btname, 0, BlobTableNameSize); + memset(btname, 0, NdbBlobImpl::BlobTableNameSize); sprintf(btname, "NDB$BLOB_%d_%d", (int)t->m_tableId, (int)c->m_attrId); } void NdbBlob::getBlobTable(NdbTableImpl& bt, const NdbTableImpl* t, const NdbColumnImpl* c) { - char btname[BlobTableNameSize]; + char btname[NdbBlobImpl::BlobTableNameSize]; getBlobTableName(btname, t, c); bt.setName(btname); bt.setLogging(t->getLogging()); bt.setFragmentType(t->getFragmentType()); - { NdbDictionary::Column bc("DIST"); + { NdbDictionary::Column bc("PK"); bc.setType(NdbDictionary::Column::Unsigned); + assert(t->m_sizeOfKeysInWords != 0); + bc.setLength(t->m_sizeOfKeysInWords); bc.setPrimaryKey(true); bc.setDistributionKey(true); bt.addColumn(bc); } - { NdbDictionary::Column bc("PART"); + { NdbDictionary::Column bc("DIST"); bc.setType(NdbDictionary::Column::Unsigned); bc.setPrimaryKey(true); + bc.setDistributionKey(true); bt.addColumn(bc); } - { NdbDictionary::Column bc("PK"); + { NdbDictionary::Column bc("PART"); bc.setType(NdbDictionary::Column::Unsigned); - assert(t->m_sizeOfKeysInWords != 0); - bc.setLength(t->m_sizeOfKeysInWords); bc.setPrimaryKey(true); + bc.setDistributionKey(false); bt.addColumn(bc); } { NdbDictionary::Column bc("DATA"); @@ -162,6 +168,7 @@ NdbBlob::init() theHead = NULL; theInlineData = NULL; theHeadInlineRecAttr = NULL; + theHeadInlineReadOp = NULL; theHeadInlineUpdateFlag = false; theNullFlag = -1; theLength = 0; @@ -206,6 +213,13 @@ NdbBlob::Buf::alloc(unsigned n) #endif } +void +NdbBlob::Buf::copyfrom(const NdbBlob::Buf& src) +{ + assert(size == src.size); + memcpy(data, src.data, size); +} + // classify operations (inline) inline bool @@ -226,6 +240,7 @@ NdbBlob::isKeyOp() return theNdbOp->theOperationType == NdbOperation::InsertRequest || theNdbOp->theOperationType == NdbOperation::UpdateRequest || + theNdbOp->theOperationType == NdbOperation::WriteRequest || theNdbOp->theOperationType == NdbOperation::ReadRequest || theNdbOp->theOperationType == NdbOperation::ReadExclusive || theNdbOp->theOperationType == NdbOperation::DeleteRequest; @@ -254,6 +269,13 @@ NdbBlob::isUpdateOp() } inline bool +NdbBlob::isWriteOp() +{ + return + theNdbOp->theOperationType == NdbOperation::WriteRequest; +} + +inline bool NdbBlob::isDeleteOp() { return @@ -373,9 +395,10 @@ NdbBlob::setPartKeyValue(NdbOperation* anOp, Uint32 part) Uint32* data = (Uint32*)theKeyBuf.data; unsigned size = theTable->m_sizeOfKeysInWords; DBG("setPartKeyValue dist=" << getDistKey(part) << " part=" << part << " key=" << ndb_blob_debug(data, size)); - if (anOp->equal((Uint32)0, getDistKey(part)) == -1 || - anOp->equal((Uint32)1, part) == -1 || - anOp->equal((Uint32)2, theKeyBuf.data) == -1) { + // TODO use attr ids after compatibility with 4.1.7 not needed + if (anOp->equal("PK", theKeyBuf.data) == -1 || + anOp->equal("DIST", getDistKey(part)) == -1 || + anOp->equal("PART", part) == -1) { setErrorCode(anOp); return -1; } @@ -401,7 +424,7 @@ NdbBlob::getHeadFromRecAttr() theNullFlag = theHeadInlineRecAttr->isNULL(); assert(theNullFlag != -1); theLength = ! theNullFlag ? theHead->length : 0; - DBG("getHeadFromRecAttr out"); + DBG("getHeadFromRecAttr [out]"); } int @@ -428,15 +451,15 @@ NdbBlob::getValue(void* data, Uint32 bytes) { DBG("getValue data=" << hex << data << " bytes=" << dec << bytes); if (theGetFlag || theState != Prepared) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } if (! isReadOp() && ! isScanOp()) { - setErrorCode(ErrUsage); + setErrorCode(NdbBlobImpl::ErrUsage); return -1; } if (data == NULL && bytes != 0) { - setErrorCode(ErrUsage); + setErrorCode(NdbBlobImpl::ErrUsage); return -1; } theGetFlag = true; @@ -450,15 +473,15 @@ NdbBlob::setValue(const void* data, Uint32 bytes) { DBG("setValue data=" << hex << data << " bytes=" << dec << bytes); if (theSetFlag || theState != Prepared) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } - if (! isInsertOp() && ! isUpdateOp()) { - setErrorCode(ErrUsage); + if (! isInsertOp() && ! isUpdateOp() && ! isWriteOp()) { + setErrorCode(NdbBlobImpl::ErrUsage); return -1; } if (data == NULL && bytes != 0) { - setErrorCode(ErrUsage); + setErrorCode(NdbBlobImpl::ErrUsage); return -1; } theSetFlag = true; @@ -466,11 +489,12 @@ NdbBlob::setValue(const void* data, Uint32 bytes) theGetSetBytes = bytes; if (isInsertOp()) { // write inline part now - if (theSetBuf != 0) { - unsigned n = theGetSetBytes; + if (theSetBuf != NULL) { + Uint32 n = theGetSetBytes; if (n > theInlineSize) n = theInlineSize; - if (writeDataPrivate(0, theSetBuf, n) == -1) + assert(thePos == 0); + if (writeDataPrivate(theSetBuf, n) == -1) return -1; } else { theNullFlag = true; @@ -489,7 +513,7 @@ NdbBlob::setActiveHook(ActiveHook activeHook, void* arg) { DBG("setActiveHook hook=" << hex << (void*)activeHook << " arg=" << hex << arg); if (theState != Prepared) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } theActiveHook = activeHook; @@ -508,7 +532,7 @@ NdbBlob::getNull(bool& isNull) return 0; } if (theNullFlag == -1) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } isNull = theNullFlag; @@ -523,7 +547,7 @@ NdbBlob::setNull() if (theState == Prepared) { return setValue(0, 0); } - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } if (theNullFlag) @@ -545,7 +569,7 @@ NdbBlob::getLength(Uint64& len) return 0; } if (theNullFlag == -1) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } len = theLength; @@ -555,9 +579,9 @@ NdbBlob::getLength(Uint64& len) int NdbBlob::truncate(Uint64 length) { - DBG("truncate length=" << length); + DBG("truncate [in] length=" << length); if (theNullFlag == -1) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } if (theLength > length) { @@ -573,7 +597,10 @@ NdbBlob::truncate(Uint64 length) } theLength = length; theHeadInlineUpdateFlag = true; + if (thePos > length) + thePos = length; } + DBG("truncate [out]"); return 0; } @@ -582,7 +609,7 @@ NdbBlob::getPos(Uint64& pos) { DBG("getPos"); if (theNullFlag == -1) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } pos = thePos; @@ -594,11 +621,11 @@ NdbBlob::setPos(Uint64 pos) { DBG("setPos pos=" << pos); if (theNullFlag == -1) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } if (pos > theLength) { - setErrorCode(ErrSeek); + setErrorCode(NdbBlobImpl::ErrSeek); return -1; } thePos = pos; @@ -610,32 +637,20 @@ NdbBlob::setPos(Uint64 pos) int NdbBlob::readData(void* data, Uint32& bytes) { - if (readData(thePos, data, bytes) == -1) - return -1; - thePos += bytes; - assert(thePos <= theLength); - return 0; -} - -int -NdbBlob::readData(Uint64 pos, void* data, Uint32& bytes) -{ if (theState != Active) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } char* buf = static_cast<char*>(data); - return readDataPrivate(pos, buf, bytes); + return readDataPrivate(buf, bytes); } int -NdbBlob::readDataPrivate(Uint64 pos, char* buf, Uint32& bytes) +NdbBlob::readDataPrivate(char* buf, Uint32& bytes) { - DBG("readData pos=" << pos << " bytes=" << bytes); - if (pos > theLength) { - setErrorCode(ErrSeek); - return -1; - } + DBG("readData [in] bytes=" << bytes); + assert(thePos <= theLength); + Uint64 pos = thePos; if (bytes > theLength - pos) bytes = theLength - pos; Uint32 len = bytes; @@ -652,7 +667,7 @@ NdbBlob::readDataPrivate(Uint64 pos, char* buf, Uint32& bytes) } } if (len > 0 && thePartSize == 0) { - setErrorCode(ErrSeek); + setErrorCode(NdbBlobImpl::ErrSeek); return -1; } if (len > 0) { @@ -665,7 +680,6 @@ NdbBlob::readDataPrivate(Uint64 pos, char* buf, Uint32& bytes) if (readParts(thePartBuf.data, part, 1) == -1) return -1; // need result now - DBG("execute pending part reads"); if (executePendingBlobReads() == -1) return -1; Uint32 n = thePartSize - off; @@ -699,7 +713,6 @@ NdbBlob::readDataPrivate(Uint64 pos, char* buf, Uint32& bytes) if (readParts(thePartBuf.data, part, 1) == -1) return -1; // need result now - DBG("execute pending part reads"); if (executePendingBlobReads() == -1) return -1; memcpy(buf, thePartBuf.data, len); @@ -709,38 +722,29 @@ NdbBlob::readDataPrivate(Uint64 pos, char* buf, Uint32& bytes) len -= n; } assert(len == 0); - return 0; -} - -int -NdbBlob::writeData(const void* data, Uint32 bytes) -{ - if (writeData(thePos, data, bytes) == -1) - return -1; - thePos += bytes; + thePos = pos; assert(thePos <= theLength); + DBG("readData [out]"); return 0; } int -NdbBlob::writeData(Uint64 pos, const void* data, Uint32 bytes) +NdbBlob::writeData(const void* data, Uint32 bytes) { if (theState != Active) { - setErrorCode(ErrState); + setErrorCode(NdbBlobImpl::ErrState); return -1; } const char* buf = static_cast<const char*>(data); - return writeDataPrivate(pos, buf, bytes); + return writeDataPrivate(buf, bytes); } int -NdbBlob::writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes) +NdbBlob::writeDataPrivate(const char* buf, Uint32 bytes) { - DBG("writeData pos=" << pos << " bytes=" << bytes); - if (pos > theLength) { - setErrorCode(ErrSeek); - return -1; - } + DBG("writeData [in] bytes=" << bytes); + assert(thePos <= theLength); + Uint64 pos = thePos; Uint32 len = bytes; // any write makes blob not NULL if (theNullFlag) { @@ -761,7 +765,7 @@ NdbBlob::writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes) } } if (len > 0 && thePartSize == 0) { - setErrorCode(ErrSeek); + setErrorCode(NdbBlobImpl::ErrSeek); return -1; } if (len > 0) { @@ -771,14 +775,12 @@ NdbBlob::writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes) if (off != 0) { DBG("partial first block pos=" << pos << " len=" << len); // flush writes to guarantee correct read - DBG("execute pending part writes"); if (executePendingBlobWrites() == -1) return -1; Uint32 part = (pos - theInlineSize) / thePartSize; if (readParts(thePartBuf.data, part, 1) == -1) return -1; // need result now - DBG("execute pending part reafs"); if (executePendingBlobReads() == -1) return -1; Uint32 n = thePartSize - off; @@ -822,13 +824,11 @@ NdbBlob::writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes) Uint32 part = (pos - theInlineSize) / thePartSize; if (theLength > pos + len) { // flush writes to guarantee correct read - DBG("execute pending part writes"); if (executePendingBlobWrites() == -1) return -1; if (readParts(thePartBuf.data, part, 1) == -1) return -1; // need result now - DBG("execute pending part reads"); if (executePendingBlobReads() == -1) return -1; memcpy(thePartBuf.data, buf, len); @@ -855,14 +855,16 @@ NdbBlob::writeDataPrivate(Uint64 pos, const char* buf, Uint32 bytes) theLength = pos; theHeadInlineUpdateFlag = true; } - DBG("writeData out"); + thePos = pos; + assert(thePos <= theLength); + DBG("writeData [out]"); return 0; } int NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) { - DBG("readParts part=" << part << " count=" << count); + DBG("readParts [in] part=" << part << " count=" << count); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -873,6 +875,7 @@ NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) setErrorCode(tOp); return -1; } + tOp->m_abortOption = AbortOnError; buf += thePartSize; n++; thePendingBlobOps |= (1 << NdbOperation::ReadRequest); @@ -884,7 +887,7 @@ NdbBlob::readParts(char* buf, Uint32 part, Uint32 count) int NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) { - DBG("insertParts part=" << part << " count=" << count); + DBG("insertParts [in] part=" << part << " count=" << count); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -895,6 +898,7 @@ NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) setErrorCode(tOp); return -1; } + tOp->m_abortOption = AbortOnError; buf += thePartSize; n++; thePendingBlobOps |= (1 << NdbOperation::InsertRequest); @@ -906,7 +910,7 @@ NdbBlob::insertParts(const char* buf, Uint32 part, Uint32 count) int NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) { - DBG("updateParts part=" << part << " count=" << count); + DBG("updateParts [in] part=" << part << " count=" << count); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -917,6 +921,7 @@ NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) setErrorCode(tOp); return -1; } + tOp->m_abortOption = AbortOnError; buf += thePartSize; n++; thePendingBlobOps |= (1 << NdbOperation::UpdateRequest); @@ -928,7 +933,7 @@ NdbBlob::updateParts(const char* buf, Uint32 part, Uint32 count) int NdbBlob::deleteParts(Uint32 part, Uint32 count) { - DBG("deleteParts part=" << part << " count=" << count); + DBG("deleteParts [in] part=" << part << " count=" << count); Uint32 n = 0; while (n < count) { NdbOperation* tOp = theNdbCon->getNdbOperation(theBlobTable); @@ -938,6 +943,7 @@ NdbBlob::deleteParts(Uint32 part, Uint32 count) setErrorCode(tOp); return -1; } + tOp->m_abortOption = AbortOnError; n++; thePendingBlobOps |= (1 << NdbOperation::DeleteRequest); theNdbCon->thePendingBlobOps |= (1 << NdbOperation::DeleteRequest); @@ -945,6 +951,59 @@ NdbBlob::deleteParts(Uint32 part, Uint32 count) return 0; } +/* + * Number of blob parts not known. Used to check for race condition + * when writeTuple is used for insert. Deletes all parts found. + */ +int +NdbBlob::deletePartsUnknown(Uint32 part) +{ + DBG("deletePartsUnknown [in] part=" << part << " count=all"); + static const unsigned maxbat = 256; + static const unsigned minbat = 1; + unsigned bat = minbat; + NdbOperation* tOpList[maxbat]; + Uint32 count = 0; + while (true) { + Uint32 n; + n = 0; + while (n < bat) { + NdbOperation*& tOp = tOpList[n]; // ref + tOp = theNdbCon->getNdbOperation(theBlobTable); + if (tOp == NULL || + tOp->deleteTuple() == -1 || + setPartKeyValue(tOp, part + count + n) == -1) { + setErrorCode(tOp); + return -1; + } + tOp->m_abortOption = AO_IgnoreError; + n++; + } + DBG("deletePartsUnknown: executeNoBlobs [in] bat=" << bat); + if (theNdbCon->executeNoBlobs(NoCommit) == -1) + return -1; + DBG("deletePartsUnknown: executeNoBlobs [out]"); + n = 0; + while (n < bat) { + NdbOperation* tOp = tOpList[n]; + if (tOp->theError.code != 0) { + if (tOp->theError.code != 626) { + setErrorCode(tOp); + return -1; + } + // first non-existent part + DBG("deletePartsUnknown [out] count=" << count); + return 0; + } + n++; + count++; + } + bat *= 4; + if (bat > maxbat) + bat = maxbat; + } +} + // pending ops int @@ -952,8 +1011,10 @@ NdbBlob::executePendingBlobReads() { Uint8 flags = (1 << NdbOperation::ReadRequest); if (thePendingBlobOps & flags) { + DBG("executePendingBlobReads: executeNoBlobs [in]"); if (theNdbCon->executeNoBlobs(NoCommit) == -1) return -1; + DBG("executePendingBlobReads: executeNoBlobs [out]"); thePendingBlobOps = 0; theNdbCon->thePendingBlobOps = 0; } @@ -965,8 +1026,10 @@ NdbBlob::executePendingBlobWrites() { Uint8 flags = 0xFF & ~(1 << NdbOperation::ReadRequest); if (thePendingBlobOps & flags) { + DBG("executePendingBlobWrites: executeNoBlobs [in]"); if (theNdbCon->executeNoBlobs(NoCommit) == -1) return -1; + DBG("executePendingBlobWrites: executeNoBlobs [out]"); thePendingBlobOps = 0; theNdbCon->thePendingBlobOps = 0; } @@ -978,10 +1041,10 @@ NdbBlob::executePendingBlobWrites() int NdbBlob::invokeActiveHook() { - DBG("invokeActiveHook"); + DBG("invokeActiveHook [in]"); assert(theState == Active && theActiveHook != NULL); int ret = (*theActiveHook)(this, theActiveHookArg); - DBG("invokeActiveHook ret=" << ret); + DBG("invokeActiveHook [out] ret=" << ret); if (ret != 0) { // no error is set on blob level return -1; @@ -1007,7 +1070,7 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* theTable = anOp->m_currentTable; theAccessTable = anOp->m_accessTable; theColumn = aColumn; - DBG("atPrepare"); + DBG("atPrepare [in]"); NdbDictionary::Column::Type partType = NdbDictionary::Column::Undefined; switch (theColumn->getType()) { case NdbDictionary::Column::Blob: @@ -1019,7 +1082,7 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* theFillChar = 0x20; break; default: - setErrorCode(ErrUsage); + setErrorCode(NdbBlobImpl::ErrUsage); return -1; } // sizes @@ -1037,7 +1100,7 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* (bc = bt->getColumn("DATA")) == NULL || bc->getType() != partType || bc->getLength() != (int)thePartSize) { - setErrorCode(ErrTable); + setErrorCode(NdbBlobImpl::ErrTable); return -1; } theBlobTable = &NdbTableImpl::getImpl(*bt); @@ -1046,6 +1109,7 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* theKeyBuf.alloc(theTable->m_sizeOfKeysInWords << 2); theAccessKeyBuf.alloc(theAccessTable->m_sizeOfKeysInWords << 2); theHeadInlineBuf.alloc(sizeof(Head) + theInlineSize); + theHeadInlineCopyBuf.alloc(sizeof(Head) + theInlineSize); thePartBuf.alloc(thePartSize); theHead = (Head*)theHeadInlineBuf.data; theInlineData = theHeadInlineBuf.data + sizeof(Head); @@ -1057,7 +1121,7 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* Uint32* data = (Uint32*)theKeyBuf.data; unsigned size = theTable->m_sizeOfKeysInWords; if (theNdbOp->getKeyFromTCREQ(data, size) == -1) { - setErrorCode(ErrUsage); + setErrorCode(NdbBlobImpl::ErrUsage); return -1; } } @@ -1066,7 +1130,7 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* Uint32* data = (Uint32*)theAccessKeyBuf.data; unsigned size = theAccessTable->m_sizeOfKeysInWords; if (theNdbOp->getKeyFromTCREQ(data, size) == -1) { - setErrorCode(ErrUsage); + setErrorCode(NdbBlobImpl::ErrUsage); return -1; } } @@ -1080,6 +1144,12 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* theNullFlag = true; theLength = 0; } + if (isWriteOp()) { + // becomes NULL unless set before execute + theNullFlag = true; + theLength = 0; + theHeadInlineUpdateFlag = true; + } supportedOp = true; } if (isScanOp()) { @@ -1089,23 +1159,25 @@ NdbBlob::atPrepare(NdbConnection* aCon, NdbOperation* anOp, const NdbColumnImpl* supportedOp = true; } if (! supportedOp) { - setErrorCode(ErrUsage); + setErrorCode(NdbBlobImpl::ErrUsage); return -1; } setState(Prepared); - DBG("atPrepare out"); + DBG("atPrepare [out]"); return 0; } /* * Before execute of prepared operation. May add new operations before * this one. May ask that this operation and all before it (a "batch") - * is executed immediately in no-commit mode. + * is executed immediately in no-commit mode. In this case remaining + * prepared operations are saved in a separate list. They are added + * back after postExecute. */ int NdbBlob::preExecute(ExecType anExecType, bool& batch) { - DBG("preExecute"); + DBG("preExecute [in]"); if (theState == Invalid) return -1; assert(theState == Prepared); @@ -1120,11 +1192,11 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) if (isInsertOp()) { if (theSetFlag && theGetSetBytes > theInlineSize) { // add ops to write rest of a setValue - assert(theSetBuf != 0); - Uint64 pos = theInlineSize; + assert(theSetBuf != NULL); const char* buf = theSetBuf + theInlineSize; Uint32 bytes = theGetSetBytes - theInlineSize; - if (writeDataPrivate(pos, buf, bytes) == -1) + assert(thePos == theInlineSize); + if (writeDataPrivate(buf, bytes) == -1) return -1; if (theHeadInlineUpdateFlag) { // add an operation to update head+inline @@ -1133,14 +1205,15 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) tOp->updateTuple() == -1 || setTableKeyValue(tOp) == -1 || setHeadInlineValue(tOp) == -1) { - setErrorCode(ErrAbort); + setErrorCode(NdbBlobImpl::ErrAbort); return -1; } + DBG("add op to update head+inline"); } } } if (isTableOp()) { - if (isUpdateOp() || isDeleteOp()) { + if (isUpdateOp() || isWriteOp() || isDeleteOp()) { // add operation before this one to read head+inline NdbOperation* tOp = theNdbCon->getNdbOperation(theTable, theNdbOp); if (tOp == NULL || @@ -1150,8 +1223,13 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) setErrorCode(tOp); return -1; } + if (isWriteOp()) { + tOp->m_abortOption = AO_IgnoreError; + } + theHeadInlineReadOp = tOp; // execute immediately batch = true; + DBG("add op before to read head+inline"); } } if (isIndexOp()) { @@ -1170,7 +1248,7 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) return -1; } } else { - NdbOperation* tOp = theNdbCon->getNdbIndexOperation(theAccessTable->m_index, theTable, theNdbOp); + NdbIndexOperation* tOp = theNdbCon->getNdbIndexOperation(theAccessTable->m_index, theTable, theNdbOp); if (tOp == NULL || tOp->readTuple() == -1 || setAccessKeyValue(tOp) == -1 || @@ -1180,6 +1258,7 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) } } } + DBG("added op before to read table key"); if (isUpdateOp() || isDeleteOp()) { // add op before this one to read head+inline via index NdbIndexOperation* tOp = theNdbCon->getNdbIndexOperation(theAccessTable->m_index, theTable, theNdbOp); @@ -1190,15 +1269,43 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) setErrorCode(tOp); return -1; } + if (isWriteOp()) { + tOp->m_abortOption = AO_IgnoreError; + } + theHeadInlineReadOp = tOp; // execute immediately batch = true; + DBG("added index op before to read head+inline"); + } + if (isWriteOp()) { + // XXX until IgnoreError fixed for index op + batch = true; + } + } + if (isWriteOp()) { + if (theSetFlag) { + // write head+inline now + theNullFlag = true; + theLength = 0; + if (theSetBuf != NULL) { + Uint32 n = theGetSetBytes; + if (n > theInlineSize) + n = theInlineSize; + assert(thePos == 0); + if (writeDataPrivate(theSetBuf, n) == -1) + return -1; + } + if (setHeadInlineValue(theNdbOp) == -1) + return -1; + // the read op before us may overwrite + theHeadInlineCopyBuf.copyfrom(theHeadInlineBuf); } } if (theActiveHook != NULL) { // need blob head for callback batch = true; } - DBG("preExecute out batch=" << batch); + DBG("preExecute [out] batch=" << batch); return 0; } @@ -1211,15 +1318,16 @@ NdbBlob::preExecute(ExecType anExecType, bool& batch) int NdbBlob::postExecute(ExecType anExecType) { - DBG("postExecute type=" << anExecType); + DBG("postExecute [in] type=" << anExecType); if (theState == Invalid) return -1; if (theState == Active) { setState(anExecType == NoCommit ? Active : Closed); - DBG("postExecute skip"); + DBG("postExecute [skip]"); return 0; } assert(theState == Prepared); + setState(anExecType == NoCommit ? Active : Closed); assert(isKeyOp()); if (isIndexOp()) { NdbBlob* tFirstBlob = theNdbOp->theBlobList; @@ -1231,22 +1339,13 @@ NdbBlob::postExecute(ExecType anExecType) } if (isReadOp()) { getHeadFromRecAttr(); - if (theGetFlag && theGetSetBytes > 0) { - // copy inline bytes to user buffer - assert(theGetBuf != NULL); - unsigned n = theGetSetBytes; - if (n > theInlineSize) - n = theInlineSize; - memcpy(theGetBuf, theInlineData, n); - } - if (theGetFlag && theGetSetBytes > theInlineSize) { - // add ops to read rest of a getValue - assert(anExecType == NoCommit); - assert(theGetBuf != 0); - Uint64 pos = theInlineSize; - char* buf = theGetBuf + theInlineSize; - Uint32 bytes = theGetSetBytes - theInlineSize; - if (readDataPrivate(pos, buf, bytes) == -1) + if (setPos(0) == -1) + return -1; + if (theGetFlag) { + assert(theGetSetBytes == 0 || theGetBuf != 0); + assert(theGetSetBytes <= theInlineSize || anExecType == NoCommit); + Uint32 bytes = theGetSetBytes; + if (readDataPrivate(theGetBuf, bytes) == -1) return -1; } } @@ -1255,10 +1354,11 @@ NdbBlob::postExecute(ExecType anExecType) getHeadFromRecAttr(); if (theSetFlag) { // setValue overwrites everything - if (theSetBuf != 0) { + if (theSetBuf != NULL) { if (truncate(0) == -1) return -1; - if (writeDataPrivate(0, theSetBuf, theGetSetBytes) == -1) + assert(thePos == 0); + if (writeDataPrivate(theSetBuf, theGetSetBytes) == -1) return -1; } else { if (setNull() == -1) @@ -1266,6 +1366,57 @@ NdbBlob::postExecute(ExecType anExecType) } } } + if (isWriteOp() && isTableOp()) { + assert(anExecType == NoCommit); + if (theHeadInlineReadOp->theError.code == 0) { + int tNullFlag = theNullFlag; + Uint64 tLength = theLength; + Uint64 tPos = thePos; + getHeadFromRecAttr(); + DBG("tuple found"); + if (truncate(0) == -1) + return -1; + // restore previous head+inline + theHeadInlineBuf.copyfrom(theHeadInlineCopyBuf); + theNullFlag = tNullFlag; + theLength = tLength; + thePos = tPos; + } else { + if (theHeadInlineReadOp->theError.code != 626) { + setErrorCode(theHeadInlineReadOp); + return -1; + } + DBG("tuple not found"); + /* + * Read found no tuple but it is possible that a tuple was + * created after the read by another transaction. Delete all + * blob parts which may exist. + */ + if (deletePartsUnknown(0) == -1) + return -1; + } + if (theSetFlag && theGetSetBytes > theInlineSize) { + assert(theSetBuf != NULL); + const char* buf = theSetBuf + theInlineSize; + Uint32 bytes = theGetSetBytes - theInlineSize; + assert(thePos == theInlineSize); + if (writeDataPrivate(buf, bytes) == -1) + return -1; + } + } + if (isWriteOp() && isIndexOp()) { + // XXX until IgnoreError fixed for index op + if (deletePartsUnknown(0) == -1) + return -1; + if (theSetFlag && theGetSetBytes > theInlineSize) { + assert(theSetBuf != NULL); + const char* buf = theSetBuf + theInlineSize; + Uint32 bytes = theGetSetBytes - theInlineSize; + assert(thePos == theInlineSize); + if (writeDataPrivate(buf, bytes) == -1) + return -1; + } + } if (isDeleteOp()) { assert(anExecType == NoCommit); getHeadFromRecAttr(); @@ -1278,7 +1429,19 @@ NdbBlob::postExecute(ExecType anExecType) if (invokeActiveHook() == -1) return -1; } - DBG("postExecute out"); + if (anExecType == NoCommit && theHeadInlineUpdateFlag) { + NdbOperation* tOp = theNdbCon->getNdbOperation(theTable); + if (tOp == NULL || + tOp->updateTuple() == -1 || + setTableKeyValue(tOp) == -1 || + setHeadInlineValue(tOp) == -1) { + setErrorCode(NdbBlobImpl::ErrAbort); + return -1; + } + tOp->m_abortOption = AbortOnError; + DBG("added op to update head+inline"); + } + DBG("postExecute [out]"); return 0; } @@ -1289,12 +1452,12 @@ NdbBlob::postExecute(ExecType anExecType) int NdbBlob::preCommit() { - DBG("preCommit"); + DBG("preCommit [in]"); if (theState == Invalid) return -1; assert(theState == Active); assert(isKeyOp()); - if (isInsertOp() || isUpdateOp()) { + if (isInsertOp() || isUpdateOp() || isWriteOp()) { if (theHeadInlineUpdateFlag) { // add an operation to update head+inline NdbOperation* tOp = theNdbCon->getNdbOperation(theTable); @@ -1302,12 +1465,14 @@ NdbBlob::preCommit() tOp->updateTuple() == -1 || setTableKeyValue(tOp) == -1 || setHeadInlineValue(tOp) == -1) { - setErrorCode(ErrAbort); + setErrorCode(NdbBlobImpl::ErrAbort); return -1; } + tOp->m_abortOption = AbortOnError; + DBG("added op to update head+inline"); } } - DBG("preCommit out"); + DBG("preCommit [out]"); return 0; } @@ -1317,41 +1482,26 @@ NdbBlob::preCommit() int NdbBlob::atNextResult() { - DBG("atNextResult"); + DBG("atNextResult [in]"); if (theState == Invalid) return -1; assert(isScanOp()); - getHeadFromRecAttr(); - // reset position - thePos = 0; // get primary key { Uint32* data = (Uint32*)theKeyBuf.data; unsigned size = theTable->m_sizeOfKeysInWords; if (((NdbScanOperation*)theNdbOp)->getKeyFromKEYINFO20(data, size) == -1) { - setErrorCode(ErrUsage); + setErrorCode(NdbBlobImpl::ErrUsage); return -1; } } - if (! theNullFlag) { - if (theGetFlag && theGetSetBytes > 0) { - // copy inline bytes to user buffer - assert(theGetBuf != NULL); - unsigned n = theGetSetBytes; - if (n > theLength) - n = theLength; - if (n > theInlineSize) - n = theInlineSize; - memcpy(theGetBuf, theInlineData, n); - } - if (theGetFlag && theGetSetBytes > theInlineSize && theLength > theInlineSize) { - // add ops to read rest of a getValue - assert(theGetBuf != 0); - Uint64 pos = theInlineSize; - char* buf = theGetBuf + theInlineSize; - Uint32 bytes = theGetSetBytes - theInlineSize; - if (readDataPrivate(pos, buf, bytes) == -1) - return -1; - } + getHeadFromRecAttr(); + if (setPos(0) == -1) + return -1; + if (theGetFlag) { + assert(theGetSetBytes == 0 || theGetBuf != 0); + Uint32 bytes = theGetSetBytes; + if (readDataPrivate(theGetBuf, bytes) == -1) + return -1; } setState(Active); // activation callback @@ -1359,7 +1509,7 @@ NdbBlob::atNextResult() if (invokeActiveHook() == -1) return -1; } - DBG("atNextResult out"); + DBG("atNextResult [out]"); return 0; } @@ -1396,7 +1546,7 @@ NdbBlob::setErrorCode(NdbOperation* anOp, bool invalidFlag) else if ((code = theNdb->theError.code) != 0) ; else - code = ErrUnknown; + code = NdbBlobImpl::ErrUnknown; setErrorCode(code, invalidFlag); } @@ -1409,7 +1559,7 @@ NdbBlob::setErrorCode(NdbConnection* aCon, bool invalidFlag) else if ((code = theNdb->theError.code) != 0) ; else - code = ErrUnknown; + code = NdbBlobImpl::ErrUnknown; setErrorCode(code, invalidFlag); } @@ -1444,7 +1594,8 @@ operator<<(NdbOut& out, const NdbBlob& blob) ndbout << dec << " n=" << blob.theNullFlag;; ndbout << dec << " l=" << blob.theLength; ndbout << dec << " p=" << blob.thePos; - ndbout << dec << " u=" << (Uint32) blob.theHeadInlineUpdateFlag; + ndbout << dec << " u=" << (Uint32)blob.theHeadInlineUpdateFlag; + ndbout << dec << " g=" << (Uint32)blob.theGetSetBytes; return out; } #endif diff --git a/ndb/src/ndbapi/NdbBlobImpl.hpp b/ndb/src/ndbapi/NdbBlobImpl.hpp new file mode 100644 index 00000000000..0030e910c52 --- /dev/null +++ b/ndb/src/ndbapi/NdbBlobImpl.hpp @@ -0,0 +1,39 @@ +/* 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 NdbBlobImpl_H +#define NdbBlobImpl_H + +class NdbBlobImpl { +public: + STATIC_CONST( BlobTableNameSize = 40 ); + // "Invalid blob attributes or invalid blob parts table" + STATIC_CONST( ErrTable = 4263 ); + // "Invalid usage of blob attribute" + STATIC_CONST( ErrUsage = 4264 ); + // "Method is not valid in current blob state" + STATIC_CONST( ErrState = 4265 ); + // "Invalid blob seek position" + STATIC_CONST( ErrSeek = 4266 ); + // "Corrupted blob value" + STATIC_CONST( ErrCorrupt = 4267 ); + // "Error in blob head update forced rollback of transaction" + STATIC_CONST( ErrAbort = 4268 ); + // "Unknown blob error" + STATIC_CONST( ErrUnknown = 4269 ); +}; + +#endif diff --git a/ndb/src/ndbapi/NdbConnection.cpp b/ndb/src/ndbapi/NdbConnection.cpp index 1457792cf28..0a1c7303771 100644 --- a/ndb/src/ndbapi/NdbConnection.cpp +++ b/ndb/src/ndbapi/NdbConnection.cpp @@ -55,6 +55,7 @@ NdbConnection::NdbConnection( Ndb* aNdb ) : theFirstExecOpInList(NULL), theLastExecOpInList(NULL), theCompletedFirstOp(NULL), + theCompletedLastOp(NULL), theNoOfOpSent(0), theNoOfOpCompleted(0), theNoOfOpFetched(0), @@ -82,7 +83,7 @@ NdbConnection::NdbConnection( Ndb* aNdb ) : { theListState = NotInList; theError.code = 0; - theId = theNdb->theNdbObjectIdMap->map(this); + theId = theNdb->theImpl->theNdbObjectIdMap.map(this); #define CHECK_SZ(mask, sz) assert((sizeof(mask)/sizeof(mask[0])) == sz) @@ -98,7 +99,7 @@ Remark: Deletes the connection object. NdbConnection::~NdbConnection() { DBUG_ENTER("NdbConnection::~NdbConnection"); - theNdb->theNdbObjectIdMap->unmap(theId, this); + theNdb->theImpl->theNdbObjectIdMap.unmap(theId, this); DBUG_VOID_RETURN; }//NdbConnection::~NdbConnection() @@ -124,6 +125,7 @@ NdbConnection::init() theLastExecOpInList = NULL; theCompletedFirstOp = NULL; + theCompletedLastOp = NULL; theGlobalCheckpointId = 0; theCommitStatus = Started; @@ -170,12 +172,14 @@ Remark: Sets an error code on the connection object from an operation object. *****************************************************************************/ void -NdbConnection::setOperationErrorCodeAbort(int error) +NdbConnection::setOperationErrorCodeAbort(int error, int abortOption) { DBUG_ENTER("NdbConnection::setOperationErrorCodeAbort"); + if (abortOption == -1) + abortOption = m_abortOption; if (theTransactionIsStarted == false) { theCommitStatus = Aborted; - } else if ((m_abortOption == AbortOnError) && + } else if ((abortOption == AbortOnError) && (theCommitStatus != Committed) && (theCommitStatus != Aborted)) { theCommitStatus = NeedAbort; @@ -254,6 +258,8 @@ NdbConnection::handleExecuteCompletion() if (tLastExecOp != NULL) { tLastExecOp->next(theCompletedFirstOp); theCompletedFirstOp = tFirstExecOp; + if (theCompletedLastOp == NULL) + theCompletedLastOp = tLastExecOp; theFirstExecOpInList = NULL; theLastExecOpInList = NULL; }//if @@ -290,6 +296,8 @@ NdbConnection::execute(ExecType aTypeOfExec, ExecType tExecType; NdbOperation* tPrepOp; + NdbOperation* tCompletedFirstOp = NULL; + NdbOperation* tCompletedLastOp = NULL; int ret = 0; do { @@ -312,6 +320,7 @@ NdbConnection::execute(ExecType aTypeOfExec, } tPrepOp = tPrepOp->next(); } + // save rest of prepared ops if batch NdbOperation* tRestOp= 0; NdbOperation* tLastOp= 0; @@ -321,6 +330,7 @@ NdbConnection::execute(ExecType aTypeOfExec, tLastOp = theLastOpInList; theLastOpInList = tPrepOp; } + if (tExecType == Commit) { NdbOperation* tOp = theCompletedFirstOp; while (tOp != NULL) { @@ -335,8 +345,28 @@ NdbConnection::execute(ExecType aTypeOfExec, tOp = tOp->next(); } } + + // completed ops are in unspecified order + if (theCompletedFirstOp != NULL) { + if (tCompletedFirstOp == NULL) { + tCompletedFirstOp = theCompletedFirstOp; + tCompletedLastOp = theCompletedLastOp; + } else { + tCompletedLastOp->next(theCompletedFirstOp); + tCompletedLastOp = theCompletedLastOp; + } + theCompletedFirstOp = NULL; + theCompletedLastOp = NULL; + } + if (executeNoBlobs(tExecType, abortOption, forceSend) == -1) ret = -1; +#ifdef ndb_api_crash_on_complex_blob_abort + assert(theFirstOpInList == NULL && theLastOpInList == NULL); +#else + theFirstOpInList = theLastOpInList = NULL; +#endif + { NdbOperation* tOp = theCompletedFirstOp; while (tOp != NULL) { @@ -352,6 +382,7 @@ NdbConnection::execute(ExecType aTypeOfExec, tOp = tOp->next(); } } + // add saved prepared ops if batch if (tPrepOp != NULL && tRestOp != NULL) { if (theFirstOpInList == NULL) @@ -360,8 +391,21 @@ NdbConnection::execute(ExecType aTypeOfExec, theLastOpInList->next(tRestOp); theLastOpInList = tLastOp; } + assert(theFirstOpInList == NULL || tExecType == NoCommit); } while (theFirstOpInList != NULL || tExecType != aTypeOfExec); + if (tCompletedFirstOp != NULL) { + tCompletedLastOp->next(theCompletedFirstOp); + theCompletedFirstOp = tCompletedFirstOp; + if (theCompletedLastOp == NULL) + theCompletedLastOp = tCompletedLastOp; + } +#if ndb_api_count_completed_ops_after_blob_execute + { NdbOperation* tOp; unsigned n = 0; + for (tOp = theCompletedFirstOp; tOp != NULL; tOp = tOp->next()) n++; + ndbout << "completed ops: " << n << endl; + } +#endif DBUG_RETURN(ret); } @@ -883,6 +927,7 @@ NdbConnection::releaseOperations() releaseOps(theFirstExecOpInList); theCompletedFirstOp = NULL; + theCompletedLastOp = NULL; theFirstOpInList = NULL; theFirstExecOpInList = NULL; theLastOpInList = NULL; @@ -898,6 +943,7 @@ NdbConnection::releaseCompletedOperations() { releaseOps(theCompletedFirstOp); theCompletedFirstOp = NULL; + theCompletedLastOp = NULL; }//NdbConnection::releaseOperations() /****************************************************************************** @@ -1075,8 +1121,11 @@ NdbConnection::getNdbIndexScanOperation(const NdbIndexImpl* index, if (indexTable != 0){ NdbIndexScanOperation* tOp = getNdbScanOperation((NdbTableImpl *) indexTable); - tOp->m_currentTable = table; - if(tOp) tOp->m_cursor_type = NdbScanOperation::IndexCursor; + if(tOp) + { + tOp->m_currentTable = table; + tOp->m_cursor_type = NdbScanOperation::IndexCursor; + } return tOp; } else { setOperationErrorCodeAbort(theNdb->theError.code); @@ -1567,13 +1616,10 @@ from other transactions. (theLastExecOpInList->theCommitIndicator == 1)){ - if (m_abortOption == IgnoreError && theError.code != 0){ + if (m_abortOption == AO_IgnoreError && theError.code != 0){ /** * There's always a TCKEYCONF when using IgnoreError */ -#ifdef VM_TRACE - ndbout_c("Not completing transaction 2"); -#endif return -1; } /**********************************************************************/ @@ -1806,11 +1852,12 @@ Parameters: aErrorCode: The error code. Remark: An operation was completed with failure. *******************************************************************************/ int -NdbConnection::OpCompleteFailure(Uint8 abortOption) +NdbConnection::OpCompleteFailure(Uint8 abortOption, bool setFailure) { Uint32 tNoComp = theNoOfOpCompleted; Uint32 tNoSent = theNoOfOpSent; - theCompletionStatus = NdbConnection::CompletedFailure; + if (setFailure) + theCompletionStatus = NdbConnection::CompletedFailure; tNoComp++; theNoOfOpCompleted = tNoComp; if (tNoComp == tNoSent) { @@ -1820,13 +1867,10 @@ NdbConnection::OpCompleteFailure(Uint8 abortOption) //decide the success of the whole transaction since a simple //operation is not really part of that transaction. //------------------------------------------------------------------------ - if (abortOption == IgnoreError){ + if (abortOption == AO_IgnoreError){ /** * There's always a TCKEYCONF when using IgnoreError */ -#ifdef VM_TRACE - ndbout_c("Not completing transaction"); -#endif return -1; } diff --git a/ndb/src/ndbapi/NdbConnectionScan.cpp b/ndb/src/ndbapi/NdbConnectionScan.cpp index 3fe8993a42b..b0c546c512a 100644 --- a/ndb/src/ndbapi/NdbConnectionScan.cpp +++ b/ndb/src/ndbapi/NdbConnectionScan.cpp @@ -56,13 +56,19 @@ NdbConnection::receiveSCAN_TABREF(NdbApiSignal* aSignal){ const ScanTabRef * ref = CAST_CONSTPTR(ScanTabRef, aSignal->getDataPtr()); if(checkState_TransId(&ref->transId1)){ - theScanningOp->theError.code = ref->errorCode; + theScanningOp->setErrorCode(ref->errorCode); + theScanningOp->execCLOSE_SCAN_REP(); if(!ref->closeNeeded){ - theScanningOp->execCLOSE_SCAN_REP(); return 0; } - assert(theScanningOp->m_sent_receivers_count); + + /** + * Setup so that close_impl will actually perform a close + * and not "close scan"-optimze it away + */ theScanningOp->m_conf_receivers_count++; + theScanningOp->m_conf_receivers[0] = theScanningOp->m_receivers[0]; + theScanningOp->m_conf_receivers[0]->m_tcPtrI = ~0; return 0; } else { #ifdef NDB_NO_DROPPED_SIGNAL @@ -97,7 +103,7 @@ NdbConnection::receiveSCAN_TABCONF(NdbApiSignal* aSignal, theScanningOp->execCLOSE_SCAN_REP(); return 0; } - + for(Uint32 i = 0; i<len; i += 3){ Uint32 opCount, totalLen; Uint32 ptrI = * ops++; @@ -109,24 +115,12 @@ NdbConnection::receiveSCAN_TABCONF(NdbApiSignal* aSignal, void * tPtr = theNdb->int2void(ptrI); assert(tPtr); // For now NdbReceiver* tOp = theNdb->void2rec(tPtr); - if (tOp && tOp->checkMagicNumber()){ - if(tOp->execSCANOPCONF(tcPtrI, totalLen, opCount)){ - /** - * - */ - theScanningOp->receiver_delivered(tOp); - } else if(info == ScanTabConf::EndOfData){ + if (tOp && tOp->checkMagicNumber()) + { + if (tcPtrI == RNIL && opCount == 0) theScanningOp->receiver_completed(tOp); - } - } - } - if (conf->requestInfo & ScanTabConf::EndOfData) { - if(theScanningOp->m_ordered) - theScanningOp->m_api_receivers_count = 0; - if(theScanningOp->m_api_receivers_count + - theScanningOp->m_conf_receivers_count + - theScanningOp->m_sent_receivers_count){ - abort(); + else if (tOp->execSCANOPCONF(tcPtrI, totalLen, opCount)) + theScanningOp->receiver_delivered(tOp); } } return 0; diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index c8414ec16a3..00db5704949 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -343,6 +343,18 @@ NdbDictionary::Table::getColumn(const int attrId) const { return m_impl.getColumn(attrId); } +NdbDictionary::Column* +NdbDictionary::Table::getColumn(const char * name) +{ + return m_impl.getColumn(name); +} + +NdbDictionary::Column* +NdbDictionary::Table::getColumn(const int attrId) +{ + return m_impl.getColumn(attrId); +} + void NdbDictionary::Table::setLogging(bool val){ m_impl.m_logging = val; @@ -761,14 +773,6 @@ NdbDictionary::Dictionary::removeCachedTable(const char * name){ m_impl.removeCachedObject(* t); } -NdbDictionary::Table -NdbDictionary::Dictionary::getTableForAlteration(const char * name){ - const NdbDictionary::Table * oldTable = getTable(name); - return (oldTable) ? - NdbDictionary::Table(*oldTable) - : NdbDictionary::Table(); -} - int NdbDictionary::Dictionary::createIndex(const Index & ind) { @@ -914,8 +918,11 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) case NdbDictionary::Column::Double: out << "Double"; break; - case NdbDictionary::Column::Decimal: - out << "Decimal(" << col.getScale() << "," << col.getPrecision() << ")"; + case NdbDictionary::Column::Olddecimal: + out << "Olddecimal(" << col.getPrecision() << "," << col.getScale() << ")"; + break; + case NdbDictionary::Column::Olddecimalunsigned: + out << "Olddecimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")"; break; case NdbDictionary::Column::Char: out << "Char(" << col.getLength() << ";" << csname << ")"; @@ -932,8 +939,8 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) case NdbDictionary::Column::Datetime: out << "Datetime"; break; - case NdbDictionary::Column::Timespec: - out << "Timespec"; + case NdbDictionary::Column::Date: + out << "Date"; break; case NdbDictionary::Column::Blob: out << "Blob(" << col.getInlineSize() << "," << col.getPartSize() @@ -943,6 +950,15 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) out << "Text(" << col.getInlineSize() << "," << col.getPartSize() << ";" << col.getStripeSize() << ";" << csname << ")"; break; + case NdbDictionary::Column::Time: + out << "Time"; + break; + case NdbDictionary::Column::Year: + out << "Year"; + break; + case NdbDictionary::Column::Timestamp: + out << "Timestamp"; + break; case NdbDictionary::Column::Undefined: out << "Undefined"; break; @@ -956,6 +972,10 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) out << " NOT NULL"; else out << " NULL"; + + if (col.getDistributionKey()) + out << " DISTRIBUTION KEY"; + return out; } diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index cf51a30fe0b..e88f76ef513 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -34,7 +34,8 @@ #include <AttributeList.hpp> #include <NdbEventOperation.hpp> #include "NdbEventOperationImpl.hpp" -#include "NdbBlob.hpp" +#include <NdbBlob.hpp> +#include "NdbBlobImpl.hpp" #include <AttributeHeader.hpp> #include <my_sys.h> @@ -47,13 +48,13 @@ * Column */ NdbColumnImpl::NdbColumnImpl() - : NdbDictionary::Column(* this), m_facade(this) + : NdbDictionary::Column(* this), m_attrId(-1), m_facade(this) { init(); } NdbColumnImpl::NdbColumnImpl(NdbDictionary::Column & f) - : NdbDictionary::Column(* this), m_facade(&f) + : NdbDictionary::Column(* this), m_attrId(-1), m_facade(&f) { init(); } @@ -93,8 +94,7 @@ NdbColumnImpl::init(Type t) { // do not use default_charset_info as it may not be initialized yet // use binary collation until NDB tests can handle charsets - CHARSET_INFO* default_cs = &my_charset_latin1_bin; - m_attrId = -1; + CHARSET_INFO* default_cs = &my_charset_bin; m_type = t; switch (m_type) { case Tinyint: @@ -114,7 +114,8 @@ NdbColumnImpl::init(Type t) m_length = 1; m_cs = NULL; break; - case Decimal: + case Olddecimal: + case Olddecimalunsigned: m_precision = 10; m_scale = 0; m_length = 1; @@ -130,7 +131,7 @@ NdbColumnImpl::init(Type t) case Binary: case Varbinary: case Datetime: - case Timespec: + case Date: m_precision = 0; m_scale = 0; m_length = 1; @@ -148,6 +149,14 @@ NdbColumnImpl::init(Type t) m_length = 4; m_cs = default_cs; break; + case Time: + case Year: + case Timestamp: + m_precision = 0; + m_scale = 0; + m_length = 1; + m_cs = NULL; + break; case Undefined: assert(false); break; @@ -276,7 +285,7 @@ void NdbTableImpl::init(){ clearNewProperties(); m_frm.clear(); - m_fragmentType = NdbDictionary::Object::FragAllMedium; + m_fragmentType = NdbDictionary::Object::FragAllSmall; m_logging = true; m_kvalue = 6; m_minLoadFactor = 78; @@ -937,6 +946,12 @@ NdbDictInterface::dictSignal(NdbApiSignal* signal, if(m_waiter.m_state == WAIT_NODE_FAILURE) continue; + if(m_waiter.m_state == WST_WAIT_TIMEOUT) + { + m_error.code = 4008; + DBUG_RETURN(-1); + } + if ( (temporaryMask & m_error.code) != 0 ) { continue; } @@ -1168,15 +1183,19 @@ columnTypeMapping[] = { { DictTabInfo::ExtBigunsigned, NdbDictionary::Column::Bigunsigned }, { DictTabInfo::ExtFloat, NdbDictionary::Column::Float }, { DictTabInfo::ExtDouble, NdbDictionary::Column::Double }, - { DictTabInfo::ExtDecimal, NdbDictionary::Column::Decimal }, + { DictTabInfo::ExtOlddecimal, NdbDictionary::Column::Olddecimal }, + { DictTabInfo::ExtOlddecimalunsigned, NdbDictionary::Column::Olddecimalunsigned }, { DictTabInfo::ExtChar, NdbDictionary::Column::Char }, { DictTabInfo::ExtVarchar, NdbDictionary::Column::Varchar }, { DictTabInfo::ExtBinary, NdbDictionary::Column::Binary }, { DictTabInfo::ExtVarbinary, NdbDictionary::Column::Varbinary }, { DictTabInfo::ExtDatetime, NdbDictionary::Column::Datetime }, - { DictTabInfo::ExtTimespec, NdbDictionary::Column::Timespec }, + { DictTabInfo::ExtDate, NdbDictionary::Column::Date }, { DictTabInfo::ExtBlob, NdbDictionary::Column::Blob }, { DictTabInfo::ExtText, NdbDictionary::Column::Text }, + { DictTabInfo::ExtTime, NdbDictionary::Column::Time }, + { DictTabInfo::ExtYear, NdbDictionary::Column::Year }, + { DictTabInfo::ExtTimestamp, NdbDictionary::Column::Timestamp }, { -1, -1 } }; @@ -1386,7 +1405,7 @@ NdbDictionaryImpl::addBlobTables(NdbTableImpl &t) if (! c.getBlobType() || c.getPartSize() == 0) continue; n--; - char btname[NdbBlob::BlobTableNameSize]; + char btname[NdbBlobImpl::BlobTableNameSize]; NdbBlob::getBlobTableName(btname, &t, &c); // Save BLOB table handle NdbTableImpl * cachedBlobTable = getTable(btname); @@ -1412,15 +1431,14 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) const char * originalInternalName = internalName.c_str(); BaseString externalName = impl.m_externalName; const char * originalExternalName = externalName.c_str(); - NdbTableImpl * oldTab = getTable(originalExternalName); - - if(!oldTab){ + + DBUG_ENTER("NdbDictionaryImpl::alterTable"); + if(!get_local_table_info(originalInternalName, false)){ m_error.code = 709; - return -1; + DBUG_RETURN(-1); } // Alter the table int ret = m_receiver.alterTable(m_ndb, impl); - if(ret == 0){ // Remove cached information and let it be refreshed at next access if (m_localHash.get(originalInternalName) != NULL) { @@ -1434,7 +1452,7 @@ int NdbDictionaryImpl::alterTable(NdbTableImpl &impl) m_globalHash->unlock(); } } - return ret; + DBUG_RETURN(ret); } int @@ -1449,15 +1467,16 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, NdbTableImpl & impl, bool alter) { + DBUG_ENTER("NdbDictInterface::createOrAlterTable"); unsigned i; if((unsigned)impl.getNoOfPrimaryKeys() > NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY){ m_error.code = 4317; - return -1; + DBUG_RETURN(-1); } unsigned sz = impl.m_columns.size(); if (sz > NDB_MAX_ATTRIBUTES_IN_TABLE){ m_error.code = 4318; - return -1; + DBUG_RETURN(-1); } impl.copyNewProperties(); @@ -1492,7 +1511,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, // Check max length of frm data if (impl.m_frm.length() > MAX_FRM_DATA_SIZE){ m_error.code = 1229; - return -1; + DBUG_RETURN(-1); } tmpTab.FrmLen = impl.m_frm.length(); memcpy(tmpTab.FrmData, impl.m_frm.get_data(), impl.m_frm.length()); @@ -1544,12 +1563,12 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, // charset is defined exactly for char types if (col->getCharType() != (col->m_cs != NULL)) { m_error.code = 703; - return -1; + DBUG_RETURN(-1); } // primary key type check if (col->m_pk && ! NdbSqlUtil::usable_in_pk(col->m_type, col->m_cs)) { m_error.code = 743; - return -1; + DBUG_RETURN(-1); } // charset in upper half of precision if (col->getCharType()) { @@ -1572,7 +1591,13 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, NdbApiSignal tSignal(m_reference); tSignal.theReceiversBlockNumber = DBDICT; - if (alter) { + + LinearSectionPtr ptr[3]; + ptr[0].p = (Uint32*)m_buffer.get_data(); + ptr[0].sz = m_buffer.length() / 4; + int ret; + if (alter) + { AlterTableReq * const req = CAST_PTR(AlterTableReq, tSignal.getDataPtrSend()); @@ -1583,8 +1608,10 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, req->tableVersion = impl.m_version;; tSignal.theVerId_signalNumber = GSN_ALTER_TABLE_REQ; tSignal.theLength = AlterTableReq::SignalLength; + ret= alterTable(&tSignal, ptr); } - else { + else + { CreateTableReq * const req = CAST_PTR(CreateTableReq, tSignal.getDataPtrSend()); @@ -1592,28 +1619,24 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, req->senderData = 0; tSignal.theVerId_signalNumber = GSN_CREATE_TABLE_REQ; tSignal.theLength = CreateTableReq::SignalLength; - } - - LinearSectionPtr ptr[3]; - ptr[0].p = (Uint32*)m_buffer.get_data(); - ptr[0].sz = m_buffer.length() / 4; - - int ret = (alter) ? - alterTable(&tSignal, ptr) - : createTable(&tSignal, ptr); - - if (!alter && haveAutoIncrement) { - if (!ndb.setAutoIncrementValue(impl.m_externalName.c_str(), - autoIncrementValue)) { - if (ndb.theError.code == 0) { - m_error.code = 4336; - ndb.theError = m_error; - } else - m_error= ndb.theError; - ret = -1; // errorcode set in initialize_autoincrement + ret= createTable(&tSignal, ptr); + + if (ret) + return ret; + + if (haveAutoIncrement) { + if (!ndb.setAutoIncrementValue(impl.m_externalName.c_str(), + autoIncrementValue)) { + if (ndb.theError.code == 0) { + m_error.code = 4336; + ndb.theError = m_error; + } else + m_error= ndb.theError; + ret = -1; // errorcode set in initialize_autoincrement + } } } - return ret; + DBUG_RETURN(ret); } int @@ -1672,17 +1695,17 @@ NdbDictInterface::alterTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]) int errCodes[noErrCodes] = {AlterTableRef::NotMaster, AlterTableRef::Busy}; - int r = dictSignal(signal,ptr,1, - 1/*use masternode id*/, - 100,WAIT_ALTER_TAB_REQ, - WAITFOR_RESPONSE_TIMEOUT, - errCodes, noErrCodes); - if(m_error.code == AlterTableRef::InvalidTableVersion) { - // Clear caches and try again - return INCOMPATIBLE_VERSION; - } + int r = dictSignal(signal,ptr,1, + 1/*use masternode id*/, + 100,WAIT_ALTER_TAB_REQ, + WAITFOR_RESPONSE_TIMEOUT, + errCodes, noErrCodes); + if(m_error.code == AlterTableRef::InvalidTableVersion) { + // Clear caches and try again + return INCOMPATIBLE_VERSION; + } - return r; + return r; } void @@ -1790,7 +1813,7 @@ NdbDictionaryImpl::dropBlobTables(NdbTableImpl & t) NdbColumnImpl & c = *t.m_columns[i]; if (! c.getBlobType() || c.getPartSize() == 0) continue; - char btname[NdbBlob::BlobTableNameSize]; + char btname[NdbBlobImpl::BlobTableNameSize]; NdbBlob::getBlobTableName(btname, &t, &c); if (dropTable(btname) != 0) { if (m_error.code != 709){ @@ -2076,8 +2099,8 @@ int NdbDictInterface::createIndex(NdbApiSignal* signal, LinearSectionPtr ptr[3]) { - const int noErrCodes = 1; - int errCodes[noErrCodes] = {CreateIndxRef::Busy}; + const int noErrCodes = 2; + int errCodes[noErrCodes] = {CreateIndxRef::Busy, CreateIndxRef::NotMaster}; return dictSignal(signal,ptr,2, 1 /*use masternode id*/, 100, @@ -2101,6 +2124,8 @@ NdbDictInterface::execCREATE_INDX_REF(NdbApiSignal * signal, { const CreateIndxRef* const ref = CAST_CONSTPTR(CreateIndxRef, signal->getDataPtr()); m_error.code = ref->getErrorCode(); + if(m_error.code == ref->NotMaster) + m_masterNodeId= ref->masterNodeId; m_waiter.signal(NO_WAIT); } @@ -2197,8 +2222,8 @@ NdbDictInterface::dropIndex(const NdbIndexImpl & impl, int NdbDictInterface::dropIndex(NdbApiSignal* signal, LinearSectionPtr ptr[3]) { - const int noErrCodes = 1; - int errCodes[noErrCodes] = {DropIndxRef::Busy}; + const int noErrCodes = 2; + int errCodes[noErrCodes] = {DropIndxRef::Busy, DropIndxRef::NotMaster}; int r = dictSignal(signal,NULL,0, 1/*Use masternode id*/, 100, @@ -2225,6 +2250,8 @@ NdbDictInterface::execDROP_INDX_REF(NdbApiSignal * signal, { const DropIndxRef* const ref = CAST_CONSTPTR(DropIndxRef, signal->getDataPtr()); m_error.code = ref->getErrorCode(); + if(m_error.code == ref->NotMaster) + m_masterNodeId= ref->masterNodeId; m_waiter.signal(NO_WAIT); } diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/ndb/src/ndbapi/NdbDictionaryImpl.hpp index 12f0946ab67..602a2d6b6ca 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -28,7 +28,7 @@ #include <Bitmask.hpp> #include <AttributeList.hpp> #include <Ndb.hpp> -#include "NdbImpl.hpp" +#include "NdbWaiter.hpp" #include "DictCache.hpp" class NdbDictObjectImpl { @@ -321,7 +321,7 @@ private: friend class Ndb; static void execSignal(void* dictImpl, class NdbApiSignal* signal, - class LinearSectionPtr ptr[3]); + struct LinearSectionPtr ptr[3]); static void execNodeStatus(void* dictImpl, Uint32, bool alive, bool nfCompleted); @@ -637,11 +637,9 @@ NdbDictionaryImpl::get_local_table_info(const char * internalTableName, return 0; } } - if (do_add_blob_tables && - info->m_table_impl->m_noOfBlobs && - addBlobTables(*(info->m_table_impl))) { - return 0; - } + if (do_add_blob_tables && info->m_table_impl->m_noOfBlobs) + addBlobTables(*(info->m_table_impl)); + return info; // autoincrement already initialized } diff --git a/ndb/src/ndbapi/NdbEventOperation.cpp b/ndb/src/ndbapi/NdbEventOperation.cpp index 506a6c8d86d..d209293f8b0 100644 --- a/ndb/src/ndbapi/NdbEventOperation.cpp +++ b/ndb/src/ndbapi/NdbEventOperation.cpp @@ -121,5 +121,5 @@ NdbEventOperation::wait(void *p, int aMillisecondNumber) } NdbEventOperation::NdbEventOperation(NdbEventOperationImpl& impl) - : m_impl(impl) {}; + : m_impl(impl) {} diff --git a/ndb/src/ndbapi/NdbImpl.hpp b/ndb/src/ndbapi/NdbImpl.hpp index 1fb1969b589..00a8ef19f3a 100644 --- a/ndb/src/ndbapi/NdbImpl.hpp +++ b/ndb/src/ndbapi/NdbImpl.hpp @@ -17,7 +17,19 @@ #ifndef NDB_IMPL_HPP #define NDB_IMPL_HPP -#include <Vector.hpp> +#include <ndb_global.h> +#include <Ndb.hpp> +#include <NdbOut.hpp> +#include <NdbError.hpp> +#include <NdbCondition.h> +#include <NdbReceiver.hpp> +#include <NdbOperation.hpp> +#include <kernel/ndb_limits.h> + +#include <NdbTick.h> + +#include "ndb_cluster_connection_impl.hpp" +#include "NdbDictionaryImpl.hpp" #include "ObjectMap.hpp" /** @@ -25,19 +37,29 @@ */ class NdbImpl { public: - Vector<class NdbTableImpl *> m_invalidTables; + NdbImpl(Ndb_cluster_connection *, Ndb&); + ~NdbImpl(); - void checkErrorCode(Uint32 i); - void checkInvalidTable(class NdbDictionaryImpl * dict); -}; + Ndb_cluster_connection_impl &m_ndb_cluster_connection; -#include <Ndb.hpp> -#include <NdbError.hpp> -#include <NdbCondition.h> -#include <NdbReceiver.hpp> -#include <NdbOperation.hpp> + NdbDictionaryImpl m_dictionary; -#include <NdbTick.h> + // Ensure good distribution of connects + Uint32 theCurrentConnectIndex; + Ndb_cluster_connection_node_iter m_node_iter; + + NdbObjectIdMap theNdbObjectIdMap; + + Uint32 theNoOfDBnodes; // The number of DB nodes + Uint8 theDBnodes[MAX_NDB_NODES]; // The node number of the DB nodes + + // 1 indicates to release all connections to node + Uint32 the_release_ind[MAX_NDB_NODES]; + + NdbWaiter theWaiter; + + int m_optimized_node_selection; +}; #ifdef VM_TRACE #define TRACE_DEBUG(x) ndbout << x << endl; @@ -57,7 +79,7 @@ public: inline void * Ndb::int2void(Uint32 val){ - return theNdbObjectIdMap->getObject(val); + return theImpl->theNdbObjectIdMap.getObject(val); } inline @@ -104,26 +126,6 @@ Ndb::checkInitState() Uint32 convertEndian(Uint32 Data); -enum WaitSignalType { - NO_WAIT = 0, - WAIT_NODE_FAILURE = 1, // Node failure during wait - WAIT_TIMEOUT = 2, // Timeout during wait - - WAIT_TC_SEIZE = 3, - WAIT_TC_RELEASE = 4, - WAIT_NDB_TAMPER = 5, - WAIT_SCAN = 6, - - // DICT stuff - WAIT_GET_TAB_INFO_REQ = 11, - WAIT_CREATE_TAB_REQ = 12, - WAIT_DROP_TAB_REQ = 13, - WAIT_ALTER_TAB_REQ = 14, - WAIT_CREATE_INDX_REQ = 15, - WAIT_DROP_INDX_REQ = 16, - WAIT_LIST_TABLES_CONF = 17 -}; - enum LockMode { Read, Update, @@ -131,44 +133,4 @@ enum LockMode { Delete }; -#include <NdbOut.hpp> - -inline -void -NdbWaiter::wait(int waitTime) -{ - const bool forever = (waitTime == -1); - const NDB_TICKS maxTime = NdbTick_CurrentMillisecond() + waitTime; - while (1) { - if (m_state == NO_WAIT || m_state == WAIT_NODE_FAILURE) - break; - if (forever) { - NdbCondition_Wait(m_condition, (NdbMutex*)m_mutex); - } else { - if (waitTime <= 0) { - m_state = WAIT_TIMEOUT; - break; - } - NdbCondition_WaitTimeout(m_condition, (NdbMutex*)m_mutex, waitTime); - waitTime = maxTime - NdbTick_CurrentMillisecond(); - } - } -} - -inline -void -NdbWaiter::nodeFail(Uint32 aNodeId){ - if (m_state != NO_WAIT && m_node == aNodeId){ - m_state = WAIT_NODE_FAILURE; - NdbCondition_Signal(m_condition); - } -} - -inline -void -NdbWaiter::signal(Uint32 state){ - m_state = state; - NdbCondition_Signal(m_condition); -} - #endif diff --git a/ndb/src/ndbapi/NdbIndexOperation.cpp b/ndb/src/ndbapi/NdbIndexOperation.cpp index 9abde639914..23af646c4c7 100644 --- a/ndb/src/ndbapi/NdbIndexOperation.cpp +++ b/ndb/src/ndbapi/NdbIndexOperation.cpp @@ -71,6 +71,7 @@ NdbIndexOperation::indxInit(const NdbIndexImpl * anIndex, return -1; } m_theIndex = anIndex; + m_thePrimaryTable = aTable; m_accessTable = anIndex->m_table; m_theIndexLen = 0; m_theNoOfIndexDefined = 0; @@ -102,6 +103,12 @@ int NdbIndexOperation::readTuple(NdbOperation::LockMode lm) }; } +int NdbIndexOperation::insertTuple() +{ + setErrorCode(4200); + return -1; +} + int NdbIndexOperation::readTuple() { // First check that index is unique @@ -265,7 +272,7 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo, CHARSET_INFO* cs = tAttrInfo->m_cs; if (cs != 0) { // current limitation: strxfrm does not increase length - assert(cs->strxfrm_multiply == 1); + assert(cs->strxfrm_multiply <= 1); unsigned n = (*cs->coll->strnxfrm)(cs, (uchar*)xfrmData, sizeof(xfrmData), @@ -341,12 +348,11 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo, theDistrGroupIndicator = 1; }//if /************************************************************************** - * If the operation is an insert request and the attribute is stored then + * If the operation is a write request and the attribute is stored then * we also set the value in the stored part through putting the * information in the INDXATTRINFO signals. *************************************************************************/ - if ((tOpType == InsertRequest) || - (tOpType == WriteRequest)) { + if ((tOpType == WriteRequest)) { if (!tAttrInfo->m_indexOnly){ // invalid data can crash kernel if (cs != NULL && @@ -357,7 +363,13 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo, goto equal_error4; Uint32 ahValue; Uint32 sz = totalSizeInWords; - AttributeHeader::init(&ahValue, tAttrId, sz); + /* + * XXX should be linked in metadata but cannot now because + * things can be defined in arbitrary order + */ + const NdbColumnImpl* primaryCol = m_thePrimaryTable->getColumn(tAttrInfo->m_name.c_str()); + assert(primaryCol != NULL); + AttributeHeader::init(&ahValue, primaryCol->m_attrId, sz); insertATTRINFO( ahValue ); insertATTRINFOloop((Uint32*)aValueToWrite, sizeInWords); if (bitsInLastWord != 0) { @@ -369,7 +381,6 @@ int NdbIndexOperation::equal_impl(const NdbColumnImpl* tAttrInfo, }//if }//if }//if - /************************************************************************** * Store the Key information in the TCINDXREQ and INDXKEYINFO signals. *************************************************************************/ @@ -734,13 +745,10 @@ NdbIndexOperation::receiveTCINDXREF( NdbApiSignal* aSignal) }//if theStatus = Finished; - + theNdbCon->theReturnStatus = NdbConnection::ReturnFailure; Uint32 errorCode = tcIndxRef->errorCode; theError.code = errorCode; theNdbCon->setOperationErrorCodeAbort(errorCode); return theNdbCon->OpCompleteFailure(theNdbCon->m_abortOption); }//NdbIndexOperation::receiveTCINDXREF() - - - diff --git a/ndb/src/ndbapi/NdbOperation.cpp b/ndb/src/ndbapi/NdbOperation.cpp index b0b95d0ff43..88d8a000d50 100644 --- a/ndb/src/ndbapi/NdbOperation.cpp +++ b/ndb/src/ndbapi/NdbOperation.cpp @@ -78,7 +78,8 @@ NdbOperation::NdbOperation(Ndb* aNdb) : m_tcReqGSN(GSN_TCKEYREQ), m_keyInfoGSN(GSN_KEYINFO), m_attrInfoGSN(GSN_ATTRINFO), - theBlobList(NULL) + theBlobList(NULL), + m_abortOption(-1) { theReceiver.init(NdbReceiver::NDB_OPERATION, this); theError.code = 0; @@ -167,6 +168,7 @@ NdbOperation::init(const NdbTableImpl* tab, NdbConnection* myConnection){ theTotalNrOfKeyWordInSignal = 8; theMagicNumber = 0xABCDEF01; theBlobList = NULL; + m_abortOption = -1; tSignal = theNdb->getSignal(); if (tSignal == NULL) diff --git a/ndb/src/ndbapi/NdbOperationDefine.cpp b/ndb/src/ndbapi/NdbOperationDefine.cpp index 35abb15b00d..c4aaffb3119 100644 --- a/ndb/src/ndbapi/NdbOperationDefine.cpp +++ b/ndb/src/ndbapi/NdbOperationDefine.cpp @@ -528,7 +528,9 @@ NdbOperation::setValue( const NdbColumnImpl* tAttrInfo, CHARSET_INFO* cs = tAttrInfo->m_cs; // invalid data can crash kernel if (cs != NULL && - (*cs->cset->well_formed_len)(cs, + // fast fix bug#7340 + tAttrInfo->m_type != NdbDictionary::Column::Text && + (*cs->cset->well_formed_len)(cs, aValue, aValue + sizeInBytes, sizeInBytes) != sizeInBytes) { diff --git a/ndb/src/ndbapi/NdbOperationExec.cpp b/ndb/src/ndbapi/NdbOperationExec.cpp index f1338ae01e4..afa3609e11c 100644 --- a/ndb/src/ndbapi/NdbOperationExec.cpp +++ b/ndb/src/ndbapi/NdbOperationExec.cpp @@ -191,14 +191,15 @@ NdbOperation::prepareSend(Uint32 aTC_ConnectPtr, Uint64 aTransId) Uint8 tDirtyIndicator = theDirtyIndicator; OperationType tOperationType = theOperationType; Uint32 tTupKeyLen = theTupKeyLen; - Uint8 abortOption = theNdbCon->m_abortOption; + Uint8 abortOption = + m_abortOption != -1 ? m_abortOption : theNdbCon->m_abortOption; tcKeyReq->setDirtyFlag(tReqInfo, tDirtyIndicator); tcKeyReq->setOperationType(tReqInfo, tOperationType); tcKeyReq->setKeyLength(tReqInfo, tTupKeyLen); // A simple read is always ignore error - abortOption = tSimpleIndicator ? IgnoreError : abortOption; + abortOption = tSimpleIndicator ? AO_IgnoreError : abortOption; tcKeyReq->setAbortOption(tReqInfo, abortOption); Uint8 tDistrKeyIndicator = theDistrKeyIndicator; @@ -541,17 +542,20 @@ NdbOperation::receiveTCKEYREF( NdbApiSignal* aSignal) return -1; }//if - AbortOption ao = (AbortOption)theNdbCon->m_abortOption; + AbortOption ao = (AbortOption) + (m_abortOption != -1 ? m_abortOption : theNdbCon->m_abortOption); theReceiver.m_received_result_length = ~0; theStatus = Finished; - theNdbCon->theReturnStatus = NdbConnection::ReturnFailure; + // blobs want this + if (m_abortOption != AO_IgnoreError) + theNdbCon->theReturnStatus = NdbConnection::ReturnFailure; theError.code = aSignal->readData(4); - theNdbCon->setOperationErrorCodeAbort(aSignal->readData(4)); + theNdbCon->setOperationErrorCodeAbort(aSignal->readData(4), m_abortOption); if(theOperationType != ReadRequest || !theSimpleIndicator) // not simple read - return theNdbCon->OpCompleteFailure(ao); + return theNdbCon->OpCompleteFailure(ao, m_abortOption != AO_IgnoreError); /** * If TCKEYCONF has arrived diff --git a/ndb/src/ndbapi/NdbOperationInt.cpp b/ndb/src/ndbapi/NdbOperationInt.cpp index ee7b8132cd1..ace90e35ca4 100644 --- a/ndb/src/ndbapi/NdbOperationInt.cpp +++ b/ndb/src/ndbapi/NdbOperationInt.cpp @@ -15,21 +15,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/************************************************************************************************ -Name: NdbOperationInt.C -Include: -Link: -Author: UABRONM Mikael Ronström UAB/M/MT -Date: 991029 -Version: 0.1 -Description: Interpreted operations in NDB API -Documentation: -Adjust: 991029 UABRONM First version. -************************************************************************************************/ -#include "NdbOperation.hpp" +#include <ndb_global.h> +#include <NdbOperation.hpp> #include "NdbApiSignal.hpp" -#include "NdbConnection.hpp" -#include "Ndb.hpp" +#include <NdbConnection.hpp> +#include <Ndb.hpp> #include "NdbRecAttr.hpp" #include "NdbUtil.hpp" #include "Interpreter.hpp" diff --git a/ndb/src/ndbapi/NdbOperationSearch.cpp b/ndb/src/ndbapi/NdbOperationSearch.cpp index 69b4e803acd..28a70abcb9b 100644 --- a/ndb/src/ndbapi/NdbOperationSearch.cpp +++ b/ndb/src/ndbapi/NdbOperationSearch.cpp @@ -142,7 +142,7 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo, CHARSET_INFO* cs = tAttrInfo->m_cs; if (cs != 0) { // current limitation: strxfrm does not increase length - assert(cs->strxfrm_multiply == 1); + assert(cs->strxfrm_multiply <= 1); unsigned n = (*cs->coll->strnxfrm)(cs, (uchar*)xfrmData, sizeof(xfrmData), diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index bcd91292fcd..db83e9c5fcf 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -156,10 +156,12 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) return out; } - if (r.arraySize() > 1) + const NdbDictionary::Column* c = r.getColumn(); + uint length = c->getLength(); + if (length > 1) out << "["; - for (Uint32 j = 0; j < r.arraySize(); j++) + for (Uint32 j = 0; j < length; j++) { if (j > 0) out << " "; @@ -192,14 +194,14 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) break; case NdbDictionary::Column::Char: out.print("%.*s", r.arraySize(), r.aRef()); - j = r.arraySize(); + j = length; break; case NdbDictionary::Column::Varchar: { short len = ntohs(r.u_short_value()); out.print("%.*s", len, r.aRef()+2); } - j = r.arraySize(); + j = length; break; case NdbDictionary::Column::Float: out << r.float_value(); @@ -207,6 +209,98 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) case NdbDictionary::Column::Double: out << r.double_value(); break; + case NdbDictionary::Column::Olddecimal: + { + short len = 1 + c->getPrecision() + (c->getScale() > 0); + out.print("%.*s", len, r.aRef()); + } + break; + case NdbDictionary::Column::Olddecimalunsigned: + { + short len = 0 + c->getPrecision() + (c->getScale() > 0); + out.print("%.*s", len, r.aRef()); + } + break; + // for dates cut-and-paste from field.cc + case NdbDictionary::Column::Datetime: + { + ulonglong tmp=r.u_64_value(); + long part1,part2,part3; + part1=(long) (tmp/LL(1000000)); + part2=(long) (tmp - (ulonglong) part1*LL(1000000)); + char buf[40]; + char* pos=(char*) buf+19; + *pos--=0; + *pos--= (char) ('0'+(char) (part2%10)); part2/=10; + *pos--= (char) ('0'+(char) (part2%10)); part3= (int) (part2 / 10); + *pos--= ':'; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= ':'; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= (char) ('0'+(char) part3); + *pos--= '/'; + *pos--= (char) ('0'+(char) (part1%10)); part1/=10; + *pos--= (char) ('0'+(char) (part1%10)); part1/=10; + *pos--= '-'; + *pos--= (char) ('0'+(char) (part1%10)); part1/=10; + *pos--= (char) ('0'+(char) (part1%10)); part3= (int) (part1/10); + *pos--= '-'; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos--= (char) ('0'+(char) (part3%10)); part3/=10; + *pos=(char) ('0'+(char) part3); + out << buf; + } + break; + case NdbDictionary::Column::Date: + { + uint32 tmp=(uint32) uint3korr(r.aRef()); + int part; + char buf[40]; + char *pos=(char*) buf+10; + *pos--=0; + part=(int) (tmp & 31); + *pos--= (char) ('0'+part%10); + *pos--= (char) ('0'+part/10); + *pos--= '-'; + part=(int) (tmp >> 5 & 15); + *pos--= (char) ('0'+part%10); + *pos--= (char) ('0'+part/10); + *pos--= '-'; + part=(int) (tmp >> 9); + *pos--= (char) ('0'+part%10); part/=10; + *pos--= (char) ('0'+part%10); part/=10; + *pos--= (char) ('0'+part%10); part/=10; + *pos= (char) ('0'+part); + out << buf; + } + break; + case NdbDictionary::Column::Time: + { + long tmp=(long) sint3korr(r.aRef()); + int hour=(uint) (tmp/10000); + int minute=(uint) (tmp/100 % 100); + int second=(uint) (tmp % 100); + char buf[40]; + sprintf(buf, "%02d:%02d:%02d", hour, minute, second); + out << buf; + } + break; + case NdbDictionary::Column::Year: + { + uint year = 1900 + r.u_char_value(); + char buf[40]; + sprintf(buf, "%04d", year); + out << buf; + } + break; + case NdbDictionary::Column::Timestamp: + { + time_t time = r.u_32_value(); + out << (uint)time; + } + break; case NdbDictionary::Column::Blob: { const NdbBlob::Head* h = (const NdbBlob::Head*)r.aRef(); @@ -215,7 +309,7 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) unsigned n = r.arraySize() - sizeof(*h); for (unsigned k = 0; k < n && k < h->length; k++) out.print("%02X", (int)p[k]); - j = r.arraySize(); + j = length; } break; case NdbDictionary::Column::Text: @@ -226,22 +320,54 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) unsigned n = r.arraySize() - sizeof(*h); for (unsigned k = 0; k < n && k < h->length; k++) out.print("%c", (int)p[k]); - j = r.arraySize(); + j = length; } break; default: /* no print functions for the rest, just print type */ out << (int) r.getType(); - j = r.arraySize(); + j = length; if (j > 1) out << " " << j << " times"; break; } } - if (r.arraySize() > 1) + if (length > 1) { out << "]"; } return out; } + +Int64 +NdbRecAttr::int64_value() const +{ + Int64 val; + memcpy(&val,theRef,8); + return val; +} + +Uint64 +NdbRecAttr::u_64_value() const +{ + Uint64 val; + memcpy(&val,theRef,8); + return val; +} + +float +NdbRecAttr::float_value() const +{ + float val; + memcpy(&val,theRef,sizeof(val)); + return val; +} + +double +NdbRecAttr::double_value() const +{ + double val; + memcpy(&val,theRef,sizeof(val)); + return val; +} diff --git a/ndb/src/ndbapi/NdbReceiver.cpp b/ndb/src/ndbapi/NdbReceiver.cpp index 14f8d4b8440..cad247512b2 100644 --- a/ndb/src/ndbapi/NdbReceiver.cpp +++ b/ndb/src/ndbapi/NdbReceiver.cpp @@ -40,7 +40,7 @@ NdbReceiver::~NdbReceiver() { DBUG_ENTER("NdbReceiver::~NdbReceiver"); if (m_id != NdbObjectIdMap::InvalidId) { - m_ndb->theNdbObjectIdMap->unmap(m_id, this); + m_ndb->theImpl->theNdbObjectIdMap.unmap(m_id, this); } delete[] m_rows; DBUG_VOID_RETURN; @@ -54,7 +54,7 @@ NdbReceiver::init(ReceiverType type, void* owner) m_owner = owner; if (m_id == NdbObjectIdMap::InvalidId) { if (m_ndb) - m_id = m_ndb->theNdbObjectIdMap->map(this); + m_id = m_ndb->theImpl->theNdbObjectIdMap.map(this); } theFirstRecAttr = NULL; diff --git a/ndb/src/ndbapi/NdbResultSet.cpp b/ndb/src/ndbapi/NdbResultSet.cpp index f270584d227..d9d71464026 100644 --- a/ndb/src/ndbapi/NdbResultSet.cpp +++ b/ndb/src/ndbapi/NdbResultSet.cpp @@ -44,10 +44,10 @@ void NdbResultSet::init() { } -int NdbResultSet::nextResult(bool fetchAllowed) +int NdbResultSet::nextResult(bool fetchAllowed, bool forceSend) { int res; - if ((res = m_operation->nextResult(fetchAllowed)) == 0) { + if ((res = m_operation->nextResult(fetchAllowed, forceSend)) == 0) { // handle blobs NdbBlob* tBlob = m_operation->theBlobList; while (tBlob != 0) { @@ -67,9 +67,9 @@ int NdbResultSet::nextResult(bool fetchAllowed) return res; } -void NdbResultSet::close() +void NdbResultSet::close(bool forceSend) { - m_operation->closeScan(); + m_operation->closeScan(forceSend); } NdbOperation* @@ -98,6 +98,6 @@ NdbResultSet::deleteTuple(NdbConnection * takeOverTrans){ } int -NdbResultSet::restart(){ - return m_operation->restart(); +NdbResultSet::restart(bool forceSend){ + return m_operation->restart(forceSend); } diff --git a/ndb/src/ndbapi/NdbScanFilter.cpp b/ndb/src/ndbapi/NdbScanFilter.cpp index 38b1c70c047..0c851427ba5 100644 --- a/ndb/src/ndbapi/NdbScanFilter.cpp +++ b/ndb/src/ndbapi/NdbScanFilter.cpp @@ -397,7 +397,7 @@ NdbScanFilterImpl::cond_col_const(Interpreter::BinaryCondition op, (m_operation->* branch)(4, 5, m_current.m_ownLabel); return 0; -}; +} int NdbScanFilter::eq(int AttrId, Uint32 value){ @@ -478,7 +478,7 @@ NdbScanFilterImpl::cond_col(Interpreter::UnaryCondition op, Uint32 AttrId){ Branch1 branch = table2[op].m_branches[m_current.m_group]; (m_operation->* branch)(AttrId, m_current.m_ownLabel); return 0; -}; +} int NdbScanFilter::isnull(int AttrId){ diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index fd63ce96f25..670a18f72a0 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -35,6 +35,8 @@ #include <signaldata/AttrInfo.hpp> #include <signaldata/TcKeyReq.hpp> +#define DEBUG_NEXT_RESULT 0 + NdbScanOperation::NdbScanOperation(Ndb* aNdb) : NdbOperation(aNdb), m_resultSet(0), @@ -239,17 +241,17 @@ NdbScanOperation::fix_receivers(Uint32 parallel){ if(parallel > m_allocated_receivers){ const Uint32 sz = parallel * (4*sizeof(char*)+sizeof(Uint32)); - Uint32 * tmp = new Uint32[(sz+3)/4]; + Uint64 * tmp = new Uint64[(sz+7)/8]; // Save old receivers - memcpy(tmp+parallel, m_receivers, m_allocated_receivers*sizeof(char*)); + memcpy(tmp, m_receivers, m_allocated_receivers*sizeof(char*)); delete[] m_array; - m_array = tmp; + m_array = (Uint32*)tmp; - m_prepared_receivers = tmp; - m_receivers = (NdbReceiver**)(tmp + parallel); + m_receivers = (NdbReceiver**)tmp; m_api_receivers = m_receivers + parallel; m_conf_receivers = m_api_receivers + parallel; m_sent_receivers = m_conf_receivers + parallel; + m_prepared_receivers = (Uint32*)(m_sent_receivers + parallel); // Only get/init "new" receivers NdbReceiver* tScanRec; @@ -275,6 +277,9 @@ NdbScanOperation::fix_receivers(Uint32 parallel){ void NdbScanOperation::receiver_delivered(NdbReceiver* tRec){ if(theError.code == 0){ + if(DEBUG_NEXT_RESULT) + ndbout_c("receiver_delivered"); + Uint32 idx = tRec->m_list_index; Uint32 last = m_sent_receivers_count - 1; if(idx != last){ @@ -298,6 +303,9 @@ NdbScanOperation::receiver_delivered(NdbReceiver* tRec){ void NdbScanOperation::receiver_completed(NdbReceiver* tRec){ if(theError.code == 0){ + if(DEBUG_NEXT_RESULT) + ndbout_c("receiver_completed"); + Uint32 idx = tRec->m_list_index; Uint32 last = m_sent_receivers_count - 1; if(idx != last){ @@ -445,12 +453,12 @@ NdbScanOperation::executeCursor(int nodeId){ return -1; } -#define DEBUG_NEXT_RESULT 0 -int NdbScanOperation::nextResult(bool fetchAllowed) +int NdbScanOperation::nextResult(bool fetchAllowed, bool forceSend) { if(m_ordered) - return ((NdbIndexScanOperation*)this)->next_result_ordered(fetchAllowed); + return ((NdbIndexScanOperation*)this)->next_result_ordered(fetchAllowed, + forceSend); /** * Check current receiver @@ -486,8 +494,12 @@ int NdbScanOperation::nextResult(bool fetchAllowed) Uint32 nodeId = theNdbCon->theDBnode; TransporterFacade* tp = TransporterFacade::instance(); Guard guard(tp->theMutexPtr); + if(theError.code) + return -1; + Uint32 seq = theNdbCon->theNodeSequence; - if(seq == tp->getNodeSequence(nodeId) && send_next_scan(idx, false) == 0){ + if(seq == tp->getNodeSequence(nodeId) && send_next_scan(idx, false, + forceSend) == 0){ idx = m_current_api_receiver; last = m_api_receivers_count; @@ -516,8 +528,8 @@ int NdbScanOperation::nextResult(bool fetchAllowed) /** * No completed... */ - theNdb->theWaiter.m_node = nodeId; - theNdb->theWaiter.m_state = WAIT_SCAN; + theNdb->theImpl->theWaiter.m_node = nodeId; + theNdb->theImpl->theWaiter.m_state = WAIT_SCAN; int return_code = theNdb->receiveResponse(WAITFOR_SCAN_TIMEOUT); if (return_code == 0 && seq == tp->getNodeSequence(nodeId)) { continue; @@ -578,8 +590,9 @@ int NdbScanOperation::nextResult(bool fetchAllowed) } int -NdbScanOperation::send_next_scan(Uint32 cnt, bool stopScanFlag){ - if(cnt > 0 || stopScanFlag){ +NdbScanOperation::send_next_scan(Uint32 cnt, bool stopScanFlag, + bool forceSend){ + if(cnt > 0){ NdbApiSignal tSignal(theNdb->theMyRef); tSignal.setSignal(GSN_SCAN_NEXTREQ); @@ -595,38 +608,57 @@ NdbScanOperation::send_next_scan(Uint32 cnt, bool stopScanFlag){ */ Uint32 last = m_sent_receivers_count; Uint32 * prep_array = (cnt > 21 ? m_prepared_receivers : theData + 4); + Uint32 sent = 0; for(Uint32 i = 0; i<cnt; i++){ NdbReceiver * tRec = m_api_receivers[i]; - m_sent_receivers[last+i] = tRec; - tRec->m_list_index = last+i; - prep_array[i] = tRec->m_tcPtrI; - tRec->prepareSend(); + if((prep_array[sent] = tRec->m_tcPtrI) != RNIL) + { + m_sent_receivers[last+sent] = tRec; + tRec->m_list_index = last+sent; + tRec->prepareSend(); + sent++; + } } - memcpy(&m_api_receivers[0], &m_api_receivers[cnt], cnt * sizeof(char*)); + memmove(m_api_receivers, m_api_receivers+cnt, + (theParallelism-cnt) * sizeof(char*)); - Uint32 nodeId = theNdbCon->theDBnode; - TransporterFacade * tp = TransporterFacade::instance(); - int ret; - if(cnt > 21){ - tSignal.setLength(4); - LinearSectionPtr ptr[3]; - ptr[0].p = prep_array; - ptr[0].sz = cnt; - ret = tp->sendFragmentedSignal(&tSignal, nodeId, ptr, 1); - } else { - tSignal.setLength(4+cnt); - ret = tp->sendSignal(&tSignal, nodeId); + int ret = 0; + if(sent) + { + Uint32 nodeId = theNdbCon->theDBnode; + TransporterFacade * tp = TransporterFacade::instance(); + if(cnt > 21){ + tSignal.setLength(4); + LinearSectionPtr ptr[3]; + ptr[0].p = prep_array; + ptr[0].sz = sent; + ret = tp->sendSignal(&tSignal, nodeId, ptr, 1); + } else { + tSignal.setLength(4+sent); + ret = tp->sendSignal(&tSignal, nodeId); + } } + + if (!ret) checkForceSend(forceSend); - m_sent_receivers_count = last + cnt + stopScanFlag; + m_sent_receivers_count = last + sent; m_api_receivers_count -= cnt; m_current_api_receiver = 0; - + return ret; } return 0; } +void NdbScanOperation::checkForceSend(bool forceSend) +{ + if (forceSend) { + TransporterFacade::instance()->forceSend(theNdb->theNdbBlockNumber); + } else { + TransporterFacade::instance()->checkForceSend(theNdb->theNdbBlockNumber); + }//if +} + int NdbScanOperation::prepareSend(Uint32 TC_ConnectPtr, Uint64 TransactionId) { @@ -642,7 +674,7 @@ NdbScanOperation::doSend(int ProcessorId) return 0; } -void NdbScanOperation::closeScan() +void NdbScanOperation::closeScan(bool forceSend) { if(m_transConnection){ if(DEBUG_NEXT_RESULT) @@ -657,7 +689,7 @@ void NdbScanOperation::closeScan() TransporterFacade* tp = TransporterFacade::instance(); Guard guard(tp->theMutexPtr); - close_impl(tp); + close_impl(tp, forceSend); } while(0); @@ -670,7 +702,6 @@ void NdbScanOperation::closeScan() void NdbScanOperation::execCLOSE_SCAN_REP(){ - m_api_receivers_count = 0; m_conf_receivers_count = 0; m_sent_receivers_count = 0; } @@ -803,7 +834,7 @@ NdbScanOperation::doSendScan(int aProcessorId) LinearSectionPtr ptr[3]; ptr[0].p = m_prepared_receivers; ptr[0].sz = theParallelism; - if (tp->sendFragmentedSignal(tSignal, aProcessorId, ptr, 1) == -1) { + if (tp->sendSignal(tSignal, aProcessorId, ptr, 1) == -1) { setErrorCode(4002); return -1; } @@ -850,6 +881,14 @@ NdbScanOperation::doSendScan(int aProcessorId) tSignal = tSignal->next(); } theStatus = WaitResponse; + + m_sent_receivers_count = theParallelism; + if(m_ordered) + { + m_current_api_receiver = theParallelism; + m_api_receivers_count = theParallelism; + } + return tSignalCount; }//NdbOperation::doSendScan() @@ -1083,7 +1122,7 @@ NdbIndexScanOperation::setBound(const NdbColumnImpl* tAttrInfo, Uint32 xfrmData[2000]; if (cs != NULL && aValue != NULL) { // current limitation: strxfrm does not increase length - assert(cs->strxfrm_multiply == 1); + assert(cs->strxfrm_multiply <= 1); unsigned n = (*cs->coll->strnxfrm)(cs, (uchar*)xfrmData, sizeof(xfrmData), @@ -1285,7 +1324,8 @@ NdbIndexScanOperation::compare(Uint32 skip, Uint32 cols, } int -NdbIndexScanOperation::next_result_ordered(bool fetchAllowed){ +NdbIndexScanOperation::next_result_ordered(bool fetchAllowed, + bool forceSend){ Uint32 u_idx = 0, u_last = 0; Uint32 s_idx = m_current_api_receiver; // first sorted @@ -1309,19 +1349,29 @@ NdbIndexScanOperation::next_result_ordered(bool fetchAllowed){ if(DEBUG_NEXT_RESULT) ndbout_c("performing fetch..."); TransporterFacade* tp = TransporterFacade::instance(); Guard guard(tp->theMutexPtr); + if(theError.code) + return -1; Uint32 seq = theNdbCon->theNodeSequence; Uint32 nodeId = theNdbCon->theDBnode; - if(seq == tp->getNodeSequence(nodeId) && !send_next_scan_ordered(s_idx)){ + if(seq == tp->getNodeSequence(nodeId) && + !send_next_scan_ordered(s_idx, forceSend)){ Uint32 tmp = m_sent_receivers_count; s_idx = m_current_api_receiver; while(m_sent_receivers_count > 0 && !theError.code){ - theNdb->theWaiter.m_node = nodeId; - theNdb->theWaiter.m_state = WAIT_SCAN; + theNdb->theImpl->theWaiter.m_node = nodeId; + theNdb->theImpl->theWaiter.m_state = WAIT_SCAN; int return_code = theNdb->receiveResponse(WAITFOR_SCAN_TIMEOUT); if (return_code == 0 && seq == tp->getNodeSequence(nodeId)) { continue; } if(DEBUG_NEXT_RESULT) ndbout_c("return -1"); + setErrorCode(4028); + return -1; + } + + if(theError.code){ + setErrorCode(theError.code); + if(DEBUG_NEXT_RESULT) ndbout_c("return -1"); return -1; } @@ -1331,11 +1381,9 @@ NdbIndexScanOperation::next_result_ordered(bool fetchAllowed){ memcpy(arr, m_conf_receivers, u_last * sizeof(char*)); if(DEBUG_NEXT_RESULT) ndbout_c("sent: %d recv: %d", tmp, u_last); - if(theError.code){ - setErrorCode(theError.code); - if(DEBUG_NEXT_RESULT) ndbout_c("return -1"); - return -1; - } + } else { + setErrorCode(4028); + return -1; } } else { if(DEBUG_NEXT_RESULT) ndbout_c("return 2"); @@ -1400,14 +1448,26 @@ NdbIndexScanOperation::next_result_ordered(bool fetchAllowed){ } int -NdbIndexScanOperation::send_next_scan_ordered(Uint32 idx){ +NdbIndexScanOperation::send_next_scan_ordered(Uint32 idx, bool forceSend){ if(idx == theParallelism) return 0; + NdbReceiver* tRec = m_api_receivers[idx]; NdbApiSignal tSignal(theNdb->theMyRef); tSignal.setSignal(GSN_SCAN_NEXTREQ); + Uint32 last = m_sent_receivers_count; Uint32* theData = tSignal.getDataPtrSend(); + Uint32* prep_array = theData + 4; + + m_current_api_receiver = idx + 1; + if((prep_array[0] = tRec->m_tcPtrI) == RNIL) + { + if(DEBUG_NEXT_RESULT) + ndbout_c("receiver completed, don't send"); + return 0; + } + theData[0] = theNdbCon->theTCConPtr; theData[1] = 0; Uint64 transId = theNdbCon->theTransactionId; @@ -1417,37 +1477,37 @@ NdbIndexScanOperation::send_next_scan_ordered(Uint32 idx){ /** * Prepare ops */ - Uint32 last = m_sent_receivers_count; - Uint32 * prep_array = theData + 4; - - NdbReceiver * tRec = m_api_receivers[idx]; m_sent_receivers[last] = tRec; tRec->m_list_index = last; - prep_array[0] = tRec->m_tcPtrI; tRec->prepareSend(); - m_sent_receivers_count = last + 1; - m_current_api_receiver = idx + 1; Uint32 nodeId = theNdbCon->theDBnode; TransporterFacade * tp = TransporterFacade::instance(); tSignal.setLength(4+1); - return tp->sendSignal(&tSignal, nodeId); + int ret= tp->sendSignal(&tSignal, nodeId); + if (!ret) checkForceSend(forceSend); + return ret; } int -NdbScanOperation::close_impl(TransporterFacade* tp){ +NdbScanOperation::close_impl(TransporterFacade* tp, bool forceSend){ Uint32 seq = theNdbCon->theNodeSequence; Uint32 nodeId = theNdbCon->theDBnode; - if(seq != tp->getNodeSequence(nodeId)){ + if(seq != tp->getNodeSequence(nodeId)) + { theNdbCon->theReleaseOnClose = true; return -1; } - while(theError.code == 0 && m_sent_receivers_count){ - theNdb->theWaiter.m_node = nodeId; - theNdb->theWaiter.m_state = WAIT_SCAN; + /** + * Wait for outstanding + */ + while(theError.code == 0 && m_sent_receivers_count) + { + theNdb->theImpl->theWaiter.m_node = nodeId; + theNdb->theImpl->theWaiter.m_state = WAIT_SCAN; int return_code = theNdb->receiveResponse(WAITFOR_SCAN_TIMEOUT); switch(return_code){ case 0: @@ -1463,20 +1523,61 @@ NdbScanOperation::close_impl(TransporterFacade* tp){ } } - if(m_api_receivers_count+m_conf_receivers_count){ - // Send close scan - if(send_next_scan(0, true) == -1){ // Close scan - theNdbCon->theReleaseOnClose = true; - return -1; - } + if(theError.code) + { + m_api_receivers_count = 0; + m_current_api_receiver = m_ordered ? theParallelism : 0; + } + + + /** + * move all conf'ed into api + * so that send_next_scan can check if they needs to be closed + */ + Uint32 api = m_api_receivers_count; + Uint32 conf = m_conf_receivers_count; + + if(m_ordered) + { + /** + * Ordered scan, keep the m_api_receivers "to the right" + */ + memmove(m_api_receivers, m_api_receivers+m_current_api_receiver, + (theParallelism - m_current_api_receiver) * sizeof(char*)); + api = (theParallelism - m_current_api_receiver); + m_api_receivers_count = api; + } + + if(DEBUG_NEXT_RESULT) + ndbout_c("close_impl: [order api conf sent curr parr] %d %d %d %d %d %d", + m_ordered, api, conf, + m_sent_receivers_count, m_current_api_receiver, theParallelism); + + if(api+conf) + { + /** + * There's something to close + * setup m_api_receivers (for send_next_scan) + */ + memcpy(m_api_receivers+api, m_conf_receivers, conf * sizeof(char*)); + m_api_receivers_count = api + conf; + m_conf_receivers_count = 0; + } + + // Send close scan + if(send_next_scan(api+conf, true, forceSend) == -1) + { + theNdbCon->theReleaseOnClose = true; + return -1; } /** * wait for close scan conf */ - while(m_sent_receivers_count+m_api_receivers_count+m_conf_receivers_count){ - theNdb->theWaiter.m_node = nodeId; - theNdb->theWaiter.m_state = WAIT_SCAN; + while(m_sent_receivers_count+m_api_receivers_count+m_conf_receivers_count) + { + theNdb->theImpl->theWaiter.m_node = nodeId; + theNdb->theImpl->theWaiter.m_state = WAIT_SCAN; int return_code = theNdb->receiveResponse(WAITFOR_SCAN_TIMEOUT); switch(return_code){ case 0: @@ -1491,6 +1592,7 @@ NdbScanOperation::close_impl(TransporterFacade* tp){ return -1; } } + return 0; } @@ -1507,17 +1609,12 @@ NdbScanOperation::reset_receivers(Uint32 parallell, Uint32 ordered){ m_api_receivers_count = 0; m_current_api_receiver = 0; - m_sent_receivers_count = parallell; + m_sent_receivers_count = 0; m_conf_receivers_count = 0; - - if(ordered){ - m_current_api_receiver = parallell; - m_api_receivers_count = parallell; - } } int -NdbScanOperation::restart() +NdbScanOperation::restart(bool forceSend) { TransporterFacade* tp = TransporterFacade::instance(); @@ -1526,7 +1623,7 @@ NdbScanOperation::restart() { int res; - if((res= close_impl(tp))) + if((res= close_impl(tp, forceSend))) { return res; } @@ -1545,13 +1642,13 @@ NdbScanOperation::restart() } int -NdbIndexScanOperation::reset_bounds(){ +NdbIndexScanOperation::reset_bounds(bool forceSend){ int res; { TransporterFacade* tp = TransporterFacade::instance(); Guard guard(tp->theMutexPtr); - res= close_impl(tp); + res= close_impl(tp, forceSend); } if(!res) diff --git a/ndb/src/ndbapi/NdbWaiter.hpp b/ndb/src/ndbapi/NdbWaiter.hpp new file mode 100644 index 00000000000..8b7b2a75879 --- /dev/null +++ b/ndb/src/ndbapi/NdbWaiter.hpp @@ -0,0 +1,102 @@ +/* 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_WAITER_HPP +#define NDB_WAITER_HPP + +#include <ndb_global.h> +#include <NdbOut.hpp> +#include <NdbError.hpp> +#include <NdbCondition.h> +#include <NdbReceiver.hpp> +#include <NdbOperation.hpp> +#include <kernel/ndb_limits.h> + +#include <NdbTick.h> + +enum WaitSignalType { + NO_WAIT = 0, + WAIT_NODE_FAILURE = 1, // Node failure during wait + WST_WAIT_TIMEOUT = 2, // Timeout during wait + + WAIT_TC_SEIZE = 3, + WAIT_TC_RELEASE = 4, + WAIT_NDB_TAMPER = 5, + WAIT_SCAN = 6, + + // DICT stuff + WAIT_GET_TAB_INFO_REQ = 11, + WAIT_CREATE_TAB_REQ = 12, + WAIT_DROP_TAB_REQ = 13, + WAIT_ALTER_TAB_REQ = 14, + WAIT_CREATE_INDX_REQ = 15, + WAIT_DROP_INDX_REQ = 16, + WAIT_LIST_TABLES_CONF = 17 +}; + +class NdbWaiter { +public: + NdbWaiter(); + ~NdbWaiter(); + + void wait(int waitTime); + void nodeFail(Uint32 node); + void signal(Uint32 state); + + Uint32 m_node; + Uint32 m_state; + void * m_mutex; + struct NdbCondition * m_condition; +}; + +inline +void +NdbWaiter::wait(int waitTime) +{ + const bool forever = (waitTime == -1); + const NDB_TICKS maxTime = NdbTick_CurrentMillisecond() + waitTime; + while (1) { + if (m_state == NO_WAIT || m_state == WAIT_NODE_FAILURE) + break; + if (forever) { + NdbCondition_Wait(m_condition, (NdbMutex*)m_mutex); + } else { + if (waitTime <= 0) { + m_state = WST_WAIT_TIMEOUT; + break; + } + NdbCondition_WaitTimeout(m_condition, (NdbMutex*)m_mutex, waitTime); + waitTime = maxTime - NdbTick_CurrentMillisecond(); + } + } +} + +inline +void +NdbWaiter::nodeFail(Uint32 aNodeId){ + if (m_state != NO_WAIT && m_node == aNodeId){ + m_state = WAIT_NODE_FAILURE; + NdbCondition_Signal(m_condition); + } +} + +inline +void +NdbWaiter::signal(Uint32 state){ + m_state = state; + NdbCondition_Signal(m_condition); +} + +#endif diff --git a/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp index c011c1a6a26..a4f233709c4 100644 --- a/ndb/src/ndbapi/Ndbif.cpp +++ b/ndb/src/ndbapi/Ndbif.cpp @@ -92,8 +92,8 @@ Ndb::init(int aMaxNoOfTransactions) theDictionary->setTransporter(this, theFacade); - aNrOfCon = theNoOfDBnodes; - aNrOfOp = 2*theNoOfDBnodes; + aNrOfCon = theImpl->theNoOfDBnodes; + aNrOfOp = 2*theImpl->theNoOfDBnodes; // Create connection object in a linked list if((createConIdleList(aNrOfCon)) == -1){ @@ -192,14 +192,14 @@ void Ndb::connected(Uint32 ref) } TransporterFacade * theFacade = TransporterFacade::instance(); - int i; - theNoOfDBnodes= 0; + int i, n= 0; for (i = 1; i < MAX_NDB_NODES; i++){ if (theFacade->getIsDbNode(i)){ - theDBnodes[theNoOfDBnodes] = i; - theNoOfDBnodes++; + theImpl->theDBnodes[n] = i; + n++; } } + theImpl->theNoOfDBnodes= n; theFirstTransId = ((Uint64)tBlockNo << 52)+ ((Uint64)tmpTheNode << 40); theFirstTransId += theFacade->m_max_trans_id; @@ -207,9 +207,8 @@ void Ndb::connected(Uint32 ref) DBUG_PRINT("info",("connected with ref=%x, id=%d, no_db_nodes=%d, first_trans_id=%lx", theMyRef, tmpTheNode, - theNoOfDBnodes, + theImpl->theNoOfDBnodes, theFirstTransId)); - startTransactionNodeSelectionData.init(theNoOfDBnodes, theDBnodes); theCommitAckSignal = new NdbApiSignal(theMyRef); theDictionary->m_receiver.m_reference= theMyRef; @@ -247,8 +246,10 @@ Ndb::report_node_failure(Uint32 node_id) * * This method is only called by ClusterMgr (via lots of methods) */ - the_release_ind[node_id] = 1; - theWaiter.nodeFail(node_id); + theImpl->the_release_ind[node_id] = 1; + // must come after + theImpl->the_release_ind[0] = 1; + theImpl->theWaiter.nodeFail(node_id); return; }//Ndb::report_node_failure() @@ -327,7 +328,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) NdbConnection* tCon; int tReturnCode = -1; const Uint32* tDataPtr = aSignal->getDataPtr(); - const Uint32 tWaitState = theWaiter.m_state; + const Uint32 tWaitState = theImpl->theWaiter.m_state; const Uint32 tSignalNumber = aSignal->readSignalNumber(); const Uint32 tFirstData = *tDataPtr; const Uint32 tLen = aSignal->getLength(); @@ -398,7 +399,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) break; case NdbReceiver::NDB_SCANRECEIVER: tCon->theScanningOp->receiver_delivered(tRec); - theWaiter.m_state = (((WaitSignalType) tWaitState) == WAIT_SCAN ? + theImpl->theWaiter.m_state = (((WaitSignalType) tWaitState) == WAIT_SCAN ? (Uint32) NO_WAIT : tWaitState); break; default: @@ -595,7 +596,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) }//if tReturnCode = tCon->receiveTCSEIZECONF(aSignal); if (tReturnCode != -1) { - theWaiter.m_state = NO_WAIT; + theImpl->theWaiter.m_state = NO_WAIT; } else { goto InvalidSignal; }//if @@ -615,7 +616,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) }//if tReturnCode = tCon->receiveTCSEIZEREF(aSignal); if (tReturnCode != -1) { - theWaiter.m_state = NO_WAIT; + theImpl->theWaiter.m_state = NO_WAIT; } else { return; }//if @@ -635,7 +636,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) }//if tReturnCode = tCon->receiveTCRELEASECONF(aSignal); if (tReturnCode != -1) { - theWaiter.m_state = NO_WAIT; + theImpl->theWaiter.m_state = NO_WAIT; }//if break; } @@ -653,7 +654,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) }//if tReturnCode = tCon->receiveTCRELEASEREF(aSignal); if (tReturnCode != -1) { - theWaiter.m_state = NO_WAIT; + theImpl->theWaiter.m_state = NO_WAIT; }//if break; } @@ -705,7 +706,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) return; tReturnCode = tCon->receiveDIHNDBTAMPER(aSignal); if (tReturnCode != -1) - theWaiter.m_state = NO_WAIT; + theImpl->theWaiter.m_state = NO_WAIT; break; } case GSN_SCAN_TABCONF: @@ -727,7 +728,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) tLen - ScanTabConf::SignalLength); } if (tReturnCode != -1 && tWaitState == WAIT_SCAN) - theWaiter.m_state = NO_WAIT; + theImpl->theWaiter.m_state = NO_WAIT; break; } else { goto InvalidSignal; @@ -746,7 +747,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) if (tCon->checkMagicNumber() == 0){ tReturnCode = tCon->receiveSCAN_TABREF(aSignal); if (tReturnCode != -1 && tWaitState == WAIT_SCAN){ - theWaiter.m_state = NO_WAIT; + theImpl->theWaiter.m_state = NO_WAIT; } break; } @@ -771,7 +772,7 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) switch(com){ case 1: tCon->theScanningOp->receiver_delivered(tRec); - theWaiter.m_state = (((WaitSignalType) tWaitState) == WAIT_SCAN ? + theImpl->theWaiter.m_state = (((WaitSignalType) tWaitState) == WAIT_SCAN ? (Uint32) NO_WAIT : tWaitState); break; case 0: @@ -835,16 +836,16 @@ Ndb::handleReceivedSignal(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]) goto InvalidSignal; }//switch - if (theWaiter.m_state == NO_WAIT) { + if (theImpl->theWaiter.m_state == NO_WAIT) { // Wake up the thread waiting for response - NdbCondition_Signal(theWaiter.m_condition); + NdbCondition_Signal(theImpl->theWaiter.m_condition); }//if return; InvalidSignal: #ifdef VM_TRACE ndbout_c("Ndbif: Error Ndb::handleReceivedSignal " - "(GSN=%d, theWaiter.m_state=%d)" + "(GSN=%d, theImpl->theWaiter.m_state=%d)" " sender = (Block: %d Node: %d)", tSignalNumber, tWaitState, @@ -892,7 +893,7 @@ Ndb::completedTransaction(NdbConnection* aCon) if ((theMinNoOfEventsToWakeUp != 0) && (theNoOfCompletedTransactions >= theMinNoOfEventsToWakeUp)) { theMinNoOfEventsToWakeUp = 0; - NdbCondition_Signal(theWaiter.m_condition); + NdbCondition_Signal(theImpl->theWaiter.m_condition); return; }//if } else { @@ -1152,9 +1153,9 @@ void Ndb::waitCompletedTransactions(int aMilliSecondsToWait, int noOfEventsToWaitFor) { - theWaiter.m_state = NO_WAIT; + theImpl->theWaiter.m_state = NO_WAIT; /** - * theWaiter.m_state = NO_WAIT; + * theImpl->theWaiter.m_state = NO_WAIT; * To ensure no messup with synchronous node fail handling * (see ReportFailure) */ @@ -1163,8 +1164,8 @@ Ndb::waitCompletedTransactions(int aMilliSecondsToWait, theMinNoOfEventsToWakeUp = noOfEventsToWaitFor; do { if (waitTime < 1000) waitTime = 1000; - NdbCondition_WaitTimeout(theWaiter.m_condition, - (NdbMutex*)theWaiter.m_mutex, + NdbCondition_WaitTimeout(theImpl->theWaiter.m_condition, + (NdbMutex*)theImpl->theWaiter.m_mutex, waitTime); if (theNoOfCompletedTransactions >= (Uint32)noOfEventsToWaitFor) { break; @@ -1270,23 +1271,23 @@ Ndb::receiveResponse(int waitTime){ int tResultCode; TransporterFacade::instance()->checkForceSend(theNdbBlockNumber); - theWaiter.wait(waitTime); + theImpl->theWaiter.wait(waitTime); - if(theWaiter.m_state == NO_WAIT) { + if(theImpl->theWaiter.m_state == NO_WAIT) { tResultCode = 0; } else { #ifdef VM_TRACE - ndbout << "ERR: receiveResponse - theWaiter.m_state = "; - ndbout << theWaiter.m_state << endl; + ndbout << "ERR: receiveResponse - theImpl->theWaiter.m_state = "; + ndbout << theImpl->theWaiter.m_state << endl; #endif - if (theWaiter.m_state == WAIT_NODE_FAILURE){ + if (theImpl->theWaiter.m_state == WAIT_NODE_FAILURE){ tResultCode = -2; } else { tResultCode = -1; } - theWaiter.m_state = NO_WAIT; + theImpl->theWaiter.m_state = NO_WAIT; } return tResultCode; }//Ndb::receiveResponse() @@ -1318,8 +1319,8 @@ Ndb::sendRecSignal(Uint16 node_id, if (tp->check_send_size(node_id, send_size)) { return_code = tp->sendSignal(aSignal, node_id); if (return_code != -1) { - theWaiter.m_node = node_id; - theWaiter.m_state = aWaitState; + theImpl->theWaiter.m_node = node_id; + theImpl->theWaiter.m_state = aWaitState; return_code = receiveResponse(); } else { return_code = -3; diff --git a/ndb/src/ndbapi/Ndbinit.cpp b/ndb/src/ndbapi/Ndbinit.cpp index 698bbcde4c6..a11dd842495 100644 --- a/ndb/src/ndbapi/Ndbinit.cpp +++ b/ndb/src/ndbapi/Ndbinit.cpp @@ -50,7 +50,9 @@ Ndb(const char* aDataBase); Parameters: aDataBase : Name of the database. Remark: Connect to the database. ***************************************************************************/ -Ndb::Ndb( const char* aDataBase , const char* aSchema) { +Ndb::Ndb( const char* aDataBase , const char* aSchema) + : theImpl(NULL) +{ DBUG_ENTER("Ndb::Ndb()"); DBUG_PRINT("enter",("(old)Ndb::Ndb this=0x%x", this)); if (theNoOfNdbObjects < 0) @@ -58,7 +60,7 @@ Ndb::Ndb( const char* aDataBase , const char* aSchema) { theNoOfNdbObjects++; if (global_ndb_cluster_connection == 0) { global_ndb_cluster_connection= new Ndb_cluster_connection(ndbConnectString); - global_ndb_cluster_connection->connect(); + global_ndb_cluster_connection->connect(12,5,1); } setup(global_ndb_cluster_connection, aDataBase, aSchema); DBUG_VOID_RETURN; @@ -66,6 +68,7 @@ Ndb::Ndb( const char* aDataBase , const char* aSchema) { Ndb::Ndb( Ndb_cluster_connection *ndb_cluster_connection, const char* aDataBase , const char* aSchema) + : theImpl(NULL) { DBUG_ENTER("Ndb::Ndb()"); DBUG_PRINT("enter",("Ndb::Ndb this=0x%x", this)); @@ -82,8 +85,10 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, { DBUG_ENTER("Ndb::setup"); - theNdbObjectIdMap= 0; - m_ndb_cluster_connection= ndb_cluster_connection; + assert(theImpl == NULL); + theImpl= new NdbImpl(ndb_cluster_connection,*this); + theDictionary= &(theImpl->m_dictionary); + thePreparedTransactionsArray= NULL; theSentTransactionsArray= NULL; theCompletedTransactionsArray= NULL; @@ -94,8 +99,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, theMaxNoOfTransactions= 0; theMinNoOfEventsToWakeUp= 0; prefixEnd= NULL; - theImpl= NULL; - theDictionary= NULL; theConIdleList= NULL; theOpIdleList= NULL; theScanOpIdleList= NULL; @@ -110,9 +113,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, theCallList= NULL; theScanList= NULL; theNdbBlobIdleList= NULL; - theNoOfDBnodes= 0; - theDBnodes= NULL; - the_release_ind= NULL; the_last_check_time= 0; theFirstTransId= 0; theRestartGCI= 0; @@ -134,19 +134,12 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, theError.code = 0; - theNdbObjectIdMap = new NdbObjectIdMap(1024,1024); theConnectionArray = new NdbConnection * [MAX_NDB_NODES]; - theDBnodes = new Uint32[MAX_NDB_NODES]; - the_release_ind = new Uint8[MAX_NDB_NODES]; theCommitAckSignal = NULL; - theCurrentConnectCounter = 1; - theCurrentConnectIndex = 0; int i; for (i = 0; i < MAX_NDB_NODES ; i++) { theConnectionArray[i] = NULL; - the_release_ind[i] = 0; - theDBnodes[i] = 0; }//forg for (i = 0; i < 2048 ; i++) { theFirstTupleId[i] = 0; @@ -164,14 +157,12 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, prefixEnd = prefixName + (len < (int) sizeof(prefixName) ? len : sizeof(prefixName) - 1); - theWaiter.m_mutex = TransporterFacade::instance()->theMutexPtr; + theImpl->theWaiter.m_mutex = TransporterFacade::instance()->theMutexPtr; // Signal that the constructor has finished OK if (theInitState == NotConstructed) theInitState = NotInitialised; - theImpl = new NdbImpl(); - { NdbGlobalEventBufferHandle *h= NdbGlobalEventBuffer_init(NDB_MAX_ACTIVE_EVENTS); @@ -182,11 +173,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, theGlobalEventBufferHandle = h; } - theDictionary = new NdbDictionaryImpl(*this); - if (theDictionary == NULL) { - ndbout_c("Ndb cailed to allocate dictionary"); - exit(-1); - } DBUG_VOID_RETURN; } @@ -212,23 +198,12 @@ Ndb::~Ndb() DBUG_PRINT("enter",("Ndb::~Ndb this=0x%x",this)); doDisconnect(); - delete theDictionary; - delete theImpl; - NdbGlobalEventBuffer_drop(theGlobalEventBufferHandle); if (TransporterFacade::instance() != NULL && theNdbBlockNumber > 0){ TransporterFacade::instance()->close(theNdbBlockNumber, theFirstTransId); } - if (global_ndb_cluster_connection != 0) { - theNoOfNdbObjects--; - if(theNoOfNdbObjects == 0){ - delete global_ndb_cluster_connection; - global_ndb_cluster_connection= 0; - } - }//if - // if (theSchemaConToNdbList != NULL) // closeSchemaTransaction(theSchemaConToNdbList); while ( theConIdleList != NULL ) @@ -257,18 +232,27 @@ Ndb::~Ndb() freeSignal(); releaseTransactionArrays(); - startTransactionNodeSelectionData.release(); delete []theConnectionArray; - delete []theDBnodes; - delete []the_release_ind; if(theCommitAckSignal != NULL){ delete theCommitAckSignal; theCommitAckSignal = NULL; } - if(theNdbObjectIdMap != 0) - delete theNdbObjectIdMap; + delete theImpl; + + /** + * This needs to be put after delete theImpl + * as TransporterFacade::instance is delete by global_ndb_cluster_connection + * and used by theImpl + */ + if (global_ndb_cluster_connection != 0) { + theNoOfNdbObjects--; + if(theNoOfNdbObjects == 0){ + delete global_ndb_cluster_connection; + global_ndb_cluster_connection= 0; + } + }//if /** * This sleep is to make sure that the transporter @@ -307,4 +291,23 @@ NdbWaiter::~NdbWaiter(){ NdbCondition_Destroy(m_condition); } +NdbImpl::NdbImpl(Ndb_cluster_connection *ndb_cluster_connection, + Ndb& ndb) + : m_ndb_cluster_connection(ndb_cluster_connection->m_impl), + m_dictionary(ndb), + theCurrentConnectIndex(0), + theNdbObjectIdMap(1024,1024), + theNoOfDBnodes(0) +{ + int i; + for (i = 0; i < MAX_NDB_NODES; i++) { + the_release_ind[i] = 0; + } + m_optimized_node_selection= + m_ndb_cluster_connection.m_optimized_node_selection; +} + +NdbImpl::~NdbImpl() +{ +} diff --git a/ndb/src/ndbapi/Ndblist.cpp b/ndb/src/ndbapi/Ndblist.cpp index a5f2a4801d5..5902aa413dc 100644 --- a/ndb/src/ndbapi/Ndblist.cpp +++ b/ndb/src/ndbapi/Ndblist.cpp @@ -30,10 +30,18 @@ void Ndb::checkFailedNode() { DBUG_ENTER("Ndb::checkFailedNode"); - DBUG_PRINT("enter", ("theNoOfDBnodes: %d", theNoOfDBnodes)); + Uint32 *the_release_ind= theImpl->the_release_ind; + if (the_release_ind[0] == 0) + { + DBUG_VOID_RETURN; + } + Uint32 tNoOfDbNodes = theImpl->theNoOfDBnodes; + Uint8 *theDBnodes= theImpl->theDBnodes; + + DBUG_PRINT("enter", ("theNoOfDBnodes: %d", tNoOfDbNodes)); - DBUG_ASSERT(theNoOfDBnodes < MAX_NDB_NODES); - for (Uint32 i = 0; i < theNoOfDBnodes; i++){ + DBUG_ASSERT(tNoOfDbNodes < MAX_NDB_NODES); + for (Uint32 i = 0; i < tNoOfDbNodes; i++){ const NodeId node_id = theDBnodes[i]; DBUG_PRINT("info", ("i: %d, node_id: %d", i, node_id)); @@ -56,31 +64,6 @@ Ndb::checkFailedNode() DBUG_VOID_RETURN; } -#if 0 -void -NdbImpl::checkInvalidTable(NdbDictionaryImpl * dict){ - Uint32 sz = m_invalidTables.size(); - for(Int32 i = sz - 1; i >= 0; i--){ - NdbTableImpl * tab = m_invalidTables[i]; - m_invalidTables.erase(i); - dict->tableDropped(* tab); - } -} - -void -NdbImpl::checkErrorCode(Uint32 i, NdbTableImpl * tab){ - switch(i){ - case 241: - case 283: - case 284: - case 285: - case 1225: - case 1226: - - } -} -#endif - /*************************************************************************** * int createConIdleList(int aNrOfCon); * diff --git a/ndb/src/ndbapi/ObjectMap.hpp b/ndb/src/ndbapi/ObjectMap.hpp index 12bede3aa3f..21407279f0b 100644 --- a/ndb/src/ndbapi/ObjectMap.hpp +++ b/ndb/src/ndbapi/ObjectMap.hpp @@ -29,7 +29,7 @@ class NdbObjectIdMap //: NdbLockable { public: - STATIC_CONST( InvalidId = ~0 ); + STATIC_CONST( InvalidId = ~(Uint32)0 ); NdbObjectIdMap(Uint32 initalSize = 128, Uint32 expandSize = 10); ~NdbObjectIdMap(); diff --git a/ndb/src/ndbapi/TransporterFacade.cpp b/ndb/src/ndbapi/TransporterFacade.cpp index bc24110ea14..5582143be44 100644 --- a/ndb/src/ndbapi/TransporterFacade.cpp +++ b/ndb/src/ndbapi/TransporterFacade.cpp @@ -34,6 +34,7 @@ #include <NdbConfig.h> #include <ndb_version.h> #include <SignalLoggerManager.hpp> +#include <kernel/ndb_limits.h> //#define REPORT_TRANSPORTER //#define API_TRACE; @@ -404,11 +405,8 @@ extern "C" void* runSendRequest_C(void * me) { - my_thread_init(); ((TransporterFacade*) me)->threadMainSend(); - my_thread_end(); - NdbThread_Exit(0); - return me; + return 0; } void TransporterFacade::threadMainSend(void) @@ -442,11 +440,8 @@ extern "C" void* runReceiveResponse_C(void * me) { - my_thread_init(); ((TransporterFacade*) me)->threadMainReceive(); - my_thread_end(); - NdbThread_Exit(0); - return me; + return 0; } void TransporterFacade::threadMainReceive(void) @@ -475,7 +470,8 @@ TransporterFacade::TransporterFacade() : theTransporterRegistry(0), theStopReceive(0), theSendThread(NULL), - theReceiveThread(NULL) + theReceiveThread(NULL), + m_fragmented_signal_id(0) { theOwnId = 0; @@ -624,6 +620,9 @@ TransporterFacade::ReportNodeFailureComplete(NodeId tNodeId) * After the restart the node is up again and the Ndb object * might not have noticed the failure. */ + + DBUG_ENTER("TransporterFacade::ReportNodeFailureComplete"); + DBUG_PRINT("enter",("nodeid= %d", tNodeId)); Uint32 sz = m_threads.m_statusNext.size(); for (Uint32 i = 0; i < sz ; i ++) { if (m_threads.getInUse(i)){ @@ -632,6 +631,7 @@ TransporterFacade::ReportNodeFailureComplete(NodeId tNodeId) (*RegPC) (obj, tNodeId, false, true); } } + DBUG_VOID_RETURN; } void @@ -833,9 +833,129 @@ TransporterFacade::sendSignalUnCond(NdbApiSignal * aSignal, NodeId aNode){ return (ss == SEND_OK ? 0 : -1); } +#define CHUNK_SZ NDB_SECTION_SEGMENT_SZ*64 // related to MAX_MESSAGE_SIZE int TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, - LinearSectionPtr ptr[3], Uint32 secs){ + LinearSectionPtr ptr[3], Uint32 secs) +{ + if(getIsNodeSendable(aNode) != true) + return -1; + +#ifdef API_TRACE + if(setSignalLog() && TRACE_GSN(aSignal->theVerId_signalNumber)){ + Uint32 tmp = aSignal->theSendersBlockRef; + aSignal->theSendersBlockRef = numberToRef(tmp, theOwnId); + signalLogger.sendSignal(* aSignal, + 1, + aSignal->getDataPtrSend(), + aNode, + ptr, secs); + aSignal->theSendersBlockRef = tmp; + } +#endif + + NdbApiSignal tmp_signal(*(SignalHeader*)aSignal); + LinearSectionPtr tmp_ptr[3]; + Uint32 unique_id= m_fragmented_signal_id++; // next unique id + unsigned i; + for (i= 0; i < secs; i++) + tmp_ptr[i]= ptr[i]; + + unsigned start_i= 0; + unsigned chunk_sz= 0; + unsigned fragment_info= 0; + Uint32 *tmp_data= tmp_signal.getDataPtrSend(); + for (i= 0; i < secs;) { + unsigned save_sz= tmp_ptr[i].sz; + tmp_data[i-start_i]= i; + if (chunk_sz + save_sz > CHUNK_SZ) { + // truncate + unsigned send_sz= CHUNK_SZ - chunk_sz; + if (i != start_i) // first piece of a new section has to be a multiple of NDB_SECTION_SEGMENT_SZ + { + send_sz= + NDB_SECTION_SEGMENT_SZ + *(send_sz+NDB_SECTION_SEGMENT_SZ-1) + /NDB_SECTION_SEGMENT_SZ; + if (send_sz > save_sz) + send_sz= save_sz; + } + tmp_ptr[i].sz= send_sz; + + if (fragment_info < 2) // 1 = first fragment, 2 = middle fragments + fragment_info++; + + // send tmp_signal + tmp_data[i-start_i+1]= unique_id; + tmp_signal.setLength(i-start_i+2); + tmp_signal.m_fragmentInfo= fragment_info; + tmp_signal.m_noOfSections= i-start_i+1; + // do prepare send + { + SendStatus ss = theTransporterRegistry->prepareSend + (&tmp_signal, + 1, /*JBB*/ + tmp_data, + aNode, + &tmp_ptr[start_i]); + assert(ss != SEND_MESSAGE_TOO_BIG); + if (ss != SEND_OK) return -1; + } + // setup variables for next signal + start_i= i; + chunk_sz= 0; + tmp_ptr[i].sz= save_sz-send_sz; + tmp_ptr[i].p+= send_sz; + if (tmp_ptr[i].sz == 0) + i++; + } + else + { + chunk_sz+=save_sz; + i++; + } + } + + unsigned a_sz= aSignal->getLength(); + + if (fragment_info > 0) { + // update the original signal to include section info + Uint32 *a_data= aSignal->getDataPtrSend(); + unsigned tmp_sz= i-start_i; + memcpy(a_data+a_sz, + tmp_data, + tmp_sz*sizeof(Uint32)); + a_data[a_sz+tmp_sz]= unique_id; + aSignal->setLength(a_sz+tmp_sz+1); + + // send last fragment + aSignal->m_fragmentInfo= 3; // 3 = last fragment + aSignal->m_noOfSections= i-start_i; + } else { + aSignal->m_noOfSections= secs; + } + + // send aSignal + int ret; + { + SendStatus ss = theTransporterRegistry->prepareSend + (aSignal, + 1/*JBB*/, + aSignal->getDataPtrSend(), + aNode, + &tmp_ptr[start_i]); + assert(ss != SEND_MESSAGE_TOO_BIG); + ret = (ss == SEND_OK ? 0 : -1); + } + aSignal->m_noOfSections = 0; + aSignal->m_fragmentInfo = 0; + aSignal->setLength(a_sz); + return ret; +} + +int +TransporterFacade::sendSignal(NdbApiSignal* aSignal, NodeId aNode, + LinearSectionPtr ptr[3], Uint32 secs){ aSignal->m_noOfSections = secs; if(getIsNodeSendable(aNode) == true){ #ifdef API_TRACE @@ -865,39 +985,6 @@ TransporterFacade::sendFragmentedSignal(NdbApiSignal* aSignal, NodeId aNode, return -1; } - - -int -TransporterFacade::sendFragmentedSignalUnCond(NdbApiSignal* aSignal, - NodeId aNode, - LinearSectionPtr ptr[3], - Uint32 secs){ - aSignal->m_noOfSections = secs; - -#ifdef API_TRACE - if(setSignalLog() && TRACE_GSN(aSignal->theVerId_signalNumber)){ - Uint32 tmp = aSignal->theSendersBlockRef; - aSignal->theSendersBlockRef = numberToRef(tmp, theOwnId); - signalLogger.sendSignal(* aSignal, - 1, - aSignal->getDataPtrSend(), - aNode, - ptr, secs); - aSignal->theSendersBlockRef = tmp; - } -#endif - SendStatus ss = theTransporterRegistry->prepareSend(aSignal, - 1, // JBB - aSignal->getDataPtrSend(), - aNode, - ptr); - assert(ss != SEND_MESSAGE_TOO_BIG); - aSignal->m_noOfSections = 0; - return (ss == SEND_OK ? 0 : -1); -} - - - /****************************************************************************** * CONNECTION METHODS Etc ******************************************************************************/ diff --git a/ndb/src/ndbapi/TransporterFacade.hpp b/ndb/src/ndbapi/TransporterFacade.hpp index 5f473975585..99edea846c1 100644 --- a/ndb/src/ndbapi/TransporterFacade.hpp +++ b/ndb/src/ndbapi/TransporterFacade.hpp @@ -69,14 +69,11 @@ public: // Only sends to nodes which are alive int sendSignal(NdbApiSignal * signal, NodeId nodeId); + int sendSignal(NdbApiSignal*, NodeId, + LinearSectionPtr ptr[3], Uint32 secs); int sendFragmentedSignal(NdbApiSignal*, NodeId, LinearSectionPtr ptr[3], Uint32 secs); - //Dirrrrty - int sendFragmentedSignalUnCond(NdbApiSignal*, NodeId, - LinearSectionPtr ptr[3], Uint32 secs); - - // Is node available for running transactions bool get_node_alive(NodeId nodeId) const; bool get_node_stopping(NodeId nodeId) const; @@ -130,7 +127,7 @@ private: friend class ExtSender; ///< @todo Hack to be able to sendSignalUnCond friend class GrepSS; friend class Ndb; - friend class Ndb_cluster_connection; + friend class Ndb_cluster_connection_impl; int sendSignalUnCond(NdbApiSignal *, NodeId nodeId); @@ -224,7 +221,8 @@ private: } m_threads; Uint32 m_max_trans_id; - + Uint32 m_fragmented_signal_id; + /** * execute function */ diff --git a/ndb/src/ndbapi/ndb_cluster_connection.cpp b/ndb/src/ndbapi/ndb_cluster_connection.cpp index 4c42fe1aeef..4fcf4d08396 100644 --- a/ndb/src/ndbapi/ndb_cluster_connection.cpp +++ b/ndb/src/ndbapi/ndb_cluster_connection.cpp @@ -18,7 +18,9 @@ #include <my_pthread.h> #include <my_sys.h> -#include <ndb_cluster_connection.hpp> +#include "ndb_cluster_connection_impl.hpp" +#include <mgmapi_configuration.hpp> +#include <mgmapi_config_parameters.h> #include <TransporterFacade.hpp> #include <NdbOut.hpp> #include <NdbSleep.h> @@ -26,6 +28,11 @@ #include <ndb_limits.h> #include <ConfigRetriever.hpp> #include <ndb_version.h> +#include <Vector.hpp> +#include <md5_hash.hpp> + +#include <EventLogger.hpp> +EventLogger g_eventLogger; static int g_run_connect_thread= 0; @@ -35,17 +42,221 @@ NdbMutex *ndb_global_event_buffer_mutex= NULL; NdbMutex *ndb_print_state_mutex= NULL; #endif +/* + * Ndb_cluster_connection + */ + Ndb_cluster_connection::Ndb_cluster_connection(const char *connect_string) + : m_impl(* new Ndb_cluster_connection_impl(connect_string)) +{ +} + +Ndb_cluster_connection::Ndb_cluster_connection +(Ndb_cluster_connection_impl& impl) : m_impl(impl) +{ +} + +Ndb_cluster_connection::~Ndb_cluster_connection() +{ + Ndb_cluster_connection_impl *tmp = &m_impl; + if (this != tmp) + delete tmp; +} + +int Ndb_cluster_connection::get_connected_port() const +{ + if (m_impl.m_config_retriever) + return m_impl.m_config_retriever->get_mgmd_port(); + return -1; +} + +const char *Ndb_cluster_connection::get_connected_host() const +{ + if (m_impl.m_config_retriever) + return m_impl.m_config_retriever->get_mgmd_host(); + return 0; +} + +const char *Ndb_cluster_connection::get_connectstring(char *buf, + int buf_sz) const +{ + if (m_impl.m_config_retriever) + return m_impl.m_config_retriever->get_connectstring(buf,buf_sz); + return 0; +} + +extern "C" pthread_handler_decl(run_ndb_cluster_connection_connect_thread, me) +{ + g_run_connect_thread= 1; + ((Ndb_cluster_connection_impl*) me)->connect_thread(); + return me; +} + +int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void)) +{ + int r; + DBUG_ENTER("Ndb_cluster_connection::start_connect_thread"); + m_impl.m_connect_callback= connect_callback; + if ((r = connect(0,0,0)) == 1) + { + DBUG_PRINT("info",("starting thread")); + m_impl.m_connect_thread= + NdbThread_Create(run_ndb_cluster_connection_connect_thread, + (void**)&m_impl, 32768, "ndb_cluster_connection", + NDB_THREAD_PRIO_LOW); + } + else if (r < 0) + { + DBUG_RETURN(-1); + } + else if (m_impl.m_connect_callback) + { + (*m_impl.m_connect_callback)(); + } + DBUG_RETURN(0); +} + +void Ndb_cluster_connection::set_optimized_node_selection(int val) +{ + m_impl.m_optimized_node_selection= val; +} + +void +Ndb_cluster_connection_impl::init_get_next_node +(Ndb_cluster_connection_node_iter &iter) +{ + if (iter.scan_state != (Uint8)~0) + iter.cur_pos= iter.scan_state; + if (iter.cur_pos >= no_db_nodes()) + iter.cur_pos= 0; + iter.init_pos= iter.cur_pos; + iter.scan_state= 0; + // fprintf(stderr,"[init %d]",iter.init_pos); + return; +} + +Uint32 +Ndb_cluster_connection_impl::get_next_node(Ndb_cluster_connection_node_iter &iter) +{ + Uint32 cur_pos= iter.cur_pos; + if (cur_pos >= no_db_nodes()) + return 0; + + Ndb_cluster_connection_impl::Node *nodes= m_impl.m_all_nodes.getBase(); + Ndb_cluster_connection_impl::Node &node= nodes[cur_pos]; + + if (iter.scan_state != (Uint8)~0) + { + assert(iter.scan_state < no_db_nodes()); + if (nodes[iter.scan_state].group == node.group) + iter.scan_state= ~0; + else + return nodes[iter.scan_state++].id; + } + + // fprintf(stderr,"[%d]",node.id); + + cur_pos++; + Uint32 init_pos= iter.init_pos; + if (cur_pos == node.next_group) + { + cur_pos= nodes[init_pos].this_group; + } + + // fprintf(stderr,"[cur_pos %d]",cur_pos); + if (cur_pos != init_pos) + iter.cur_pos= cur_pos; + else + { + iter.cur_pos= node.next_group; + iter.init_pos= node.next_group; + } + return node.id; +} + +unsigned +Ndb_cluster_connection::no_db_nodes() +{ + return m_impl.m_all_nodes.size(); +} + + +int +Ndb_cluster_connection::wait_until_ready(int timeout, + int timeout_after_first_alive) +{ + DBUG_ENTER("Ndb_cluster_connection::wait_until_ready"); + TransporterFacade *tp = TransporterFacade::instance(); + if (tp == 0) + { + DBUG_RETURN(-1); + } + if (tp->ownId() == 0) + { + DBUG_RETURN(-1); + } + int secondsCounter = 0; + int milliCounter = 0; + int noChecksSinceFirstAliveFound = 0; + do { + unsigned int foundAliveNode = 0; + tp->lock_mutex(); + for(unsigned i= 0; i < no_db_nodes(); i++) + { + //************************************************ + // If any node is answering, ndb is answering + //************************************************ + if (tp->get_node_alive(m_impl.m_all_nodes[i].id) != 0) { + foundAliveNode++; + } + } + tp->unlock_mutex(); + + if (foundAliveNode == no_db_nodes()) + { + DBUG_RETURN(0); + } + else if (foundAliveNode > 0) + { + noChecksSinceFirstAliveFound++; + // 100 ms delay -> 10* + if (noChecksSinceFirstAliveFound > 10*timeout_after_first_alive) + DBUG_RETURN(1); + } + else if (secondsCounter >= timeout) + { // no alive nodes and timed out + DBUG_RETURN(-1); + } + NdbSleep_MilliSleep(100); + milliCounter += 100; + if (milliCounter >= 1000) { + secondsCounter++; + milliCounter = 0; + }//if + } while (1); +} + + + +/* + * Ndb_cluster_connection_impl + */ + +Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char * + connect_string) + : Ndb_cluster_connection(*this), + m_optimized_node_selection(1) { DBUG_ENTER("Ndb_cluster_connection"); DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%x", this)); - m_facade= TransporterFacade::theFacadeInstance= new TransporterFacade(); - if (connect_string) - m_connect_string= my_strdup(connect_string,MYF(MY_WME)); - else - m_connect_string= 0; - m_config_retriever= 0; - m_local_config= 0; + + g_eventLogger.createConsoleHandler(); + g_eventLogger.setCategory("NdbApi"); + g_eventLogger.enable(Logger::LL_ON, Logger::LL_ERROR); + + m_transporter_facade= + TransporterFacade::theFacadeInstance= new TransporterFacade(); + m_connect_thread= 0; m_connect_callback= 0; @@ -59,117 +270,229 @@ Ndb_cluster_connection::Ndb_cluster_connection(const char *connect_string) ndb_print_state_mutex= NdbMutex_Create(); } #endif + m_config_retriever= + new ConfigRetriever(connect_string, NDB_VERSION, NODE_TYPE_API); + if (m_config_retriever->hasError()) + { + printf("Could not connect initialize handle to management server: %s", + m_config_retriever->getErrorString()); + delete m_config_retriever; + m_config_retriever= 0; + } + DBUG_VOID_RETURN; } -extern "C" pthread_handler_decl(run_ndb_cluster_connection_connect_thread, me) +Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() { - my_thread_init(); - g_run_connect_thread= 1; - ((Ndb_cluster_connection*) me)->connect_thread(); - my_thread_end(); - NdbThread_Exit(0); - return me; + DBUG_ENTER("~Ndb_cluster_connection"); + DBUG_PRINT("enter",("~Ndb_cluster_connection this=0x%x", this)); + TransporterFacade::stop_instance(); + if (m_connect_thread) + { + void *status; + g_run_connect_thread= 0; + NdbThread_WaitFor(m_connect_thread, &status); + NdbThread_Destroy(&m_connect_thread); + m_connect_thread= 0; + } + if (m_transporter_facade != 0) + { + delete m_transporter_facade; + if (m_transporter_facade != TransporterFacade::theFacadeInstance) + abort(); + TransporterFacade::theFacadeInstance= 0; + } + if (m_config_retriever) + delete m_config_retriever; + + // fragmentToNodeMap.release(); + + DBUG_VOID_RETURN; } -void Ndb_cluster_connection::connect_thread() +void +Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid, + const ndb_mgm_configuration + &config) { - DBUG_ENTER("Ndb_cluster_connection::connect_thread"); - int r; - do { - NdbSleep_SecSleep(1); - if ((r = connect(1)) == 0) + DBUG_ENTER("Ndb_cluster_connection_impl::init_nodes_vector"); + ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION); + + for(iter.first(); iter.valid(); iter.next()) + { + Uint32 nodeid1, nodeid2, remoteNodeId, group= 5; + const char * remoteHostName= 0, * localHostName= 0; + if(iter.get(CFG_CONNECTION_NODE_1, &nodeid1)) continue; + if(iter.get(CFG_CONNECTION_NODE_2, &nodeid2)) continue; + + if(nodeid1 != nodeid && nodeid2 != nodeid) continue; + remoteNodeId = (nodeid == nodeid1 ? nodeid2 : nodeid1); + + iter.get(CFG_CONNECTION_GROUP, &group); + + { + const char * host1= 0, * host2= 0; + iter.get(CFG_CONNECTION_HOSTNAME_1, &host1); + iter.get(CFG_CONNECTION_HOSTNAME_2, &host2); + localHostName = (nodeid == nodeid1 ? host1 : host2); + remoteHostName = (nodeid == nodeid1 ? host2 : host1); + } + + Uint32 type = ~0; + if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue; + + switch(type){ + case CONNECTION_TYPE_SHM:{ break; - if (r == -1) { - printf("Ndb_cluster_connection::connect_thread error\n"); - DBUG_ASSERT(false); - g_run_connect_thread= 0; - } else { - // Wait before making a new connect attempt - NdbSleep_SecSleep(1); } - } while (g_run_connect_thread); - if (m_connect_callback) - (*m_connect_callback)(); - DBUG_VOID_RETURN; -} + case CONNECTION_TYPE_SCI:{ + break; + } + case CONNECTION_TYPE_TCP:{ + // connecting through localhost + // check if config_hostname is local + if (SocketServer::tryBind(0,remoteHostName)) + group--; // upgrade group value + break; + } + case CONNECTION_TYPE_OSE:{ + break; + } + } + m_impl.m_all_nodes.push_back(Node(group,remoteNodeId)); + DBUG_PRINT("info",("saved %d %d", group,remoteNodeId)); + for (int i= m_impl.m_all_nodes.size()-2; + i >= 0 && m_impl.m_all_nodes[i].group > m_impl.m_all_nodes[i+1].group; + i--) + { + Node tmp= m_impl.m_all_nodes[i]; + m_impl.m_all_nodes[i]= m_impl.m_all_nodes[i+1]; + m_impl.m_all_nodes[i+1]= tmp; + } + } -int Ndb_cluster_connection::start_connect_thread(int (*connect_callback)(void)) -{ - int r; - DBUG_ENTER("Ndb_cluster_connection::start_connect_thread"); - m_connect_callback= connect_callback; - if ((r = connect(1)) == 1) + int i; + Uint32 cur_group, i_group= 0; + cur_group= ~0; + for (i= (int)m_impl.m_all_nodes.size()-1; i >= 0; i--) { - DBUG_PRINT("info",("starting thread")); - m_connect_thread= - NdbThread_Create(run_ndb_cluster_connection_connect_thread, - (void**)this, 32768, "ndb_cluster_connection", - NDB_THREAD_PRIO_LOW); + if (m_impl.m_all_nodes[i].group != cur_group) + { + cur_group= m_impl.m_all_nodes[i].group; + i_group= i+1; + } + m_impl.m_all_nodes[i].next_group= i_group; } - else if (r < 0) + cur_group= ~0; + for (i= 0; i < (int)m_impl.m_all_nodes.size(); i++) { - DBUG_RETURN(-1); + if (m_impl.m_all_nodes[i].group != cur_group) + { + cur_group= m_impl.m_all_nodes[i].group; + i_group= i; + } + m_impl.m_all_nodes[i].this_group= i_group; } - else if (m_connect_callback) - { - (*m_connect_callback)(); +#if 0 + for (i= 0; i < (int)m_impl.m_all_nodes.size(); i++) + { + fprintf(stderr, "[%d] %d %d %d %d\n", + i, + m_impl.m_all_nodes[i].id, + m_impl.m_all_nodes[i].group, + m_impl.m_all_nodes[i].this_group, + m_impl.m_all_nodes[i].next_group); } - DBUG_RETURN(0); + + do_test(); +#endif + DBUG_VOID_RETURN; } -int Ndb_cluster_connection::connect(int reconnect) +void +Ndb_cluster_connection_impl::do_test() { - DBUG_ENTER("Ndb_cluster_connection::connect"); - const char* error = 0; - do { - if (m_config_retriever == 0) + Ndb_cluster_connection_node_iter iter; + int n= no_db_nodes()+5; + Uint32 *nodes= new Uint32[n+1]; + + for (int g= 0; g < n; g++) + { + for (int h= 0; h < n; h++) { - if (m_local_config == 0) { - m_local_config= new LocalConfig(); - if (!m_local_config->init(m_connect_string,0)) { - ndbout_c("Configuration error: Unable to retrieve local config"); - m_local_config->printError(); - m_local_config->printUsage(); - DBUG_RETURN(-1); + Uint32 id; + Ndb_cluster_connection_node_iter iter2; + { + for (int j= 0; j < g; j++) + { + nodes[j]= get_next_node(iter2); } } - m_config_retriever= - new ConfigRetriever(*m_local_config, NDB_VERSION, NODE_TYPE_API); - } - else - if (reconnect == 0) - DBUG_RETURN(0); - if (reconnect) - { - int r= m_config_retriever->do_connect(1); - if (r == 1) - DBUG_RETURN(1); // mgmt server not up yet - if (r == -1) - break; - } - else - if(m_config_retriever->do_connect() == -1) - break; - Uint32 nodeId = m_config_retriever->allocNodeId(); - for(Uint32 i = 0; nodeId == 0 && i<5; i++){ - NdbSleep_SecSleep(3); - nodeId = m_config_retriever->allocNodeId(); + for (int i= 0; i < n; i++) + { + init_get_next_node(iter); + fprintf(stderr, "%d dead:(", g); + id= 0; + while (id == 0) + { + if ((id= get_next_node(iter)) == 0) + break; + for (int j= 0; j < g; j++) + { + if (nodes[j] == id) + { + fprintf(stderr, " %d", id); + id= 0; + break; + } + } + } + fprintf(stderr, ")"); + if (id == 0) + { + break; + } + fprintf(stderr, " %d\n", id); + } + fprintf(stderr, "\n"); } + } + delete [] nodes; +} + +int Ndb_cluster_connection::connect(int no_retries, int retry_delay_in_seconds, + int verbose) +{ + DBUG_ENTER("Ndb_cluster_connection::connect"); + const char* error = 0; + do { + if (m_impl.m_config_retriever == 0) + DBUG_RETURN(-1); + if (m_impl.m_config_retriever->do_connect(no_retries, + retry_delay_in_seconds, + verbose)) + DBUG_RETURN(1); // mgmt server not up yet + + Uint32 nodeId = m_impl.m_config_retriever->allocNodeId(4/*retries*/, + 3/*delay*/); if(nodeId == 0) break; - ndb_mgm_configuration * props = m_config_retriever->getConfig(); + ndb_mgm_configuration * props = m_impl.m_config_retriever->getConfig(); if(props == 0) break; - m_facade->start_instance(nodeId, props); + m_impl.m_transporter_facade->start_instance(nodeId, props); + + m_impl.init_nodes_vector(nodeId, *props); + ndb_mgm_destroy_configuration(props); - m_facade->connected(); + m_impl.m_transporter_facade->connected(); DBUG_RETURN(0); } while(0); ndbout << "Configuration error: "; - const char* erString = m_config_retriever->getErrorString(); + const char* erString = m_impl.m_config_retriever->getErrorString(); if (erString == 0) { erString = "No error specified!"; } @@ -177,32 +500,132 @@ int Ndb_cluster_connection::connect(int reconnect) DBUG_RETURN(-1); } -Ndb_cluster_connection::~Ndb_cluster_connection() +void Ndb_cluster_connection_impl::connect_thread() { - DBUG_ENTER("~Ndb_cluster_connection"); - DBUG_PRINT("enter",("~Ndb_cluster_connection this=0x%x", this)); - TransporterFacade::stop_instance(); - if (m_connect_thread) + DBUG_ENTER("Ndb_cluster_connection_impl::connect_thread"); + int r; + do { + NdbSleep_SecSleep(1); + if ((r = connect(0,0,0)) == 0) + break; + if (r == -1) { + printf("Ndb_cluster_connection::connect_thread error\n"); + DBUG_ASSERT(false); + g_run_connect_thread= 0; + } else { + // Wait before making a new connect attempt + NdbSleep_SecSleep(1); + } + } while (g_run_connect_thread); + if (m_connect_callback) + (*m_connect_callback)(); + DBUG_VOID_RETURN; +} + +/* + * Hint handling to select node + * ToDo: fix this + */ + +void +Ndb_cluster_connection_impl::FragmentToNodeMap::init(Uint32 noOfNodes, + Uint8 nodeIds[]) +{ + kValue = 6; + noOfFragments = 2 * noOfNodes; + + /** + * Compute hashValueMask and hashpointerValue + */ { - void *status; - g_run_connect_thread= 0; - NdbThread_WaitFor(m_connect_thread, &status); - NdbThread_Destroy(&m_connect_thread); - m_connect_thread= 0; + Uint32 topBit = (1 << 31); + for(int i = 31; i>=0; i--){ + if((noOfFragments & topBit) != 0) + break; + topBit >>= 1; + } + hashValueMask = topBit - 1; + hashpointerValue = noOfFragments - (hashValueMask + 1); } - if (m_facade != 0) + + /** + * This initialization depends on + * the fact that: + * primary node for fragment i = i % noOfNodes + * + * This algorithm should be implemented in Dbdih + */ { - delete m_facade; - if (m_facade != TransporterFacade::theFacadeInstance) + if (fragment2PrimaryNodeMap != 0) abort(); - TransporterFacade::theFacadeInstance= 0; + + fragment2PrimaryNodeMap = new Uint32[noOfFragments]; + Uint32 i; + for(i = 0; i<noOfNodes; i++){ + fragment2PrimaryNodeMap[i] = nodeIds[i]; + } + + // Sort them (bubble sort) + for(i = 0; i<noOfNodes-1; i++) + for(Uint32 j = i+1; j<noOfNodes; j++) + if(fragment2PrimaryNodeMap[i] > fragment2PrimaryNodeMap[j]){ + Uint32 tmp = fragment2PrimaryNodeMap[i]; + fragment2PrimaryNodeMap[i] = fragment2PrimaryNodeMap[j]; + fragment2PrimaryNodeMap[j] = tmp; + } + + for(i = 0; i<noOfNodes; i++){ + fragment2PrimaryNodeMap[i+noOfNodes] = fragment2PrimaryNodeMap[i]; + } } - my_free(m_connect_string,MYF(MY_ALLOW_ZERO_PTR)); - if (m_config_retriever) - delete m_config_retriever; - if (m_local_config) - delete m_local_config; - DBUG_VOID_RETURN; } +void +Ndb_cluster_connection_impl::FragmentToNodeMap::release(){ + delete [] fragment2PrimaryNodeMap; + fragment2PrimaryNodeMap = 0; +} + +static const Uint32 MAX_KEY_LEN_64_WORDS = 4; +Uint32 +Ndb_cluster_connection_impl::guess_primary_node(const char *keyData, + Uint32 keyLen) +{ + Uint64 tempData[MAX_KEY_LEN_64_WORDS]; + + const Uint32 usedKeyLen = (keyLen + 3) >> 2; // In words + const char * usedKeyData = 0; + + /** + * If key data buffer is not aligned (on 64 bit boundary) + * or key len is not a multiple of 4 + * Use temp data + */ + if(((((UintPtr)keyData) & 7) == 0) && ((keyLen & 3) == 0)) { + usedKeyData = keyData; + } else { + memcpy(&tempData[0], keyData, keyLen); + const int slack = keyLen & 3; + if(slack > 0) { + memset(&((char *)&tempData[0])[keyLen], 0, (4 - slack)); + }//if + usedKeyData = (char *)&tempData[0]; + }//if + + Uint32 hashValue = md5_hash((Uint64 *)usedKeyData, usedKeyLen); + + hashValue >>= fragmentToNodeMap.kValue; + + Uint32 fragmentId = hashValue & + fragmentToNodeMap.hashValueMask; + + if(fragmentId < fragmentToNodeMap.hashpointerValue) { + fragmentId = hashValue & + ((fragmentToNodeMap.hashValueMask << 1) + 1); + }//if + return fragmentId; +} + + +template class Vector<Ndb_cluster_connection_impl::Node>; diff --git a/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp b/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp new file mode 100644 index 00000000000..620eac296a3 --- /dev/null +++ b/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp @@ -0,0 +1,100 @@ +/* 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 CLUSTER_CONNECTION_IMPL_HPP +#define CLUSTER_CONNECTION_IMPL_HPP + +#include <ndb_cluster_connection.hpp> +#include <Vector.hpp> + +class TransporterFacade; +class ConfigRetriever; +class NdbThread; +class ndb_mgm_configuration; + +struct Ndb_cluster_connection_node_iter { + Ndb_cluster_connection_node_iter() : scan_state(~0), + init_pos(0), + cur_pos(0) {}; + Uint8 scan_state; + Uint8 init_pos; + Uint8 cur_pos; +}; + +extern "C" { + void* run_ndb_cluster_connection_connect_thread(void*); +} + +class Ndb_cluster_connection_impl : public Ndb_cluster_connection +{ + Ndb_cluster_connection_impl(const char *connectstring); + ~Ndb_cluster_connection_impl(); + + void do_test(); + + void init_get_next_node(Ndb_cluster_connection_node_iter &iter); + Uint32 get_next_node(Ndb_cluster_connection_node_iter &iter); + +private: + friend class Ndb; + friend class NdbImpl; + friend void* run_ndb_cluster_connection_connect_thread(void*); + friend class Ndb_cluster_connection; + + /** + * Structure containing values for guessing primary node + */ + struct FragmentToNodeMap { + FragmentToNodeMap(): + fragment2PrimaryNodeMap(0) {}; + Uint32 kValue; + Uint32 hashValueMask; + Uint32 hashpointerValue; + Uint32 noOfFragments; + Uint32 *fragment2PrimaryNodeMap; + + void init(Uint32 noOfNodes, Uint8 nodeIds[]); + void release(); + } fragmentToNodeMap; + + struct Node + { + Node(Uint32 _g= 0, Uint32 _id= 0) : this_group(0), + next_group(0), + group(_g), + id(_id) {}; + Uint32 this_group; + Uint32 next_group; + Uint32 group; + Uint32 id; + }; + + Vector<Node> m_all_nodes; + void init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config); + Uint32 guess_primary_node(const char * keyData, Uint32 keyLen); + + void connect_thread(); + + TransporterFacade *m_transporter_facade; + ConfigRetriever *m_config_retriever; + NdbThread *m_connect_thread; + int (*m_connect_callback)(void); + + int m_optimized_node_selection; +}; + +#endif diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c index 20661b89517..d4ad9cd6f1c 100644 --- a/ndb/src/ndbapi/ndberror.c +++ b/ndb/src/ndbapi/ndberror.c @@ -17,6 +17,7 @@ #include <ndb_global.h> #include <ndberror.h> +#include <m_string.h> typedef struct ErrorBundle { int code; @@ -35,6 +36,7 @@ typedef struct ErrorBundle { #define NE ndberror_cl_none #define AE ndberror_cl_application +#define CE ndberror_cl_configuration #define ND ndberror_cl_no_data_found #define CV ndberror_cl_constraint_violation #define SE ndberror_cl_schema_error @@ -53,8 +55,32 @@ typedef struct ErrorBundle { #define NI ndberror_cl_function_not_implemented #define UE ndberror_cl_unknown_error_code +static const char REDO_BUFFER_MSG[]= +"REDO log buffers overloaded, consult online manual (increase RedoBuffer, and|or decrease TimeBetweenLocalCheckpoints, and|or increase NoOfFragmentLogFiles)"; + static const char* empty_string = ""; +/* + * Error code ranges are reserved for respective block + * + * 200 - TC + * 300 - DIH + * 400 - LQH + * 600 - ACC + * 700 - DICT + * 800 - TUP + * 1200 - LQH + * 1300 - BACKUP + * 4000 - API + * 4100 - "" + * 4200 - "" + * 4300 - "" + * 4400 - "" + * 4500 - "" + * 4600 - "" + * 5000 - Management server + */ + static const ErrorBundle ErrorCodes[] = { @@ -124,7 +150,8 @@ ErrorBundle ErrorCodes[] = { { 217, TR, "217" }, { 218, TR, "218" }, { 219, TR, "219" }, - { 233, TR, "Out of operation records in transaction coordinator" }, + { 233, TR, + "Out of operation records in transaction coordinator (increase MaxNoOfConcurrentOperations)" }, { 275, TR, "275" }, { 279, TR, "Out of transaction markers in transaction coordinator" }, { 414, TR, "414" }, @@ -136,9 +163,8 @@ ErrorBundle ErrorCodes[] = { { 805, TR, "Out of attrinfo records in tuple manager" }, { 830, TR, "Out of add fragment operation records" }, { 873, TR, "Out of attrinfo records for scan in tuple manager" }, - { 1217, TR, "1217" }, - { 1219, TR, "Out of operation records in local data manager" }, - { 1220, TR, "1220" }, + { 1217, TR, "Out of operation records in local data manager (increase MaxNoOfLocalOperations)" }, + { 1220, TR, REDO_BUFFER_MSG }, { 1222, TR, "Out of transaction markers in LQH" }, { 4021, TR, "Out of Send Buffer space in NDB API" }, { 4022, TR, "Out of Send Buffer space in NDB API" }, @@ -149,9 +175,10 @@ ErrorBundle ErrorCodes[] = { */ { 623, IS, "623" }, { 624, IS, "624" }, - { 625, IS, "Out of memory in Ndb Kernel, index part" }, - { 826, IS, "826" }, - { 827, IS, "Out of memory in Ndb Kernel, data part" }, + { 625, IS, "Out of memory in Ndb Kernel, index part (increase IndexMemory)" }, + { 800, IS, "Too many ordered indexes (increase MaxNoOfOrderedIndexes)" }, + { 826, IS, "Too many tables and attributes (increase MaxNoOfAttributes or MaxNoOfTables)" }, + { 827, IS, "Out of memory in Ndb Kernel, data part (increase DataMemory)" }, { 832, IS, "832" }, /** @@ -163,15 +190,14 @@ ErrorBundle ErrorCodes[] = { { 297, TO, "Time-out in NDB, probably caused by deadlock" }, /* Scan trans timeout, temporary!! */ { 237, TO, "Transaction had timed out when trying to commit it" }, - /** * OverloadError */ - { 410, OL, "Out of log file space temporarily" }, - { 677, OL, "Index UNDO buffers overloaded" }, - { 891, OL, "Data UNDO buffers overloaded" }, - { 1221, OL, "REDO log buffers overloaded" }, - { 4006, OL, "Connect failure - out of connection objects" }, + { 410, OL, REDO_BUFFER_MSG }, + { 677, OL, "Index UNDO buffers overloaded (increase UndoIndexBuffer)" }, + { 891, OL, "Data UNDO buffers overloaded (increase UndoDataBuffer)" }, + { 1221, OL, REDO_BUFFER_MSG }, + { 4006, OL, "Connect failure - out of connection objects (increase MaxNoOfConcurrentTransactions)" }, @@ -238,12 +264,13 @@ ErrorBundle ErrorCodes[] = { { 877, AE, "877" }, { 878, AE, "878" }, { 879, AE, "879" }, + { 880, AE, "Tried to read too much - too many getValue calls" }, { 884, AE, "Stack overflow in interpreter" }, { 885, AE, "Stack underflow in interpreter" }, { 886, AE, "More than 65535 instructions executed in interpreter" }, - { 4256, AE, "Must call Ndb::init() before this function" }, - { 880, AE, "Tried to read too much - too many getValue calls" }, - { 4257, AE, "Tried to read too much - too many getValue calls" }, + { 897, AE, "Update attempt of primary key via ndbcluster internal api (if this occurs via the MySQL server it is a bug, please report)" }, + { 4256, AE, "Must call Ndb::init() before this function" }, + { 4257, AE, "Tried to read too much - too many getValue calls" }, /** * Scan application errors @@ -288,7 +315,7 @@ ErrorBundle ErrorCodes[] = { { 283, SE, "Table is being dropped" }, { 284, SE, "Table not defined in transaction coordinator" }, { 285, SE, "Unknown table error in transaction coordinator" }, - { 881, SE, "Unable to create table, out of data pages" }, + { 881, SE, "Unable to create table, out of data pages (increase DataMemory) " }, { 1225, SE, "Table not defined in local query handler" }, { 1226, SE, "Table is being dropped" }, { 1228, SE, "Cannot use drop table for drop index" }, @@ -300,6 +327,36 @@ ErrorBundle ErrorCodes[] = { { 4003, NI, "Function not implemented yet" }, /** + * Backup error codes + */ + + { 1300, IE, "Undefined error" }, + { 1301, IE, "Backup issued to not master (reissue command to master)" }, + { 1302, IE, "Out of backup record" }, + { 1303, IS, "Out of resources" }, + { 1304, IE, "Sequence failure" }, + { 1305, IE, "Backup definition not implemented" }, + { 1306, AE, "Backup not supported in diskless mode (change Diskless)" }, + + { 1321, IE, "Backup aborted by application" }, + { 1322, IE, "Backup already completed" }, + { 1323, IE, "1323" }, + { 1324, IE, "Backup log buffer full" }, + { 1325, IE, "File or scan error" }, + { 1326, IE, "Backup abortet due to node failure" }, + { 1327, IE, "1327" }, + + { 1340, IE, "Backup undefined error" }, + { 1342, AE, "Backup failed to allocate buffers (check configuration)" }, + { 1343, AE, "Backup failed to setup fs buffers (check configuration)" }, + { 1344, AE, "Backup failed to allocate tables (check configuration)" }, + { 1345, AE, "Backup failed to insert file header (check configuration)" }, + { 1346, AE, "Backup failed to insert table list (check configuration)" }, + { 1347, AE, "Backup failed to allocate table memory (check configuration)" }, + { 1348, AE, "Backup failed to allocate file record (check configuration)" }, + { 1349, AE, "Backup failed to allocate attribute record (check configuration)" }, + + /** * Still uncategorized */ { 720, AE, "Attribute name reused in table definition" }, @@ -344,17 +401,11 @@ ErrorBundle ErrorCodes[] = { { 4327, AE, "Distribution Group with 1 byte attribute is not allowed" }, { 4328, AE, "Disk memory attributes not yet supported" }, { 4329, AE, "Variable stored attributes not yet supported" }, - { 4330, AE, "Table names limited to 127 bytes" }, - { 4331, AE, "Attribute names limited to 31 bytes" }, - { 4332, AE, "Maximum 2000 attributes in a table" }, - { 4333, AE, "Maximum 4092 bytes long keys allowed" }, - { 4334, AE, "Attribute properties length limited to 127 bytes" }, { 4400, AE, "Status Error in NdbSchemaCon" }, { 4401, AE, "Only one schema operation per schema transaction" }, { 4402, AE, "No schema operation defined before calling execute" }, - { 4500, AE, "Cannot handle more than 2048 tables in NdbApi" }, { 4501, AE, "Insert in hash table failed when getting table information from Ndb" }, { 4502, AE, "GetValue not allowed in Update operation" }, { 4503, AE, "GetValue not allowed in Insert operation" }, @@ -429,7 +480,8 @@ ErrorBundle ErrorCodes[] = { { 4267, IE, "Corrupted blob value" }, { 4268, IE, "Error in blob head update forced rollback of transaction" }, { 4268, IE, "Unknown blob error" }, - { 4269, IE, "No connection to ndb management server" } + { 4269, IE, "No connection to ndb management server" }, + { 4335, AE, "Only one autoincrement column allowed per table. Having a table without primary key uses an autoincremented hidden key, i.e. a table without a primary key can not have an autoincremented column" } }; static @@ -468,6 +520,7 @@ const ErrorStatusClassification StatusClassificationMapping[] = { { ST_S, NE, "No error"}, { ST_P, AE, "Application error"}, + { ST_P, CE, "Configuration or application error"}, { ST_P, ND, "No data found"}, { ST_P, CV, "Constraint violation"}, { ST_P, SE, "Schema error"}, @@ -594,10 +647,10 @@ int ndb_error_string(int err_no, char *str, unsigned int size) ndberror_update(&error); len = - snprintf(str, size-1, "%s: %s: %s", error.message, - ndberror_status_message(error.status), - ndberror_classification_message(error.classification)); + my_snprintf(str, size-1, "%s: %s: %s", error.message, + ndberror_status_message(error.status), + ndberror_classification_message(error.classification)); str[size-1]= '\0'; - + return len; } diff --git a/ndb/test/Makefile.am b/ndb/test/Makefile.am index 2e0f30df9d4..b8753668c60 100644 --- a/ndb/test/Makefile.am +++ b/ndb/test/Makefile.am @@ -4,3 +4,5 @@ EXTRA_DIST = include dist-hook: -rm -rf `find $(distdir) -type d -name SCCS` + +windoze-dsp: diff --git a/ndb/src/mgmclient/CpcClient.hpp b/ndb/test/include/CpcClient.hpp index 1655bc57b56..1655bc57b56 100644 --- a/ndb/src/mgmclient/CpcClient.hpp +++ b/ndb/test/include/CpcClient.hpp diff --git a/ndb/test/include/HugoOperations.hpp b/ndb/test/include/HugoOperations.hpp index fe22e4b5649..a23d3018f47 100644 --- a/ndb/test/include/HugoOperations.hpp +++ b/ndb/test/include/HugoOperations.hpp @@ -30,6 +30,8 @@ public: int closeTransaction(Ndb*); NdbConnection* getTransaction(); void refresh(); + + void setTransactionId(Uint64); int pkInsertRecord(Ndb*, int recordNo, @@ -98,7 +100,7 @@ protected: struct RsPair { NdbResultSet* m_result_set; int records; }; Vector<RsPair> m_result_sets; Vector<RsPair> m_executed_result_sets; -private: + NdbConnection* pTrans; }; diff --git a/ndb/test/include/HugoTransactions.hpp b/ndb/test/include/HugoTransactions.hpp index 19e4cb43336..b833f2ac629 100644 --- a/ndb/test/include/HugoTransactions.hpp +++ b/ndb/test/include/HugoTransactions.hpp @@ -36,15 +36,21 @@ public: bool allowConstraintViolation = true, int doSleep = 0, bool oneTrans = false); + int scanReadRecords(Ndb*, int records, int abort = 0, int parallelism = 0, - bool committed = false); - int scanReadCommittedRecords(Ndb*, - int records, - int abort = 0, - int parallelism = 0); + NdbOperation::LockMode = NdbOperation::LM_Read); + + int scanReadRecords(Ndb*, + const NdbDictionary::Index*, + int records, + int abort = 0, + int parallelism = 0, + NdbOperation::LockMode = NdbOperation::LM_Read, + bool sorted = false); + int pkReadRecords(Ndb*, int records, int batchsize = 1, diff --git a/ndb/test/include/NDBT_Test.hpp b/ndb/test/include/NDBT_Test.hpp index b0b5fe15960..a60228c1a5d 100644 --- a/ndb/test/include/NDBT_Test.hpp +++ b/ndb/test/include/NDBT_Test.hpp @@ -188,7 +188,7 @@ public: NDBT_TestCase(NDBT_TestSuite* psuite, const char* name, const char* comment); - virtual ~NDBT_TestCase(){} + virtual ~NDBT_TestCase() {} // This is the default executor of a test case // When a test case is executed it will need to be suplied with a number of @@ -225,6 +225,8 @@ protected: void stopTimer(NDBT_Context*); void printTimer(NDBT_Context*); + BaseString _name; + BaseString _comment; const char* name; const char* comment; NDBT_TestSuite* suite; @@ -392,10 +394,10 @@ C##suitname():NDBT_TestSuite(#suitname){ \ // Add a number of equal steps to the testcase #define STEPS(stepfunc, num) \ - for (int i = 0; i < num; i++){ \ + { int i; for (i = 0; i < num; i++){ \ pts = new NDBT_ParallelStep(pt, #stepfunc, stepfunc); \ pt->addStep(pts);\ - } + } } #define VERIFIER(stepfunc) \ ptv = new NDBT_Verifier(pt, #stepfunc, stepfunc); \ diff --git a/ndb/test/include/NdbRestarter.hpp b/ndb/test/include/NdbRestarter.hpp index 114726f6a2b..19a88b4f8ad 100644 --- a/ndb/test/include/NdbRestarter.hpp +++ b/ndb/test/include/NdbRestarter.hpp @@ -87,8 +87,6 @@ protected: bool connected; BaseString addr; - BaseString host; - int port; NdbMgmHandle handle; ndb_mgm_configuration * m_config; protected: diff --git a/ndb/test/include/NdbSchemaOp.hpp b/ndb/test/include/NdbSchemaOp.hpp index 43f76c8c253..e8ab542b00a 100644 --- a/ndb/test/include/NdbSchemaOp.hpp +++ b/ndb/test/include/NdbSchemaOp.hpp @@ -303,6 +303,7 @@ public: * * @deprecated do not use! */ +#ifndef NDB_WIN32 inline int createTable( const char* aTableName, Uint32 aTableSize, KeyType aTupleKey, @@ -324,6 +325,7 @@ public: aMemoryType, (aStoredTable == 1 ? true : false)); } +#endif /** * Add a new attribute to a database table. @@ -565,7 +567,8 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type) case NdbDictionary::Column::Unsigned: return UnSigned; case NdbDictionary::Column::Float: - case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Olddecimal: + case NdbDictionary::Column::Olddecimalunsigned: case NdbDictionary::Column::Double: return Float; case NdbDictionary::Column::Char: @@ -573,9 +576,6 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type) case NdbDictionary::Column::Binary: case NdbDictionary::Column::Varbinary: return String; - case NdbDictionary::Column::Datetime: - case NdbDictionary::Column::Timespec: - case NdbDictionary::Column::Undefined: default: return NoAttrTypeDef; } diff --git a/ndb/test/include/UtilTransactions.hpp b/ndb/test/include/UtilTransactions.hpp index 37cd99550a5..23902f3b317 100644 --- a/ndb/test/include/UtilTransactions.hpp +++ b/ndb/test/include/UtilTransactions.hpp @@ -53,11 +53,11 @@ public: int selectCount(Ndb*, int parallelism = 0, int* count_rows = NULL, - ScanLock lock = SL_Read, + NdbOperation::LockMode lm = NdbOperation::LM_CommittedRead, NdbConnection* pTrans = NULL); int scanReadRecords(Ndb*, int parallelism, - bool exclusive, + NdbOperation::LockMode lm, int records, int noAttribs, int* attrib_list, diff --git a/ndb/include/util/getarg.h b/ndb/test/include/getarg.h index 03ed25f6828..03ed25f6828 100644 --- a/ndb/include/util/getarg.h +++ b/ndb/test/include/getarg.h diff --git a/ndb/test/ndbapi/Makefile.am b/ndb/test/ndbapi/Makefile.am index 787589dd9b6..0c84db8c068 100644 --- a/ndb/test/ndbapi/Makefile.am +++ b/ndb/test/ndbapi/Makefile.am @@ -30,7 +30,8 @@ testSystemRestart \ testTimeout \ testTransactions \ testDeadlock \ -test_event ndbapi_slow_select testReadPerf testLcp +test_event ndbapi_slow_select testReadPerf testLcp \ +DbCreate DbAsyncGenerator #flexTimedAsynch #testBlobs @@ -69,6 +70,8 @@ test_event_SOURCES = test_event.cpp ndbapi_slow_select_SOURCES = slow_select.cpp testReadPerf_SOURCES = testReadPerf.cpp testLcp_SOURCES = testLcp.cpp +DbCreate_SOURCES= bench/mainPopulate.cpp bench/dbPopulate.cpp bench/userInterface.cpp +DbAsyncGenerator_SOURCES= bench/mainAsyncGenerator.cpp bench/asyncGenerator.cpp bench/ndb_async2.cpp INCLUDES_LOC = -I$(top_srcdir)/ndb/include/kernel @@ -84,4 +87,65 @@ testBackup_LDADD = $(LDADD) bank/libbank.a # Don't update the files from bitkeeper %::SCCS/s.% +windoze-dsp: flexBench.dsp testBasic.dsp testBlobs.dsp \ + testScan.dsp +flexBench.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ flexBench + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(flexBench_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +testBasic.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ testBasic + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(testBasic_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +testOIBasic.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ testOIBasic + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(testOIBasic_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +testBlobs.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ testBlobs + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(testBlobs_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +testScan.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ testScan + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(testScan_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) diff --git a/ndb/test/ndbapi/Makefile_old b/ndb/test/ndbapi/Makefile_old deleted file mode 100644 index c3198096ec0..00000000000 --- a/ndb/test/ndbapi/Makefile_old +++ /dev/null @@ -1,49 +0,0 @@ -include .defs.mk - - -ifeq ($(NDB_OS), OSE) -DIRS = basic flexBench flexAsynch -else -DIRS = lmc-bench ronja -BIN_DIRS = \ - flexAsynch \ - flexBench \ - flexHammer \ - flexTT \ - create_tab \ - create_all_tabs \ - drop_all_tabs \ - bulk_copy \ - restarter2 restarter \ - restarts testScan testNdbApi \ - testScanInterpreter testIndex \ - testInterpreter \ - testOIBasic \ - testBackup \ - testBasic \ - basicAsynch \ - testNodeRestart \ - testOperations testTransactions \ - testSystemRestart \ - testTimeout \ - testMgm \ - testRestartGci \ - testDataBuffers \ - testDict \ - acid \ - telco \ - indexTest \ - test_event \ - indexTest2 \ - testGrep \ - testBlobs - -ifeq ($(NDB_OS), SOLARIS) -ifeq ($(NDB_COMPILER), FORTE6) - DIRS += flexTimedAsynch -endif -endif -endif - -include ${NDB_TOP}/Epilogue.mk - diff --git a/ndb/test/ndbapi/ScanFunctions.hpp b/ndb/test/ndbapi/ScanFunctions.hpp index 2ff4b751c33..6964f8c73a8 100644 --- a/ndb/test/ndbapi/ScanFunctions.hpp +++ b/ndb/test/ndbapi/ScanFunctions.hpp @@ -286,36 +286,36 @@ void AttribList::buildAttribList(const NdbDictionary::Table* pTab){ attr = new Attrib; attr->numAttribs = 0; attriblist.push_back(attr); - - for(int i = 1; i < pTab->getNoOfColumns(); i++){ + int i; + for(i = 1; i < pTab->getNoOfColumns(); i++){ attr = new Attrib; attr->numAttribs = i; for(int a = 0; a<i; a++) attr->attribs[a] = a; attriblist.push_back(attr); } - for(int i = pTab->getNoOfColumns()-1; i > 0; i--){ + for(i = pTab->getNoOfColumns()-1; i > 0; i--){ attr = new Attrib; attr->numAttribs = i; for(int a = 0; a<i; a++) attr->attribs[a] = a; attriblist.push_back(attr); } - for(int i = pTab->getNoOfColumns(); i > 0; i--){ + for(i = pTab->getNoOfColumns(); i > 0; i--){ attr = new Attrib; attr->numAttribs = pTab->getNoOfColumns() - i; for(int a = 0; a<pTab->getNoOfColumns() - i; a++) attr->attribs[a] = pTab->getNoOfColumns()-a-1; attriblist.push_back(attr); } - for(int i = 1; i < pTab->getNoOfColumns(); i++){ + for(i = 1; i < pTab->getNoOfColumns(); i++){ attr = new Attrib; attr->numAttribs = pTab->getNoOfColumns() - i; for(int a = 0; a<pTab->getNoOfColumns() - i; a++) attr->attribs[a] = pTab->getNoOfColumns()-a-1; attriblist.push_back(attr); } - for(int i = 1; i < pTab->getNoOfColumns(); i++){ + for(i = 1; i < pTab->getNoOfColumns(); i++){ attr = new Attrib; attr->numAttribs = 2; for(int a = 0; a<2; a++){ @@ -345,11 +345,11 @@ void AttribList::buildAttribList(const NdbDictionary::Table* pTab){ attriblist.push_back(attr); #if 1 - for(size_t i = 0; i < attriblist.size(); i++){ + for(size_t j = 0; j < attriblist.size(); j++){ - g_info << attriblist[i]->numAttribs << ": " ; - for(int a = 0; a < attriblist[i]->numAttribs; a++) - g_info << attriblist[i]->attribs[a] << ", "; + g_info << attriblist[j]->numAttribs << ": " ; + for(int a = 0; a < attriblist[j]->numAttribs; a++) + g_info << attriblist[j]->attribs[a] << ", "; g_info << endl; } #endif diff --git a/ndb/test/ndbapi/bank/Makefile.am b/ndb/test/ndbapi/bank/Makefile.am index 886d664aefb..d4f82a7f9c4 100644 --- a/ndb/test/ndbapi/bank/Makefile.am +++ b/ndb/test/ndbapi/bank/Makefile.am @@ -20,3 +20,5 @@ include $(top_srcdir)/ndb/config/type_ndbapitest.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: diff --git a/ndb/test/ndbapi/bank/Makefile_old b/ndb/test/ndbapi/bank/Makefile_old deleted file mode 100644 index f710f9e6612..00000000000 --- a/ndb/test/ndbapi/bank/Makefile_old +++ /dev/null @@ -1,12 +0,0 @@ -include .defs.mk - -DIRS = src bankCreator \ - bankSumAccounts \ - bankTransactionMaker \ - bankValidateAllGLs \ - bankMakeGL \ - bankTimer \ - testBank - - -include $(NDB_TOP)/Epilogue.mk diff --git a/ndb/test/ndbapi/bench/asyncGenerator.cpp b/ndb/test/ndbapi/bench/asyncGenerator.cpp new file mode 100644 index 00000000000..d91e38dff1a --- /dev/null +++ b/ndb/test/ndbapi/bench/asyncGenerator.cpp @@ -0,0 +1,571 @@ +/* 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" +#include <NdbApi.hpp> +#include <NdbOut.hpp> +#include <NdbSleep.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(ThreadData * td, + int parallellism, + int millisSendPoll, + int minEventSendPoll, + int forceSendPoll); +static void doTransaction_T1(Ndb * pNDB, ThreadData * td, int async); +static void doTransaction_T2(Ndb * pNDB, ThreadData * td, int async); +static void doTransaction_T3(Ndb * pNDB, ThreadData * td, int async); +static void doTransaction_T4(Ndb * pNDB, ThreadData * td, int async); +static void doTransaction_T5(Ndb * pNDB, ThreadData * td, int async); + +/*************************************************************** +* 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->count = 0; + trans->branchExecuted = 0; + trans->rollbackExecuted = 0; + trans->latencyCounter = myRandom48(127); + trans->latency.reset(); +} + +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 ) { + ndbout_c("could not set the transaction types"); + exit(0); + } + + if( initSequence(&gen->rollbackSequenceT4, + rollbackDefinition) != 0 ) { + ndbout_c("could not set the rollback sequence"); + exit(0); + } + + if( initSequence(&gen->rollbackSequenceT5, + rollbackDefinition) != 0 ) { + ndbout_c("could not set the rollback sequence"); + 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(ThreadData * td, int p, int millis, int minEvents, int force) +{ + int i; + unsigned int transactionType; + int async = 1; + if (p == 1) { + async = 0; + }//if + for(i = 0; i<p; i++){ + if(td[i].runState == Runnable){ + transactionType = getNextRandom(&td[i].generator.transactionSequence); + + switch(transactionType) { + case 1: + doTransaction_T1(td[i].pNDB, &td[i], async); + break; + case 2: + doTransaction_T2(td[i].pNDB, &td[i], async); + break; + case 3: + doTransaction_T3(td[i].pNDB, &td[i], async); + break; + case 4: + doTransaction_T4(td[i].pNDB, &td[i], async); + break; + case 5: + doTransaction_T5(td[i].pNDB, &td[i], async); + break; + default: + ndbout_c("Unknown transaction type: %d", transactionType); + } + } + } + if (async == 1) { + td[0].pNDB->sendPollNdb(millis, minEvents, force); + }//if +} + +static +void +doTransaction_T1(Ndb * pNDB, ThreadData * td, int async) +{ + /*----------------*/ + /* Init arguments */ + /*----------------*/ + getRandomSubscriberNumber(td->transactionData.number); + getRandomChangedBy(td->transactionData.changed_by); + BaseString::snprintf(td->transactionData.changed_time, + sizeof(td->transactionData.changed_time), + "%ld - %d", td->changedTime++, myRandom48(65536*1024)); + //getRandomChangedTime(td->transactionData.changed_time); + td->transactionData.location = td->transactionData.changed_by[0]; + + /*-----------------*/ + /* Run transaction */ + /*-----------------*/ + td->runState = Running; + td->generator.transactions[0].startLatency(); + + start_T1(pNDB, td, async); +} + +static +void +doTransaction_T2(Ndb * pNDB, ThreadData * td, int async) +{ + /*----------------*/ + /* Init arguments */ + /*----------------*/ + getRandomSubscriberNumber(td->transactionData.number); + + /*-----------------*/ + /* Run transaction */ + /*-----------------*/ + td->runState = Running; + td->generator.transactions[1].startLatency(); + + start_T2(pNDB, td, async); +} + +static +void +doTransaction_T3(Ndb * pNDB, ThreadData * td, int async) +{ + SessionElement *se; + + /*----------------*/ + /* Init arguments */ + /*----------------*/ + se = getNextSession(&td->generator.activeSessions); + if( se ) { + strcpy(td->transactionData.number, se->subscriberNumber); + td->transactionData.server_id = se->serverId; + td->transactionData.sessionElement = 1; + } else { + getRandomSubscriberNumber(td->transactionData.number); + getRandomServerId(&td->transactionData.server_id); + td->transactionData.sessionElement = 0; + } + + td->transactionData.server_bit = (1 << td->transactionData.server_id); + + /*-----------------*/ + /* Run transaction */ + /*-----------------*/ + td->runState = Running; + td->generator.transactions[2].startLatency(); + start_T3(pNDB, td, async); +} + +static +void +doTransaction_T4(Ndb * pNDB, ThreadData * td, int async) +{ + /*----------------*/ + /* Init arguments */ + /*----------------*/ + getRandomSubscriberNumber(td->transactionData.number); + getRandomServerId(&td->transactionData.server_id); + + td->transactionData.server_bit = (1 << td->transactionData.server_id); + td->transactionData.do_rollback = + getNextRandom(&td->generator.rollbackSequenceT4); + +#if 0 + memset(td->transactionData.session_details, + myRandom48(26)+'A', SESSION_DETAILS_LENGTH); +#endif + td->transactionData.session_details[SESSION_DETAILS_LENGTH] = 0; + + /*-----------------*/ + /* Run transaction */ + /*-----------------*/ + td->runState = Running; + td->generator.transactions[3].startLatency(); + start_T4(pNDB, td, async); +} + +static +void +doTransaction_T5(Ndb * pNDB, ThreadData * td, int async) +{ + SessionElement * se; + se = getNextSession(&td->generator.activeSessions); + if( se ) { + strcpy(td->transactionData.number, se->subscriberNumber); + td->transactionData.server_id = se->serverId; + td->transactionData.sessionElement = 1; + } + else { + getRandomSubscriberNumber(td->transactionData.number); + getRandomServerId(&td->transactionData.server_id); + td->transactionData.sessionElement = 0; + } + + td->transactionData.server_bit = (1 << td->transactionData.server_id); + td->transactionData.do_rollback + = getNextRandom(&td->generator.rollbackSequenceT5); + + /*-----------------*/ + /* Run transaction */ + /*-----------------*/ + td->runState = Running; + td->generator.transactions[4].startLatency(); + start_T5(pNDB, td, async); +} + +void +complete_T1(ThreadData * data){ + data->generator.transactions[0].stopLatency(); + data->generator.transactions[0].count++; + + data->runState = Runnable; + data->generator.totalTransactions++; +} + +void +complete_T2(ThreadData * data){ + data->generator.transactions[1].stopLatency(); + data->generator.transactions[1].count++; + + data->runState = Runnable; + data->generator.totalTransactions++; +} + +void +complete_T3(ThreadData * data){ + + data->generator.transactions[2].stopLatency(); + data->generator.transactions[2].count++; + + if(data->transactionData.branchExecuted) + data->generator.transactions[2].branchExecuted++; + + data->runState = Runnable; + data->generator.totalTransactions++; +} + +void +complete_T4(ThreadData * data){ + + data->generator.transactions[3].stopLatency(); + data->generator.transactions[3].count++; + + if(data->transactionData.branchExecuted) + data->generator.transactions[3].branchExecuted++; + if(data->transactionData.do_rollback) + data->generator.transactions[3].rollbackExecuted++; + + if(data->transactionData.branchExecuted && + !data->transactionData.do_rollback){ + insertSession(&data->generator.activeSessions, + data->transactionData.number, + data->transactionData.server_id); + } + + data->runState = Runnable; + data->generator.totalTransactions++; + +} +void +complete_T5(ThreadData * data){ + + data->generator.transactions[4].stopLatency(); + data->generator.transactions[4].count++; + + if(data->transactionData.branchExecuted) + data->generator.transactions[4].branchExecuted++; + if(data->transactionData.do_rollback) + data->generator.transactions[4].rollbackExecuted++; + + if(data->transactionData.sessionElement && + !data->transactionData.do_rollback){ + deleteSession(&data->generator.activeSessions); + } + + data->runState = Runnable; + data->generator.totalTransactions++; +} + +/*************************************************************** +**************************************************************** +* 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 +asyncGenerator(ThreadData *data, + int parallellism, + int millisSendPoll, + int minEventSendPoll, + int forceSendPoll) +{ + ThreadData * startUp; + + GeneratorStatistics *st; + double periodStop; + double benchTimeStart; + double benchTimeEnd; + int i, j, done; + + myRandom48Init(data->randomSeed); + + for(i = 0; i<parallellism; i++){ + initGeneratorStatistics(&data[i].generator); + } + + startUp = (ThreadData*)malloc(parallellism * sizeof(ThreadData)); + memcpy(startUp, data, (parallellism * sizeof(ThreadData))); + + /*----------------*/ + /* warm up period */ + /*----------------*/ + periodStop = userGetTime() + (double)data[0].warmUpSeconds; + + while(userGetTime() < periodStop){ + doOneTransaction(startUp, parallellism, + millisSendPoll, minEventSendPoll, forceSendPoll); + } + + ndbout_c("Waiting for startup to finish"); + + /** + * Wait for all transactions + */ + done = 0; + while(!done){ + done = 1; + for(i = 0; i<parallellism; i++){ + if(startUp[i].runState != Runnable){ + done = 0; + break; + } + } + if(!done){ + startUp[0].pNDB->sendPollNdb(); + } + } + ndbout_c("Benchmark period starts"); + + /*-------------------------*/ + /* normal benchmark period */ + /*-------------------------*/ + benchTimeStart = userGetTime(); + + periodStop = benchTimeStart + (double)data[0].testSeconds; + while(userGetTime() < periodStop) + doOneTransaction(data, parallellism, + millisSendPoll, minEventSendPoll, forceSendPoll); + + benchTimeEnd = userGetTime(); + + ndbout_c("Benchmark period done"); + + /** + * Wait for all transactions + */ + done = 0; + while(!done){ + done = 1; + for(i = 0; i<parallellism; i++){ + if(data[i].runState != Runnable){ + done = 0; + break; + } + } + if(!done){ + data[0].pNDB->sendPollNdb(); + } + } + + /*------------------*/ + /* cool down period */ + /*------------------*/ + periodStop = userGetTime() + (double)data[0].coolDownSeconds; + while(userGetTime() < periodStop){ + doOneTransaction(startUp, parallellism, + millisSendPoll, minEventSendPoll, forceSendPoll); + } + + done = 0; + while(!done){ + done = 1; + for(i = 0; i<parallellism; i++){ + if(startUp[i].runState != Runnable){ + done = 0; + break; + } + } + if(!done){ + startUp[0].pNDB->sendPollNdb(); + } + } + + + /*---------------------------------------------------------*/ + /* add the times for all transaction for inner loop timing */ + /*---------------------------------------------------------*/ + for(j = 0; j<parallellism; j++){ + st = &data[j].generator; + + st->outerLoopTime = benchTimeEnd - benchTimeStart; + st->outerTps = getTps(st->totalTransactions, st->outerLoopTime); + } + /* ndbout_c("maxsize = %d\n",maxsize); */ + + free(startUp); +} + diff --git a/ndb/test/ndbapi/bench/dbGenerator.h b/ndb/test/ndbapi/bench/dbGenerator.h new file mode 100644 index 00000000000..2256498e151 --- /dev/null +++ b/ndb/test/ndbapi/bench/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/ndb/test/ndbapi/bench/dbPopulate.cpp b/ndb/test/ndbapi/bench/dbPopulate.cpp new file mode 100644 index 00000000000..42fbb52f3b2 --- /dev/null +++ b/ndb/test/ndbapi/bench/dbPopulate.cpp @@ -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/ndb/test/ndbapi/bench/dbPopulate.h b/ndb/test/ndbapi/bench/dbPopulate.h new file mode 100644 index 00000000000..1916720e141 --- /dev/null +++ b/ndb/test/ndbapi/bench/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/ndb/test/ndbapi/bench/macros.h b/ndb/test/ndbapi/bench/macros.h new file mode 100644 index 00000000000..22b7f564490 --- /dev/null +++ b/ndb/test/ndbapi/bench/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/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp b/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp new file mode 100644 index 00000000000..828b924582f --- /dev/null +++ b/ndb/test/ndbapi/bench/mainAsyncGenerator.cpp @@ -0,0 +1,503 @@ +/* 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 <NdbOut.hpp> +#include <NdbEnv.h> +#include <NdbTest.hpp> + +#include "userInterface.h" +#include "dbGenerator.h" + +static int numProcesses; +static int numSeconds; +static int numWarmSeconds; +static int parallellism; +static int millisSendPoll; +static int minEventSendPoll; +static int forceSendPoll; + +static ThreadData *data; +static Ndb_cluster_connection *g_cluster_connection= 0; + + +static void usage(const char *prog) +{ + const char *progname; + + /*--------------------------------------------*/ + /* Get the name of the program (without path) */ + /*--------------------------------------------*/ + progname = strrchr(prog, '/'); + + if (progname == 0) + progname = prog; + else + ++progname; + + ndbout_c( + "Usage: %s [-proc <num>] [-warm <num>] [-time <num>] [ -p <num>] " + "[-t <num> ] [ -e <num> ] [ -f <num>] \n" + " -proc <num> Specifies that <num> is the number of\n" + " threads. The default is 1.\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" + " -p <num> The no of parallell transactions started by " + "one thread\n" + " -e <num> Minimum no of events before wake up in call to " + "sendPoll\n" + " Default is 1\n" + " -f <num> force parameter to sendPoll\n" + " Default is 0\n", + progname); +} + +static +int +parse_args(int argc, const char **argv) +{ + int i; + + numProcesses = 1; + numSeconds = 10; + numWarmSeconds = 10; + parallellism = 1; + millisSendPoll = 10000; + minEventSendPoll = 1; + forceSendPoll = 0; + + + i = 1; + while (i < argc){ + if (strcmp("-proc",argv[i]) == 0) { + if (i + 1 >= argc) { + return 1; + } + if (sscanf(argv[i+1], "%d", &numProcesses) == -1 || + numProcesses <= 0 || numProcesses > 127) { + ndbout_c("-proc flag requires a positive integer argument [1..127]"); + return 1; + } + i += 2; + } else if (strcmp("-p", argv[i]) == 0){ + if(i + 1 >= argc){ + usage(argv[0]); + return 1; + } + if (sscanf(argv[i+1], "%d", ¶llellism) == -1 || + parallellism <= 0){ + ndbout_c("-p flag requires a positive integer argument"); + return 1; + } + i += 2; + } + else if (strcmp("-time",argv[i]) == 0) { + if (i + 1 >= argc) { + return 1; + } + if (sscanf(argv[i+1], "%d", &numSeconds) == -1 || + numSeconds < 0) { + ndbout_c("-time flag requires a positive integer argument"); + return 1; + } + i += 2; + } + else if (strcmp("-warm",argv[i]) == 0) { + if (i + 1 >= argc) { + return 1; + } + if (sscanf(argv[i+1], "%d", &numWarmSeconds) == -1 || + numWarmSeconds < 0) { + ndbout_c("-warm flag requires a positive integer argument"); + return 1; + } + i += 2; + } + else if (strcmp("-e",argv[i]) == 0) { + if (i + 1 >= argc) { + return 1; + } + if (sscanf(argv[i+1], "%d", &minEventSendPoll) == -1 || + minEventSendPoll < 0) { + ndbout_c("-e flag requires a positive integer argument"); + return 1; + } + i += 2; + } + else if (strcmp("-f",argv[i]) == 0) { + if (i + 1 >= argc) { + usage(argv[0]); + return 1; + } + if (sscanf(argv[i+1], "%d", &forceSendPoll) == -1 || + forceSendPoll < 0) { + ndbout_c("-f flag requires a positive integer argument"); + return 1; + } + i += 2; + } + else { + return 1; + } + } + + if(minEventSendPoll > parallellism){ + ndbout_c("minEventSendPoll(%d) > parallellism(%d)", + minEventSendPoll, parallellism); + ndbout_c("not very good..."); + ndbout_c("very bad..."); + ndbout_c("exiting..."); + return 1; + } + return 0; +} + +static +void +print_transaction(const char *header, + unsigned long totalCount, + TransactionDefinition *trans, + unsigned int printBranch, + unsigned int printRollback) +{ + double f; + + ndbout_c(" %s: %d (%.2f%%) " + "Latency(ms) avg: %d min: %d max: %d std: %d n: %d", + header, + trans->count, + (double)trans->count / (double)totalCount * 100.0, + (int)trans->latency.getMean(), + (int)trans->latency.getMin(), + (int)trans->latency.getMax(), + (int)trans->latency.getStddev(), + (int)trans->latency.getCount() + ); + + if( printBranch ){ + if( trans->count == 0 ) + f = 0.0; + else + f = (double)trans->branchExecuted / (double)trans->count * 100.0; + ndbout_c(" Branches Executed: %d (%.2f%%)", trans->branchExecuted, f); + } + + if( printRollback ){ + if( trans->count == 0 ) + f = 0.0; + else + f = (double)trans->rollbackExecuted / (double)trans->count * 100.0; + ndbout_c(" Rollback Executed: %d (%.2f%%)",trans->rollbackExecuted,f); + } +} + +void +print_stats(const char *title, + unsigned int length, + unsigned int transactionFlag, + GeneratorStatistics *gen, + int numProc, int parallellism) +{ + int i; + char buf[10]; + char name[MAXHOSTNAMELEN]; + + name[0] = 0; + NdbHost_GetHostName(name); + + ndbout_c("\n------ %s ------",title); + ndbout_c("Length : %d %s", + length, + transactionFlag ? "Transactions" : "sec"); + ndbout_c("Processor : %s", name); + ndbout_c("Number of Proc: %d",numProc); + ndbout_c("Parallellism : %d", parallellism); + ndbout_c("\n"); + + if( gen->totalTransactions == 0 ) { + ndbout_c(" No Transactions for this test"); + } + 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 ); + } + + ndbout_c("\n"); + ndbout_c(" Overall Statistics:"); + ndbout_c(" Transactions: %d", gen->totalTransactions); + ndbout_c(" Outer : %.0f TPS",gen->outerTps); + ndbout_c("\n"); + } +} + +static +void * +threadRoutine(void *arg) +{ + int i; + ThreadData *data = (ThreadData *)arg; + Ndb * pNDB; + + pNDB = asyncDbConnect(parallellism); + /* NdbSleep_MilliSleep(rand() % 10); */ + + for(i = 0; i<parallellism; i++){ + data[i].pNDB = pNDB; + } + millisSendPoll = 30000; + asyncGenerator(data, parallellism, + millisSendPoll, minEventSendPoll, forceSendPoll); + + asyncDbDisconnect(pNDB); + + return NULL; +} + +NDB_COMMAND(DbAsyncGenerator, "DbAsyncGenerator", + "DbAsyncGenerator", "DbAsyncGenerator", 65535) +{ + ndb_init(); + int i; + int j; + int k; + struct NdbThread* pThread = NULL; + GeneratorStatistics stats; + GeneratorStatistics *p; + char threadName[32]; + int rc = NDBT_OK; + void* tmp = NULL; + if(parse_args(argc,argv) != 0){ + usage(argv[0]); + return NDBT_ProgramExit(NDBT_WRONGARGS); + } + + + ndbout_c("\nStarting Test with %d process(es) for %d %s parallellism %d", + numProcesses, + numSeconds, + "sec", + parallellism); + + ndbout_c(" WarmUp/coolDown = %d sec", numWarmSeconds); + + Ndb_cluster_connection con; + if(con.connect(12, 5, 1) != 0) + { + ndbout << "Unable to connect to management server." << endl; + return 0; + } + if (con.wait_until_ready(30,0) < 0) + { + ndbout << "Cluster nodes not ready in 30 seconds." << endl; + return 0; + } + + g_cluster_connection= &con; + data = (ThreadData*)malloc((numProcesses*parallellism)*sizeof(ThreadData)); + + for(i = 0; i < numProcesses; i++) { + for(j = 0; j<parallellism; j++){ + data[i*parallellism+j].warmUpSeconds = numWarmSeconds; + data[i*parallellism+j].testSeconds = numSeconds; + data[i*parallellism+j].coolDownSeconds = numWarmSeconds; + data[i*parallellism+j].randomSeed = + NdbTick_CurrentMillisecond()+i+j; + data[i*parallellism+j].changedTime = 0; + data[i*parallellism+j].runState = Runnable; + } + sprintf(threadName, "AsyncThread[%d]", i); + pThread = NdbThread_Create(threadRoutine, + (void**)&data[i*parallellism], + 65535, + threadName, + NDB_THREAD_PRIO_LOW); + if(pThread != 0 && pThread != NULL){ + (&data[i*parallellism])->pThread = pThread; + } else { + perror("Failed to create thread"); + rc = NDBT_FAILED; + } + } + + showTime(); + + /*--------------------------------*/ + /* Wait for all processes to exit */ + /*--------------------------------*/ + for(i = 0; i < numProcesses; i++) { + NdbThread_WaitFor(data[i*parallellism].pThread, &tmp); + NdbThread_Destroy(&data[i*parallellism].pThread); + } + + ndbout_c("All threads have finished"); + + /*-------------------------------------------*/ + /* Clear all structures for total statistics */ + /*-------------------------------------------*/ + stats.totalTransactions = 0; + stats.outerTps = 0.0; + + for(i = 0; i < NUM_TRANSACTION_TYPES; i++ ) { + stats.transactions[i].count = 0; + stats.transactions[i].branchExecuted = 0; + stats.transactions[i].rollbackExecuted = 0; + stats.transactions[i].latency.reset(); + } + + /*--------------------------------*/ + /* Add the values for all Threads */ + /*--------------------------------*/ + for(i = 0; i < numProcesses; i++) { + for(k = 0; k<parallellism; k++){ + p = &data[i*parallellism+k].generator; + + stats.totalTransactions += p->totalTransactions; + stats.outerTps += p->outerTps; + + for(j = 0; j < NUM_TRANSACTION_TYPES; j++ ) { + stats.transactions[j].count += + p->transactions[j].count; + stats.transactions[j].branchExecuted += + p->transactions[j].branchExecuted; + stats.transactions[j].rollbackExecuted += + p->transactions[j].rollbackExecuted; + stats.transactions[j].latency += + p->transactions[j].latency; + } + } + } + + print_stats("Test Results", + numSeconds, + 0, + &stats, + numProcesses, + parallellism); + + free(data); + + NDBT_ProgramExit(rc); +} +/*************************************************************** +* I N C L U D E D F I L E S * +***************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <time.h> + +#include "ndb_schema.hpp" +#include "ndb_error.hpp" +#include "userInterface.h" +#include <NdbMutex.h> +#include <NdbThread.h> +#include <NdbTick.h> +#include <NdbApi.hpp> +#include <NdbOut.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 * +***************************************************************/ + +#ifndef NDB_WIN32 +#include <unistd.h> +#endif + +Ndb* +asyncDbConnect(int parallellism){ + Ndb * pNDB = new Ndb(g_cluster_connection, "TEST_DB"); + + pNDB->init(parallellism + 1); + + while(pNDB->waitUntilReady() != 0){ + } + + return pNDB; +} + +void +asyncDbDisconnect(Ndb* pNDB) +{ + delete pNDB; +} + +double +userGetTime(void) +{ + static bool initialized = false; + static NDB_TICKS initSecs = 0; + static Uint32 initMicros = 0; + double timeValue = 0; + + if ( !initialized ) { + initialized = true; + 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)micros - (double)initMicros; + + timeValue = s + (us / 1000000.0); + } + return timeValue; +} + +void showTime() +{ + char buf[128]; + struct tm* tm_now; + time_t now; + now = ::time((time_t*)NULL); + tm_now = ::gmtime(&now); + + ::snprintf(buf, 128, + "%d-%.2d-%.2d %.2d:%.2d:%.2d", + tm_now->tm_year + 1900, + tm_now->tm_mon, + tm_now->tm_mday, + tm_now->tm_hour, + tm_now->tm_min, + tm_now->tm_sec); + + ndbout_c("Time: %s", buf); +} + diff --git a/ndb/test/ndbapi/bench/mainPopulate.cpp b/ndb/test/ndbapi/bench/mainPopulate.cpp new file mode 100644 index 00000000000..5ab1a5b015d --- /dev/null +++ b/ndb/test/ndbapi/bench/mainPopulate.cpp @@ -0,0 +1,81 @@ +/* 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 <ndb_opts.h> + +#include "userInterface.h" +#include "dbPopulate.h" +#include <NdbMain.h> +#include <NdbOut.hpp> +#include <random.h> +#include <NDBT.hpp> + +#ifdef __cplusplus +extern "C" { +#endif +int useTableLogging; +#ifdef __cplusplus +} +#endif + + +static void usage() +{ +} + +static +void usage(const char *prog) +{ + + ndbout_c( + "Usage: %s [-l]\n" + " -l Use logging and checkpointing on tables\n", + prog); + + exit(1); +} + +NDB_STD_OPTS_VARS; + +NDB_COMMAND(DbCreate, "DbCreate", "DbCreate", "DbCreate", 16384) +{ + ndb_init(); + int i; + UserHandle *uh; + + useTableLogging = 0; + + for(i = 1; i<argc; i++){ + if(strcmp(argv[i], "-l") == 0){ + useTableLogging = 1; + } else { + usage(argv[0]); + return 0; + } + } + + ndbout_c("Using %s tables", + useTableLogging ? "logging" : "temporary"); + + myRandom48Init(0x3e6f); + + uh = userDbConnect(1, "TEST_DB"); + dbPopulate(uh); + userDbDisconnect(uh); + + return NDBT_ProgramExit(NDBT_OK); +} diff --git a/ndb/test/ndbapi/bench/ndb_async1.cpp b/ndb/test/ndbapi/bench/ndb_async1.cpp new file mode 100644 index 00000000000..2a84f6b2aca --- /dev/null +++ b/ndb/test/ndbapi/bench/ndb_async1.cpp @@ -0,0 +1,647 @@ +/* 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 */ + +//#define DEBUG_ON + +#include "userInterface.h" + +#include "macros.h" +#include "ndb_schema.hpp" +#include "ndb_error.hpp" + +#include <NdbApi.hpp> + +inline +NdbConnection * +startTransaction(Ndb * pNDB, + ServerId inServerId, + const SubscriberNumber inNumber){ + + const int keyDataLenBytes = sizeof(ServerId)+SUBSCRIBER_NUMBER_LENGTH; + const int keyDataLen_64Words = keyDataLenBytes >> 3; + + Uint64 keyDataBuf[keyDataLen_64Words+1]; // The "+1" is for rounding... + + char * keyDataBuf_charP = (char *)&keyDataBuf[0]; + Uint32 * keyDataBuf_wo32P = (Uint32 *)&keyDataBuf[0]; + + // Server Id comes first + keyDataBuf_wo32P[0] = inServerId; + // Then subscriber number + memcpy(&keyDataBuf_charP[sizeof(ServerId)], inNumber, + SUBSCRIBER_NUMBER_LENGTH); + + return pNDB->startTransaction(0, keyDataBuf_charP, keyDataLenBytes); +} + +void T1_Callback(int result, NdbConnection * pCon, void * threadData); +void T2_Callback(int result, NdbConnection * pCon, void * threadData); +void T3_Callback_1(int result, NdbConnection * pCon, void * threadData); +void T3_Callback_2(int result, NdbConnection * pCon, void * threadData); +void T3_Callback_3(int result, NdbConnection * pCon, void * threadData); +void T4_Callback_1(int result, NdbConnection * pCon, void * threadData); +void T4_Callback_2(int result, NdbConnection * pCon, void * threadData); +void T4_Callback_3(int result, NdbConnection * pCon, void * threadData); +void T5_Callback_1(int result, NdbConnection * pCon, void * threadData); +void T5_Callback_2(int result, NdbConnection * pCon, void * threadData); +void T5_Callback_3(int result, NdbConnection * pCon, void * threadData); + +/** + * Transaction 1 - T1 + * + * Update location and changed by/time on a subscriber + * + * Input: + * SubscriberNumber, + * Location, + * ChangedBy, + * ChangedTime + * + * Output: + */ +void +start_T1(Ndb * pNDB, ThreadData * td){ + + DEBUG2("T1(%.*s): - Starting\n", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number); + + int check; + NdbConnection * pCON = pNDB->startTransaction(); + if (pCON != NULL) { + NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE); + if (MyOp != NULL) { + MyOp->updateTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->setValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->setValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->setValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + pCON->executeAsynchPrepare( Commit , T1_Callback, td); + } else { + CHECK_NULL(MyOp, "T1: getNdbOperation", pCON); + }//if + } else { + error_handler("T1-1: startTranscation", + pNDB->getNdbErrorString(), + pNDB->getNdbError()); + }//if +} + +void +T1_Callback(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + + DEBUG2("T1(%.*s): - Completing\n", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number); + + CHECK_MINUS_ONE(result, "T1: Commit", + pCON); + td->pNDB->closeTransaction(pCON); + complete_T1(td); +} + +/** + * Transaction 2 - T2 + * + * Read from Subscriber: + * + * Input: + * SubscriberNumber + * + * Output: + * Location + * Changed by + * Changed Timestamp + * Name + */ +void +start_T2(Ndb * pNDB, ThreadData * td){ + + DEBUG3("T2(%.*s, %p): - Starting\n", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.location); + + int check; + NdbRecAttr * check2; + + NdbConnection * pCON = pNDB->startTransaction(); + if (pCON == NULL) + error_handler("T2-1: startTransaction", + pNDB->getNdbErrorString(), + pNDB->getNdbError()); + + NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOp, "T2: getNdbOperation", + pCON); + + MyOp->readTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + MyOp->getValue(IND_SUBSCRIBER_NAME, + td->transactionData.name); + pCON->executeAsynchPrepare( Commit, T2_Callback, td ); +} + +void +T2_Callback(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + DEBUG3("T2(%.*s, %p): - Completing\n", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.location); + + CHECK_MINUS_ONE(result, "T2: Commit", pCON); + td->pNDB->closeTransaction(pCON); + complete_T2(td); +} + +/** + * Transaction 3 - T3 + * + * Read session details + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * + * Output: + * BranchExecuted + * SessionDetails + * ChangedBy + * ChangedTime + * Location + */ +void +start_T3(Ndb * pNDB, ThreadData * td){ + + DEBUG3("T3(%.*s, %.2d): - Starting\n", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + int check; + NdbRecAttr * check2; + + NdbConnection * pCON = startTransaction(pNDB, + td->transactionData.server_id, + td->transactionData.number); + if (pCON == NULL) + error_handler("T3-1: startTranscation", + pNDB->getNdbErrorString(), + pNDB->getNdbError()); + + NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOp, "T3-1: getNdbOperation", + pCON); + + MyOp->readTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + MyOp->getValue(IND_SUBSCRIBER_GROUP, + (char *)&td->transactionData.group_id); + MyOp->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&td->transactionData.sessions); + pCON->executeAsynchPrepare( NoCommit , T3_Callback_1, td); +} + +void +T3_Callback_1(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + DEBUG3("T3(%.*s, %.2d): - Callback 1\n", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + CHECK_MINUS_ONE(result, "T3-1: NoCommit", pCON); + + NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOp, "T3-2: getNdbOperation", + pCON); + + MyOp->readTuple(); + MyOp->equal(IND_GROUP_ID, + (char*)&td->transactionData.group_id); + MyOp->getValue(IND_GROUP_ALLOW_READ, + (char *)&td->transactionData.permission); + pCON->executeAsynchPrepare( NoCommit, T3_Callback_2, td ); +} + +void +T3_Callback_2(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + + CHECK_MINUS_ONE(result, "T3-2: NoCommit", pCON); + + Uint32 permission = td->transactionData.permission; + Uint32 sessions = td->transactionData.sessions; + Uint32 server_bit = td->transactionData.server_bit; + + if(((permission & server_bit) == server_bit) && + ((sessions & server_bit) == server_bit)){ + + memcpy(td->transactionData.suffix, + &td->transactionData.number + [SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH], + SUBSCRIBER_NUMBER_SUFFIX_LENGTH); + DEBUG5("T3(%.*s, %.2d): - Callback 2 - reading(%.*s)\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + SUBSCRIBER_NUMBER_SUFFIX_LENGTH, + td->transactionData.suffix); + + /* Operation 3 */ + NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOp, "T3-3: getNdbOperation", + pCON); + + MyOp->simpleRead(); + MyOp->equal(IND_SESSION_SUBSCRIBER, + (char*)td->transactionData.number); + MyOp->equal(IND_SESSION_SERVER, + (char*)&td->transactionData.server_id); + MyOp->getValue(IND_SESSION_DATA, + (char *)td->transactionData.session_details); + + /* Operation 4 */ + MyOp = pCON->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOp, "T3-4: getNdbOperation", + pCON); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SERVER_ID, + (char*)&td->transactionData.server_id); + MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)td->transactionData.suffix); + MyOp->incValue(IND_SERVER_READS, (uint32)1); + td->transactionData.branchExecuted = 1; + } else { + DEBUG3("T3(%.*s, %.2d): - Callback 2 - no read\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + td->transactionData.branchExecuted = 0; + } + pCON->executeAsynchPrepare( Commit, T3_Callback_3, td ); +} + +void +T3_Callback_3(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + DEBUG3("T3(%.*s, %.2d): - Completing\n", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + CHECK_MINUS_ONE(result, "T3-3: Commit", pCON); + + td->pNDB->closeTransaction(pCON); + complete_T3(td); +} + +/** + * Transaction 4 - T4 + * + * Create session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * SessionDetails, + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +void +start_T4(Ndb * pNDB, ThreadData * td){ + + DEBUG3("T4(%.*s, %.2d): - Starting\n", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + int check; + NdbRecAttr * check2; + + NdbConnection * pCON = startTransaction(pNDB, + td->transactionData.server_id, + td->transactionData.number); + if (pCON == NULL) + error_handler("T4-1: startTranscation", + pNDB->getNdbErrorString(), + pNDB->getNdbError()); + + NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOp, "T4-1: getNdbOperation", + pCON); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + MyOp->getValue(IND_SUBSCRIBER_GROUP, + (char *)&td->transactionData.group_id); + MyOp->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&td->transactionData.sessions); + MyOp->incValue(IND_SUBSCRIBER_SESSIONS, + (uint32)td->transactionData.server_bit); + pCON->executeAsynchPrepare( NoCommit , T4_Callback_1, td); +} + +void +T4_Callback_1(int result, NdbConnection * pCON, void * threadData){ + CHECK_MINUS_ONE(result, "T4-1: NoCommit", pCON); + ThreadData * td = (ThreadData *)threadData; + + DEBUG3("T4(%.*s, %.2d): - Callback 1\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + + NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOp, "T4-2: getNdbOperation", + pCON); + + MyOp->readTuple(); + MyOp->equal(IND_GROUP_ID, + (char*)&td->transactionData.group_id); + MyOp->getValue(IND_GROUP_ALLOW_INSERT, + (char *)&td->transactionData.permission); + pCON->executeAsynchPrepare( NoCommit , T4_Callback_2, td); +} + +void +T4_Callback_2(int result, NdbConnection * pCON, void * threadData){ + CHECK_MINUS_ONE(result, "T4-2: NoCommit", pCON); + ThreadData * td = (ThreadData *)threadData; + + Uint32 permission = td->transactionData.permission; + Uint32 sessions = td->transactionData.sessions; + Uint32 server_bit = td->transactionData.server_bit; + + if(((permission & server_bit) == server_bit) && + ((sessions & server_bit) == 0)){ + + memcpy(td->transactionData.suffix, + &td->transactionData.number + [SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH], + SUBSCRIBER_NUMBER_SUFFIX_LENGTH); + + DEBUG5("T4(%.*s, %.2d): - Callback 2 - inserting(%.*s)\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + SUBSCRIBER_NUMBER_SUFFIX_LENGTH, + td->transactionData.suffix); + + /* Operation 3 */ + + NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOp, "T4-3: getNdbOperation", + pCON); + + MyOp->insertTuple(); + MyOp->equal(IND_SESSION_SUBSCRIBER, + (char*)td->transactionData.number); + MyOp->equal(IND_SESSION_SERVER, + (char*)&td->transactionData.server_id); + MyOp->setValue(SESSION_DATA, + (char *)td->transactionData.session_details); + /* Operation 4 */ + + /* Operation 5 */ + MyOp = pCON->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOp, "T4-5: getNdbOperation", + pCON); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SERVER_ID, + (char*)&td->transactionData.server_id); + MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)td->transactionData.suffix); + MyOp->incValue(IND_SERVER_INSERTS, (uint32)1); + td->transactionData.branchExecuted = 1; + } else { + td->transactionData.branchExecuted = 0; + DEBUG5("T4(%.*s, %.2d): - Callback 2 - %s %s\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + ((permission & server_bit) ? + "permission - " : "no permission - "), + ((sessions & server_bit) ? + "in session - " : "no in session - ")); + } + + if(!td->transactionData.do_rollback && td->transactionData.branchExecuted){ + pCON->executeAsynchPrepare(Commit, T4_Callback_3, td); + } else { + pCON->executeAsynchPrepare(Rollback, T4_Callback_3, td); + } +} + +void +T4_Callback_3(int result, NdbConnection * pCON, void * threadData){ + CHECK_MINUS_ONE(result, "T4-3: Commit", pCON); + ThreadData * td = (ThreadData *)threadData; + + DEBUG3("T4(%.*s, %.2d): - Completing\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + td->pNDB->closeTransaction(pCON); + complete_T4(td); +} + +/** + * Transaction 5 - T5 + * + * Delete session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +void +start_T5(Ndb * pNDB, ThreadData * td){ + + DEBUG3("T5(%.*s, %.2d): - Starting\n", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + int check; + NdbRecAttr * check2; + + NdbConnection * pCON = pNDB->startTransaction(); + if (pCON == NULL) + error_handler("T5-1: startTranscation", + pNDB->getNdbErrorString(), + pNDB->getNdbError()); + + NdbOperation * MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOp, "T5-1: getNdbOperation", + pCON); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + MyOp->getValue(IND_SUBSCRIBER_GROUP, + (char *)&td->transactionData.group_id); + MyOp->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&td->transactionData.sessions); + MyOp->subValue(IND_SUBSCRIBER_SESSIONS, + (uint32)td->transactionData.server_bit); + pCON->executeAsynchPrepare( NoCommit, T5_Callback_1, td ); +} + +void +T5_Callback_1(int result, NdbConnection * pCON, void * threadData){ + CHECK_MINUS_ONE(result, "T5-1: NoCommit", pCON); + ThreadData * td = (ThreadData *)threadData; + + DEBUG3("T5(%.*s, %.2d): - Callback 1\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOp, "T5-2: getNdbOperation", + pCON); + + MyOp->readTuple(); + MyOp->equal(IND_GROUP_ID, + (char*)&td->transactionData.group_id); + MyOp->getValue(IND_GROUP_ALLOW_DELETE, + (char *)&td->transactionData.permission); + pCON->executeAsynchPrepare( NoCommit, T5_Callback_2, td ); +} + +void +T5_Callback_2(int result, NdbConnection * pCON, void * threadData){ + CHECK_MINUS_ONE(result, "T5-2: NoCommit", pCON); + ThreadData * td = (ThreadData *)threadData; + + Uint32 permission = td->transactionData.permission; + Uint32 sessions = td->transactionData.sessions; + Uint32 server_bit = td->transactionData.server_bit; + + if(((permission & server_bit) == server_bit) && + ((sessions & server_bit) == server_bit)){ + + memcpy(td->transactionData.suffix, + &td->transactionData.number + [SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH], + SUBSCRIBER_NUMBER_SUFFIX_LENGTH); + + DEBUG5("T5(%.*s, %.2d): - Callback 2 - deleting(%.*s)\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + SUBSCRIBER_NUMBER_SUFFIX_LENGTH, + td->transactionData.suffix); + + /* Operation 3 */ + NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOp, "T5-3: getNdbOperation", + pCON); + + MyOp->deleteTuple(); + MyOp->equal(IND_SESSION_SUBSCRIBER, + (char*)td->transactionData.number); + MyOp->equal(IND_SESSION_SERVER, + (char*)&td->transactionData.server_id); + /* Operation 4 */ + + /* Operation 5 */ + MyOp = pCON->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOp, "T5-5: getNdbOperation", + pCON); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SERVER_ID, + (char*)&td->transactionData.server_id); + MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)td->transactionData.suffix); + MyOp->incValue(IND_SERVER_DELETES, (uint32)1); + td->transactionData.branchExecuted = 1; + } else { + td->transactionData.branchExecuted = 0; + + DEBUG5("T5(%.*s, %.2d): - Callback 2 - no delete - %s %s\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + ((permission & server_bit) ? + "permission - " : "no permission - "), + ((sessions & server_bit) ? + "in session - " : "no in session - ")); + } + + if(!td->transactionData.do_rollback && td->transactionData.branchExecuted){ + pCON->executeAsynchPrepare(Commit, T5_Callback_3, td); + } else { + pCON->executeAsynchPrepare(Rollback, T5_Callback_3, td); + } +} + +void +T5_Callback_3(int result, NdbConnection * pCON, void * threadData){ + CHECK_MINUS_ONE(result, "T5-3: Commit", pCON); + ThreadData * td = (ThreadData *)threadData; + + DEBUG3("T5(%.*s, %.2d): - Completing\n", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + td->pNDB->closeTransaction(pCON); + complete_T5(td); +} diff --git a/ndb/test/ndbapi/bench/ndb_async2.cpp b/ndb/test/ndbapi/bench/ndb_async2.cpp new file mode 100644 index 00000000000..31cf1d8310a --- /dev/null +++ b/ndb/test/ndbapi/bench/ndb_async2.cpp @@ -0,0 +1,757 @@ +/* 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 */ + +//#define DEBUG_ON + +#include <string.h> +#include "userInterface.h" + +#include "macros.h" +#include "ndb_schema.hpp" +#include "ndb_error.hpp" +#include <NdbSleep.h> + +#include <NdbApi.hpp> + +void T1_Callback(int result, NdbConnection * pCon, void * threadData); +void T2_Callback(int result, NdbConnection * pCon, void * threadData); +void T3_Callback_1(int result, NdbConnection * pCon, void * threadData); +void T3_Callback_2(int result, NdbConnection * pCon, void * threadData); +void T3_Callback_3(int result, NdbConnection * pCon, void * threadData); +void T4_Callback_1(int result, NdbConnection * pCon, void * threadData); +void T4_Callback_2(int result, NdbConnection * pCon, void * threadData); +void T4_Callback_3(int result, NdbConnection * pCon, void * threadData); +void T5_Callback_1(int result, NdbConnection * pCon, void * threadData); +void T5_Callback_2(int result, NdbConnection * pCon, void * threadData); +void T5_Callback_3(int result, NdbConnection * pCon, void * threadData); + +static int stat_async = 0; + +/** + * Transaction 1 - T1 + * + * Update location and changed by/time on a subscriber + * + * Input: + * SubscriberNumber, + * Location, + * ChangedBy, + * ChangedTime + * + * Output: + */ + +#define SFX_START (SUBSCRIBER_NUMBER_LENGTH - SUBSCRIBER_NUMBER_SUFFIX_LENGTH) + +inline +NdbConnection * +startTransaction(Ndb * pNDB, ThreadData * td){ + return pNDB->startTransaction(); +#ifdef OLD_CODE + return pNDB->startTransactionDGroup (0, + &td->transactionData.number[SFX_START], + 1); +#endif +} + +void +start_T1(Ndb * pNDB, ThreadData * td, int async){ + + DEBUG2("T1(%.*s): - Starting", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number); + + NdbConnection * pCON = 0; + while((pCON = startTransaction(pNDB, td)) == 0){ + CHECK_ALLOWED_ERROR("T1: startTransaction", td, pNDB->getNdbError()); + NdbSleep_MilliSleep(10); + } + + NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE); + if (MyOp != NULL) { + MyOp->updateTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->setValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->setValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->setValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + if (async == 1) { + pCON->executeAsynchPrepare( Commit , T1_Callback, td); + } else { + int result = pCON->execute(Commit); + T1_Callback(result, pCON, (void*)td); + return; + }//if + } else { + CHECK_NULL(MyOp, "T1: getNdbOperation", td, pCON->getNdbError()); + }//if +} + +void +T1_Callback(int result, NdbConnection * pCON, void * threadData) { + ThreadData * td = (ThreadData *)threadData; + + DEBUG2("T1(%.*s): - Completing", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number); + + if (result == -1) { + CHECK_ALLOWED_ERROR("T1: Commit", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T1(td->pNDB, td, stat_async); + return; + }//if + td->pNDB->closeTransaction(pCON); + complete_T1(td); +} + +/** + * Transaction 2 - T2 + * + * Read from Subscriber: + * + * Input: + * SubscriberNumber + * + * Output: + * Location + * Changed by + * Changed Timestamp + * Name + */ +void +start_T2(Ndb * pNDB, ThreadData * td, int async){ + + DEBUG3("T2(%.*s, %d): - Starting", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.location); + + NdbConnection * pCON = 0; + + while((pCON = startTransaction(pNDB, td)) == 0){ + CHECK_ALLOWED_ERROR("T2-1: startTransaction", td, pNDB->getNdbError()); + NdbSleep_MilliSleep(10); + } + + NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOp, "T2: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->readTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + MyOp->getValue(IND_SUBSCRIBER_NAME, + td->transactionData.name); + if (async == 1) { + pCON->executeAsynchPrepare( Commit , T2_Callback, td); + } else { + int result = pCON->execute(Commit); + T2_Callback(result, pCON, (void*)td); + return; + }//if +} + +void +T2_Callback(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + DEBUG3("T2(%.*s, %d): - Completing", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.location); + + if (result == -1) { + CHECK_ALLOWED_ERROR("T2: Commit", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T2(td->pNDB, td, stat_async); + return; + }//if + td->pNDB->closeTransaction(pCON); + complete_T2(td); +} + +/** + * Transaction 3 - T3 + * + * Read session details + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * + * Output: + * BranchExecuted + * SessionDetails + * ChangedBy + * ChangedTime + * Location + */ +void +start_T3(Ndb * pNDB, ThreadData * td, int async){ + + DEBUG3("T3(%.*s, %.2d): - Starting", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + NdbConnection * pCON = 0; + + while((pCON = startTransaction(pNDB, td)) == 0){ + CHECK_ALLOWED_ERROR("T3-1: startTransaction", td, pNDB->getNdbError()); + NdbSleep_MilliSleep(10); + } + + NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOp, "T3-1: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->readTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + MyOp->getValue(IND_SUBSCRIBER_GROUP, + (char *)&td->transactionData.group_id); + MyOp->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&td->transactionData.sessions); + stat_async = async; + if (async == 1) { + pCON->executeAsynchPrepare( NoCommit , T3_Callback_1, td); + } else { + int result = pCON->execute( NoCommit ); + T3_Callback_1(result, pCON, (void*)td); + return; + }//if +} + +void +T3_Callback_1(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + DEBUG3("T3(%.*s, %.2d): - Callback 1", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + if (result == -1) { + CHECK_ALLOWED_ERROR("T3-1: execute", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T3(td->pNDB, td, stat_async); + return; + }//if + + NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOp, "T3-2: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->readTuple(); + MyOp->equal(IND_GROUP_ID, + (char*)&td->transactionData.group_id); + MyOp->getValue(IND_GROUP_ALLOW_READ, + (char *)&td->transactionData.permission); + if (stat_async == 1) { + pCON->executeAsynchPrepare( NoCommit , T3_Callback_2, td); + } else { + int result = pCON->execute( NoCommit ); + T3_Callback_2(result, pCON, (void*)td); + return; + }//if +} + +void +T3_Callback_2(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + + if (result == -1) { + CHECK_ALLOWED_ERROR("T3-2: execute", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T3(td->pNDB, td, stat_async); + return; + }//if + + Uint32 permission = td->transactionData.permission; + Uint32 sessions = td->transactionData.sessions; + Uint32 server_bit = td->transactionData.server_bit; + + if(((permission & server_bit) == server_bit) && + ((sessions & server_bit) == server_bit)){ + + memcpy(td->transactionData.suffix, + &td->transactionData.number[SFX_START], + SUBSCRIBER_NUMBER_SUFFIX_LENGTH); + DEBUG5("T3(%.*s, %.2d): - Callback 2 - reading(%.*s)", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + SUBSCRIBER_NUMBER_SUFFIX_LENGTH, + td->transactionData.suffix); + + /* Operation 3 */ + NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOp, "T3-3: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->simpleRead(); + MyOp->equal(IND_SESSION_SUBSCRIBER, + (char*)td->transactionData.number); + MyOp->equal(IND_SESSION_SERVER, + (char*)&td->transactionData.server_id); + MyOp->getValue(IND_SESSION_DATA, + (char *)td->transactionData.session_details); + + /* Operation 4 */ + MyOp = pCON->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOp, "T3-4: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SERVER_ID, + (char*)&td->transactionData.server_id); + MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)td->transactionData.suffix); + MyOp->incValue(IND_SERVER_READS, (uint32)1); + td->transactionData.branchExecuted = 1; + } else { + DEBUG3("T3(%.*s, %.2d): - Callback 2 - no read", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + td->transactionData.branchExecuted = 0; + } + if (stat_async == 1) { + pCON->executeAsynchPrepare( Commit , T3_Callback_3, td); + } else { + int result = pCON->execute( Commit ); + T3_Callback_3(result, pCON, (void*)td); + return; + }//if +} + +void +T3_Callback_3(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + DEBUG3("T3(%.*s, %.2d): - Completing", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + if (result == -1) { + CHECK_ALLOWED_ERROR("T3-3: Commit", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T3(td->pNDB, td, stat_async); + return; + }//if + td->pNDB->closeTransaction(pCON); + complete_T3(td); +} + +/** + * Transaction 4 - T4 + * + * Create session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * SessionDetails, + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +void +start_T4(Ndb * pNDB, ThreadData * td, int async){ + + DEBUG3("T4(%.*s, %.2d): - Starting", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + NdbConnection * pCON = 0; + while((pCON = startTransaction(pNDB, td)) == 0){ + CHECK_ALLOWED_ERROR("T4-1: startTransaction", td, pNDB->getNdbError()); + NdbSleep_MilliSleep(10); + } + + NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOp, "T4-1: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + MyOp->getValue(IND_SUBSCRIBER_GROUP, + (char *)&td->transactionData.group_id); + MyOp->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&td->transactionData.sessions); + MyOp->incValue(IND_SUBSCRIBER_SESSIONS, + (uint32)td->transactionData.server_bit); + stat_async = async; + if (async == 1) { + pCON->executeAsynchPrepare( NoCommit , T4_Callback_1, td); + } else { + int result = pCON->execute( NoCommit ); + T4_Callback_1(result, pCON, (void*)td); + return; + }//if +} + +void +T4_Callback_1(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + if (result == -1) { + CHECK_ALLOWED_ERROR("T4-1: execute", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T4(td->pNDB, td, stat_async); + return; + }//if + + DEBUG3("T4(%.*s, %.2d): - Callback 1", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + + NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOp, "T4-2: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->readTuple(); + MyOp->equal(IND_GROUP_ID, + (char*)&td->transactionData.group_id); + MyOp->getValue(IND_GROUP_ALLOW_INSERT, + (char *)&td->transactionData.permission); + if (stat_async == 1) { + pCON->executeAsynchPrepare( NoCommit , T4_Callback_2, td); + } else { + int result = pCON->execute( NoCommit ); + T4_Callback_2(result, pCON, (void*)td); + return; + }//if +} + +void +T4_Callback_2(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + if (result == -1) { + CHECK_ALLOWED_ERROR("T4-2: execute", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T4(td->pNDB, td, stat_async); + return; + }//if + + Uint32 permission = td->transactionData.permission; + Uint32 sessions = td->transactionData.sessions; + Uint32 server_bit = td->transactionData.server_bit; + + if(((permission & server_bit) == server_bit) && + ((sessions & server_bit) == 0)){ + + memcpy(td->transactionData.suffix, + &td->transactionData.number[SFX_START], + SUBSCRIBER_NUMBER_SUFFIX_LENGTH); + + DEBUG5("T4(%.*s, %.2d): - Callback 2 - inserting(%.*s)", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + SUBSCRIBER_NUMBER_SUFFIX_LENGTH, + td->transactionData.suffix); + + /* Operation 3 */ + + NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOp, "T4-3: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->insertTuple(); + MyOp->equal(IND_SESSION_SUBSCRIBER, + (char*)td->transactionData.number); + MyOp->equal(IND_SESSION_SERVER, + (char*)&td->transactionData.server_id); + MyOp->setValue(SESSION_DATA, + (char *)td->transactionData.session_details); + /* Operation 4 */ + + /* Operation 5 */ + MyOp = pCON->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOp, "T4-5: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SERVER_ID, + (char*)&td->transactionData.server_id); + MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)td->transactionData.suffix); + MyOp->incValue(IND_SERVER_INSERTS, (uint32)1); + td->transactionData.branchExecuted = 1; + } else { + td->transactionData.branchExecuted = 0; + DEBUG5("T4(%.*s, %.2d): - Callback 2 - %s %s", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + ((permission & server_bit) ? + "permission - " : "no permission - "), + ((sessions & server_bit) ? + "in session - " : "no in session - ")); + } + + if(!td->transactionData.do_rollback && td->transactionData.branchExecuted){ + if (stat_async == 1) { + pCON->executeAsynchPrepare( Commit , T4_Callback_3, td); + } else { + int result = pCON->execute( Commit ); + T4_Callback_3(result, pCON, (void*)td); + return; + }//if + } else { + if (stat_async == 1) { + pCON->executeAsynchPrepare( Rollback , T4_Callback_3, td); + } else { + int result = pCON->execute( Rollback ); + T4_Callback_3(result, pCON, (void*)td); + return; + }//if + } +} + +void +T4_Callback_3(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + if (result == -1) { + CHECK_ALLOWED_ERROR("T4-3: Commit", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T4(td->pNDB, td, stat_async); + return; + }//if + + DEBUG3("T4(%.*s, %.2d): - Completing", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + td->pNDB->closeTransaction(pCON); + complete_T4(td); +} + +/** + * Transaction 5 - T5 + * + * Delete session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +void +start_T5(Ndb * pNDB, ThreadData * td, int async){ + + DEBUG3("T5(%.*s, %.2d): - Starting", SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + NdbConnection * pCON = 0; + while((pCON = startTransaction(pNDB, td)) == 0){ + CHECK_ALLOWED_ERROR("T5-1: startTransaction", td, pNDB->getNdbError()); + NdbSleep_MilliSleep(10); + } + + NdbOperation * MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOp, "T5-1: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SUBSCRIBER_NUMBER, + td->transactionData.number); + MyOp->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&td->transactionData.location); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY, + td->transactionData.changed_by); + MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME, + td->transactionData.changed_time); + MyOp->getValue(IND_SUBSCRIBER_GROUP, + (char *)&td->transactionData.group_id); + MyOp->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&td->transactionData.sessions); + MyOp->subValue(IND_SUBSCRIBER_SESSIONS, + (uint32)td->transactionData.server_bit); + stat_async = async; + if (async == 1) { + pCON->executeAsynchPrepare( NoCommit , T5_Callback_1, td); + } else { + int result = pCON->execute( NoCommit ); + T5_Callback_1(result, pCON, (void*)td); + return; + }//if +} + +void +T5_Callback_1(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + if (result == -1) { + CHECK_ALLOWED_ERROR("T5-1: execute", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T5(td->pNDB, td, stat_async); + return; + }//if + + DEBUG3("T5(%.*s, %.2d): - Callback 1", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOp, "T5-2: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->readTuple(); + MyOp->equal(IND_GROUP_ID, + (char*)&td->transactionData.group_id); + MyOp->getValue(IND_GROUP_ALLOW_DELETE, + (char *)&td->transactionData.permission); + if (stat_async == 1) { + pCON->executeAsynchPrepare( NoCommit , T5_Callback_2, td); + } else { + int result = pCON->execute( NoCommit ); + T5_Callback_2(result, pCON, (void*)td); + return; + }//if +} + +void +T5_Callback_2(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + if (result == -1) { + CHECK_ALLOWED_ERROR("T5-2: execute", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T5(td->pNDB, td, stat_async); + return; + }//if + + Uint32 permission = td->transactionData.permission; + Uint32 sessions = td->transactionData.sessions; + Uint32 server_bit = td->transactionData.server_bit; + + if(((permission & server_bit) == server_bit) && + ((sessions & server_bit) == server_bit)){ + + memcpy(td->transactionData.suffix, + &td->transactionData.number[SFX_START], + SUBSCRIBER_NUMBER_SUFFIX_LENGTH); + + DEBUG5("T5(%.*s, %.2d): - Callback 2 - deleting(%.*s)", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + SUBSCRIBER_NUMBER_SUFFIX_LENGTH, + td->transactionData.suffix); + + /* Operation 3 */ + NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOp, "T5-3: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->deleteTuple(); + MyOp->equal(IND_SESSION_SUBSCRIBER, + (char*)td->transactionData.number); + MyOp->equal(IND_SESSION_SERVER, + (char*)&td->transactionData.server_id); + /* Operation 4 */ + + /* Operation 5 */ + MyOp = pCON->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOp, "T5-5: getNdbOperation", td, + pCON->getNdbError()); + + MyOp->interpretedUpdateTuple(); + MyOp->equal(IND_SERVER_ID, + (char*)&td->transactionData.server_id); + MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)td->transactionData.suffix); + MyOp->incValue(IND_SERVER_DELETES, (uint32)1); + td->transactionData.branchExecuted = 1; + } else { + td->transactionData.branchExecuted = 0; + + DEBUG5("T5(%.*s, %.2d): - Callback 2 - no delete - %s %s", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id, + ((permission & server_bit) ? + "permission - " : "no permission - "), + ((sessions & server_bit) ? + "in session - " : "no in session - ")); + } + + if(!td->transactionData.do_rollback && td->transactionData.branchExecuted){ + if (stat_async == 1) { + pCON->executeAsynchPrepare( Commit , T5_Callback_3, td); + } else { + int result = pCON->execute( Commit ); + T5_Callback_3(result, pCON, (void*)td); + return; + }//if + } else { + if (stat_async == 1) { + pCON->executeAsynchPrepare( Rollback , T5_Callback_3, td); + } else { + int result = pCON->execute( Rollback ); + T5_Callback_3(result, pCON, (void*)td); + return; + }//if + } +} + +void +T5_Callback_3(int result, NdbConnection * pCON, void * threadData){ + ThreadData * td = (ThreadData *)threadData; + if (result == -1) { + CHECK_ALLOWED_ERROR("T5-3: Commit", td, pCON->getNdbError()); + td->pNDB->closeTransaction(pCON); + start_T5(td->pNDB, td, stat_async); + return; + }//if + + DEBUG3("T5(%.*s, %.2d): - Completing", + SUBSCRIBER_NUMBER_LENGTH, + td->transactionData.number, + td->transactionData.server_id); + + td->pNDB->closeTransaction(pCON); + complete_T5(td); +} diff --git a/ndb/test/ndbapi/bench/ndb_error.hpp b/ndb/test/ndbapi/bench/ndb_error.hpp new file mode 100644 index 00000000000..d90f5506813 --- /dev/null +++ b/ndb/test/ndbapi/bench/ndb_error.hpp @@ -0,0 +1,81 @@ +/* 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> +#include <NdbApi.hpp> + +#define error_handler(x,y, z) { \ + ndbout << x << " " << y << endl; \ + exit(-1); } + +#define CHECK_MINUS_ONE(x, y, z) if(x == -1) \ + error_handler(y,(z->getNdbError()), 0) + +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); + } +} + +inline +void +CHECK_NULL(void * null, const char* msg, NdbConnection* obj) +{ + if(null == 0) + { + error_handler(msg, obj->getNdbError(), 0); + } +} + +#endif diff --git a/ndb/test/ndbapi/bench/ndb_schema.hpp b/ndb/test/ndbapi/bench/ndb_schema.hpp new file mode 100644 index 00000000000..af08bc2eecd --- /dev/null +++ b/ndb/test/ndbapi/bench/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/ndb/test/ndbapi/bench/ndb_user_transaction.cpp b/ndb/test/ndbapi/bench/ndb_user_transaction.cpp new file mode 100644 index 00000000000..182f1f99586 --- /dev/null +++ b/ndb/test/ndbapi/bench/ndb_user_transaction.cpp @@ -0,0 +1,825 @@ +/* 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 */ + +//#define DEBUG_ON + +extern "C" { +#include "user_transaction.h" +}; + +#include "macros.h" +#include "ndb_schema.hpp" +#include "ndb_error.hpp" + +#include <time.h> +#include <NdbApi.hpp> + +/** + * Transaction 1 - T1 + * + * Update location and changed by/time on a subscriber + * + * Input: + * SubscriberNumber, + * Location, + * ChangedBy, + * ChangedTime + * + * Output: + */ +int +T1(void * obj, + const SubscriberNumber number, + const Location new_location, + const ChangedBy changed_by, + const ChangedTime changed_time, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction); + + check = MyOperation->updateTuple(); + CHECK_MINUS_ONE(check, "T1: updateTuple", + MyTransaction); + + check = MyOperation->equal(SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T1: equal subscriber", + MyTransaction); + + check = MyOperation->setValue(SUBSCRIBER_LOCATION, + (char *)&new_location); + CHECK_MINUS_ONE(check, "T1: setValue location", + MyTransaction); + + check = MyOperation->setValue(SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_MINUS_ONE(check, "T1: setValue changed_by", + MyTransaction); + + check = MyOperation->setValue(SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_MINUS_ONE(check, "T1: setValue changed_time", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T1: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 2 - T2 + * + * Read from Subscriber: + * + * Input: + * SubscriberNumber + * + * Output: + * Location + * Changed by + * Changed Timestamp + * Name + */ +int +T2(void * obj, + const SubscriberNumber number, + Location * readLocation, + ChangedBy changed_by, + ChangedTime changed_time, + SubscriberName subscriberName, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T2: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T2: readTuple", + MyTransaction); + + check = MyOperation->equal(SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T2: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_LOCATION, + (char *)readLocation); + CHECK_NULL(check2, "T2: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_NULL(check2, "T2: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_NULL(check2, "T2: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_NAME, + subscriberName); + CHECK_NULL(check2, "T2: getValue name", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T2: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 3 - T3 + * + * Read session details + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * + * Output: + * BranchExecuted + * SessionDetails + * ChangedBy + * ChangedTime + * Location + */ +int +T3(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + SessionDetails outSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T3-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T3-1: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-1: readTuple", + MyTransaction); + + check = MyOperation->equal(SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T3-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T3-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T3-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T3-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T3-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T3-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T3-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-2: readTuple", + MyTransaction); + + check = MyOperation->equal(GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T3-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(GROUP_ALLOW_READ, + (char *)&permission); + CHECK_NULL(check2, "T3-2: getValue allow_read", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-2: NoCommit", + MyTransaction); + + DEBUG3("T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("reading - "); + + /* Operation 3 */ + + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T3-3: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-3: readTuple", + MyTransaction); + + check = MyOperation->equal(SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T3-3: equal number", + MyTransaction); + + check = MyOperation->equal(SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-3: equal server id", + MyTransaction); + + check2 = MyOperation->getValue(SESSION_DATA, + (char *)outSessionDetails); + CHECK_NULL(check2, "T3-3: getValue session details", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-3: NoCommit", + MyTransaction); + + /* Operation 4 */ + + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T3-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T3-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-4: equal serverId", + MyTransaction); + + check = MyOperation->equal(SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T3-4: equal suffix", + MyTransaction); + + check = MyOperation->incValue(SERVER_READS, (uint32)1); + CHECK_MINUS_ONE(check, "T3-4: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-4: NoCommit", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + (* outBranchExecuted) = 0; + } + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T3: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 4 - T4 + * + * Create session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * SessionDetails, + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T4(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + const SessionDetails inSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T4-1: startTranscation", pNDB->getNdbErrorString(), 0); + + DEBUG3("T4(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + NdbOperation * MyOperation = 0; + + MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T4-1: getNdbOperation", + MyTransaction); + + check = MyOperation->readTupleExclusive(); + CHECK_MINUS_ONE(check, "T4-1: readTuple", + MyTransaction); + + check = MyOperation->equal(SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T4-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T4-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T4-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T4-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T4-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T4-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T4-2: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T4-2: readTuple", + MyTransaction); + + check = MyOperation->equal(GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T4-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(GROUP_ALLOW_INSERT, + (char *)&permission); + CHECK_NULL(check2, "T4-2: getValue allow_insert", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-2: NoCommit", + MyTransaction); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == 0)){ + + DEBUG("inserting - "); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T4-3: getNdbOperation", + MyTransaction); + + check = MyOperation->insertTuple(); + CHECK_MINUS_ONE(check, "T4-3: insertTuple", + MyTransaction); + + check = MyOperation->equal(SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T4-3: equal number", + MyTransaction); + + check = MyOperation->equal(SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-3: equal server id", + MyTransaction); + + check = MyOperation->setValue(SESSION_DATA, + (char *)inSessionDetails); + CHECK_MINUS_ONE(check, "T4-3: setValue session details", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-3: NoCommit", + MyTransaction); + + /* Operation 4 */ + MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T4-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(SUBSCRIBER_NUMBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T4-4: equal number", + MyTransaction); + + check = MyOperation->incValue(SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T4-4: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-4: NoCommit", + MyTransaction); + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T4-5: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T4-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(SERVER_INSERTS, (uint32)1); + CHECK_MINUS_ONE(check, "T4-5: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-5: NoCommit", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T4: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T4:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 5 - T5 + * + * Delete session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T5(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + NdbConnection * MyTransaction = 0; + NdbOperation * MyOperation = 0; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), 0); + + MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T5-1: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTupleExclusive(); + CHECK_MINUS_ONE(check, "T5-1: readTuple", + MyTransaction); + + check = MyOperation->equal(SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T5-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T5-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T5-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T5-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T5-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T5-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T5-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T5-2: readTuple", + MyTransaction); + + check = MyOperation->equal(GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T5-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(GROUP_ALLOW_DELETE, + (char *)&permission); + CHECK_NULL(check2, "T5-2: getValue allow_delete", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-2: NoCommit", + MyTransaction); + + DEBUG3("T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("deleting - "); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T5-3: getNdbOperation", + MyTransaction); + + check = MyOperation->deleteTuple(); + CHECK_MINUS_ONE(check, "T5-3: deleteTuple", + MyTransaction); + + check = MyOperation->equal(SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T5-3: equal number", + MyTransaction); + + check = MyOperation->equal(SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-3: equal server id", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-3: NoCommit", + MyTransaction); + + /* Operation 4 */ + MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T5-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(SUBSCRIBER_NUMBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T5-4: equal number", + MyTransaction); + + check = MyOperation->subValue(SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T5-4: dec value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-4: NoCommit", + MyTransaction); + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T5-5: getNdbOperation", + MyTransaction); + + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T5-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(SERVER_DELETES, (uint32)1); + CHECK_MINUS_ONE(check, "T5-5: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-5: NoCommit", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T5: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T5:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + diff --git a/ndb/test/ndbapi/bench/ndb_user_transaction2.cpp b/ndb/test/ndbapi/bench/ndb_user_transaction2.cpp new file mode 100644 index 00000000000..df3c7a7989e --- /dev/null +++ b/ndb/test/ndbapi/bench/ndb_user_transaction2.cpp @@ -0,0 +1,825 @@ +/* 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 */ + +//#define DEBUG_ON + +extern "C" { +#include "user_transaction.h" +}; + +#include "macros.h" +#include "ndb_schema.hpp" +#include "ndb_error.hpp" + +#include <time.h> +#include <NdbApi.hpp> + +/** + * Transaction 1 - T1 + * + * Update location and changed by/time on a subscriber + * + * Input: + * SubscriberNumber, + * Location, + * ChangedBy, + * ChangedTime + * + * Output: + */ +int +T1(void * obj, + const SubscriberNumber number, + const Location new_location, + const ChangedBy changed_by, + const ChangedTime changed_time, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction); + + check = MyOperation->updateTuple(); + CHECK_MINUS_ONE(check, "T1: updateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T1: equal subscriber", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_LOCATION, + (char *)&new_location); + CHECK_MINUS_ONE(check, "T1: setValue location", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_MINUS_ONE(check, "T1: setValue changed_by", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_MINUS_ONE(check, "T1: setValue changed_time", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T1: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 2 - T2 + * + * Read from Subscriber: + * + * Input: + * SubscriberNumber + * + * Output: + * Location + * Changed by + * Changed Timestamp + * Name + */ +int +T2(void * obj, + const SubscriberNumber number, + Location * readLocation, + ChangedBy changed_by, + ChangedTime changed_time, + SubscriberName subscriberName, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T2: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T2: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)readLocation); + CHECK_NULL(check2, "T2: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_NULL(check2, "T2: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_NULL(check2, "T2: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_NAME, + subscriberName); + CHECK_NULL(check2, "T2: getValue name", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T2: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 3 - T3 + * + * Read session details + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * + * Output: + * BranchExecuted + * SessionDetails + * ChangedBy + * ChangedTime + * Location + */ +int +T3(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + SessionDetails outSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T3-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T3-1: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T3-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T3-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T3-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T3-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T3-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T3-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T3-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T3-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_READ, + (char *)&permission); + CHECK_NULL(check2, "T3-2: getValue allow_read", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-2: NoCommit", + MyTransaction); + + DEBUG3("T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("reading - "); + + /* Operation 3 */ + + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T3-3: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-3: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T3-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-3: equal server id", + MyTransaction); + + check2 = MyOperation->getValue(IND_SESSION_DATA, + (char *)outSessionDetails); + CHECK_NULL(check2, "T3-3: getValue session details", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-3: NoCommit", + MyTransaction); + + /* Operation 4 */ + + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T3-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T3-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-4: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T3-4: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_READS, (uint32)1); + CHECK_MINUS_ONE(check, "T3-4: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-4: NoCommit", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + (* outBranchExecuted) = 0; + } + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T3: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 4 - T4 + * + * Create session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * SessionDetails, + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T4(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + const SessionDetails inSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T4-1: startTranscation", pNDB->getNdbErrorString(), 0); + + DEBUG3("T4(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + NdbOperation * MyOperation = 0; + + MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T4-1: getNdbOperation", + MyTransaction); + + check = MyOperation->readTupleExclusive(); + CHECK_MINUS_ONE(check, "T4-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T4-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T4-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T4-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T4-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T4-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T4-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T4-2: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T4-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T4-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_INSERT, + (char *)&permission); + CHECK_NULL(check2, "T4-2: getValue allow_insert", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-2: NoCommit", + MyTransaction); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == 0)){ + + DEBUG("inserting - "); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T4-3: getNdbOperation", + MyTransaction); + + check = MyOperation->insertTuple(); + CHECK_MINUS_ONE(check, "T4-3: insertTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T4-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-3: equal server id", + MyTransaction); + + check = MyOperation->setValue(SESSION_DATA, + (char *)inSessionDetails); + CHECK_MINUS_ONE(check, "T4-3: setValue session details", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-3: NoCommit", + MyTransaction); + + /* Operation 4 */ + MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T4-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T4-4: equal number", + MyTransaction); + + check = MyOperation->incValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T4-4: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-4: NoCommit", + MyTransaction); + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T4-5: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T4-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_INSERTS, (uint32)1); + CHECK_MINUS_ONE(check, "T4-5: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-5: NoCommit", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T4: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T4:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 5 - T5 + * + * Delete session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T5(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + NdbConnection * MyTransaction = 0; + NdbOperation * MyOperation = 0; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), 0); + + MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T5-1: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTupleExclusive(); + CHECK_MINUS_ONE(check, "T5-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T5-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T5-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T5-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T5-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T5-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T5-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T5-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T5-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T5-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_DELETE, + (char *)&permission); + CHECK_NULL(check2, "T5-2: getValue allow_delete", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-2: NoCommit", + MyTransaction); + + DEBUG3("T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("deleting - "); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T5-3: getNdbOperation", + MyTransaction); + + check = MyOperation->deleteTuple(); + CHECK_MINUS_ONE(check, "T5-3: deleteTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T5-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-3: equal server id", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-3: NoCommit", + MyTransaction); + + /* Operation 4 */ + MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T5-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T5-4: equal number", + MyTransaction); + + check = MyOperation->subValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T5-4: dec value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-4: NoCommit", + MyTransaction); + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T5-5: getNdbOperation", + MyTransaction); + + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T5-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_DELETES, (uint32)1); + CHECK_MINUS_ONE(check, "T5-5: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-5: NoCommit", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T5: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T5:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + diff --git a/ndb/test/ndbapi/bench/ndb_user_transaction3.cpp b/ndb/test/ndbapi/bench/ndb_user_transaction3.cpp new file mode 100644 index 00000000000..d2c92ecd424 --- /dev/null +++ b/ndb/test/ndbapi/bench/ndb_user_transaction3.cpp @@ -0,0 +1,793 @@ +/* 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 */ + +//#define DEBUG_ON + +extern "C" { +#include "user_transaction.h" +}; + +#include "macros.h" +#include "ndb_schema.hpp" +#include "ndb_error.hpp" + +#include <time.h> +#include <NdbApi.hpp> + +/** + * Transaction 1 - T1 + * + * Update location and changed by/time on a subscriber + * + * Input: + * SubscriberNumber, + * Location, + * ChangedBy, + * ChangedTime + * + * Output: + */ +int +T1(void * obj, + const SubscriberNumber number, + const Location new_location, + const ChangedBy changed_by, + const ChangedTime changed_time, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction); + + check = MyOperation->updateTuple(); + CHECK_MINUS_ONE(check, "T1: updateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T1: equal subscriber", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_LOCATION, + (char *)&new_location); + CHECK_MINUS_ONE(check, "T1: setValue location", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_MINUS_ONE(check, "T1: setValue changed_by", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_MINUS_ONE(check, "T1: setValue changed_time", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T1: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 2 - T2 + * + * Read from Subscriber: + * + * Input: + * SubscriberNumber + * + * Output: + * Location + * Changed by + * Changed Timestamp + * Name + */ +int +T2(void * obj, + const SubscriberNumber number, + Location * readLocation, + ChangedBy changed_by, + ChangedTime changed_time, + SubscriberName subscriberName, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T2: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T2: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)readLocation); + CHECK_NULL(check2, "T2: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_NULL(check2, "T2: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_NULL(check2, "T2: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_NAME, + subscriberName); + CHECK_NULL(check2, "T2: getValue name", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T2: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 3 - T3 + * + * Read session details + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * + * Output: + * BranchExecuted + * SessionDetails + * ChangedBy + * ChangedTime + * Location + */ +int +T3(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + SessionDetails outSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T3-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T3-1: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T3-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T3-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T3-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T3-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T3-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T3-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T3-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T3-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_READ, + (char *)&permission); + CHECK_NULL(check2, "T3-2: getValue allow_read", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-2: NoCommit", + MyTransaction); + + DEBUG3("T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("reading - "); + + /* Operation 3 */ + + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T3-3: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-3: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T3-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-3: equal server id", + MyTransaction); + + check2 = MyOperation->getValue(IND_SESSION_DATA, + (char *)outSessionDetails); + CHECK_NULL(check2, "T3-3: getValue session details", + MyTransaction); + + /* Operation 4 */ + + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T3-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T3-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-4: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T3-4: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_READS, (uint32)1); + CHECK_MINUS_ONE(check, "T3-4: inc value", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + (* outBranchExecuted) = 0; + } + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T3: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 4 - T4 + * + * Create session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * SessionDetails, + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T4(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + const SessionDetails inSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T4-1: startTranscation", pNDB->getNdbErrorString(), 0); + + DEBUG3("T4(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + NdbOperation * MyOperation = 0; + + MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T4-1: getNdbOperation", + MyTransaction); + + check = MyOperation->readTupleExclusive(); + CHECK_MINUS_ONE(check, "T4-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T4-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T4-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T4-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T4-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T4-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T4-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T4-2: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T4-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T4-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_INSERT, + (char *)&permission); + CHECK_NULL(check2, "T4-2: getValue allow_insert", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-2: NoCommit", + MyTransaction); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == 0)){ + + DEBUG("inserting - "); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T4-3: getNdbOperation", + MyTransaction); + + check = MyOperation->insertTuple(); + CHECK_MINUS_ONE(check, "T4-3: insertTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T4-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-3: equal server id", + MyTransaction); + + check = MyOperation->setValue(SESSION_DATA, + (char *)inSessionDetails); + CHECK_MINUS_ONE(check, "T4-3: setValue session details", + MyTransaction); + + /* Operation 4 */ + MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T4-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T4-4: equal number", + MyTransaction); + + check = MyOperation->incValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T4-4: inc value", + MyTransaction); + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T4-5: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T4-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_INSERTS, (uint32)1); + CHECK_MINUS_ONE(check, "T4-5: inc value", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T4: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T4:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 5 - T5 + * + * Delete session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T5(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + NdbConnection * MyTransaction = 0; + NdbOperation * MyOperation = 0; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), 0); + + MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T5-1: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTupleExclusive(); + CHECK_MINUS_ONE(check, "T5-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T5-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T5-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T5-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T5-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T5-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T5-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T5-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T5-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T5-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_DELETE, + (char *)&permission); + CHECK_NULL(check2, "T5-2: getValue allow_delete", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-2: NoCommit", + MyTransaction); + + DEBUG3("T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("deleting - "); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T5-3: getNdbOperation", + MyTransaction); + + check = MyOperation->deleteTuple(); + CHECK_MINUS_ONE(check, "T5-3: deleteTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T5-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-3: equal server id", + MyTransaction); + + /* Operation 4 */ + MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T5-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T5-4: equal number", + MyTransaction); + + check = MyOperation->subValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T5-4: dec value", + MyTransaction); + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T5-5: getNdbOperation", + MyTransaction); + + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T5-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_DELETES, (uint32)1); + CHECK_MINUS_ONE(check, "T5-5: inc value", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T5: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T5:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + diff --git a/ndb/test/ndbapi/bench/ndb_user_transaction4.cpp b/ndb/test/ndbapi/bench/ndb_user_transaction4.cpp new file mode 100644 index 00000000000..e652c7bfed8 --- /dev/null +++ b/ndb/test/ndbapi/bench/ndb_user_transaction4.cpp @@ -0,0 +1,770 @@ +/* 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 */ + +//#define DEBUG_ON + +extern "C" { +#include "user_transaction.h" +}; + +#include "macros.h" +#include "ndb_schema.hpp" +#include "ndb_error.hpp" + +#include <time.h> +#include <NdbApi.hpp> + +/** + * Transaction 1 - T1 + * + * Update location and changed by/time on a subscriber + * + * Input: + * SubscriberNumber, + * Location, + * ChangedBy, + * ChangedTime + * + * Output: + */ +int +T1(void * obj, + const SubscriberNumber number, + const Location new_location, + const ChangedBy changed_by, + const ChangedTime changed_time, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + DEBUG2("T1(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number); + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T1-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction); + + check = MyOperation->updateTuple(); + CHECK_MINUS_ONE(check, "T1: updateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T1: equal subscriber", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_LOCATION, + (char *)&new_location); + CHECK_MINUS_ONE(check, "T1: setValue location", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_MINUS_ONE(check, "T1: setValue changed_by", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_MINUS_ONE(check, "T1: setValue changed_time", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T1: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 2 - T2 + * + * Read from Subscriber: + * + * Input: + * SubscriberNumber + * + * Output: + * Location + * Changed by + * Changed Timestamp + * Name + */ +int +T2(void * obj, + const SubscriberNumber number, + Location * readLocation, + ChangedBy changed_by, + ChangedTime changed_time, + SubscriberName subscriberName, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + DEBUG2("T2(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number); + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T2-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T2: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)readLocation); + CHECK_NULL(check2, "T2: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_NULL(check2, "T2: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_NULL(check2, "T2: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_NAME, + subscriberName); + CHECK_NULL(check2, "T2: getValue name", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T2: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 3 - T3 + * + * Read session details + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * + * Output: + * BranchExecuted + * SessionDetails + * ChangedBy + * ChangedTime + * Location + */ +int +T3(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + SessionDetails outSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + DEBUG3("T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T3-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T3-1: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T3-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T3-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T3-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T3-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T3-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T3-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T3-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T3-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_READ, + (char *)&permission); + CHECK_NULL(check2, "T3-2: getValue allow_read", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-2: NoCommit", + MyTransaction); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("reading - "); + + /* Operation 3 */ + + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T3-3: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-3: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T3-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-3: equal server id", + MyTransaction); + + check2 = MyOperation->getValue(IND_SESSION_DATA, + (char *)outSessionDetails); + CHECK_NULL(check2, "T3-3: getValue session details", + MyTransaction); + + /* Operation 4 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T3-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T3-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-4: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T3-4: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_READS, (uint32)1); + CHECK_MINUS_ONE(check, "T3-4: inc value", + MyTransaction); + (* outBranchExecuted) = 1; + } else { + (* outBranchExecuted) = 0; + } + DEBUG("commit..."); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T3: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + DEBUG("done\n"); + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 4 - T4 + * + * Create session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * SessionDetails, + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T4(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + const SessionDetails inSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + DEBUG3("T4(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T4-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T4-1: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T4-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T4-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T4-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T4-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T4-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T4-1: getValue sessions", + MyTransaction); + + check = MyOperation->incValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T4-4: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T4-2: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T4-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T4-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_INSERT, + (char *)&permission); + CHECK_NULL(check2, "T4-2: getValue allow_insert", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-2: NoCommit", + MyTransaction); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == 0)){ + + DEBUG("inserting - "); + + /* Operation 3 */ + + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T4-3: getNdbOperation", + MyTransaction); + + check = MyOperation->insertTuple(); + CHECK_MINUS_ONE(check, "T4-3: insertTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T4-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-3: equal server id", + MyTransaction); + + check = MyOperation->setValue(SESSION_DATA, + (char *)inSessionDetails); + CHECK_MINUS_ONE(check, "T4-3: setValue session details", + MyTransaction); + + /* Operation 4 */ + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T4-5: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T4-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_INSERTS, (uint32)1); + CHECK_MINUS_ONE(check, "T4-5: inc value", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback && (* outBranchExecuted)){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T4: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T4:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 5 - T5 + * + * Delete session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T5(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + DEBUG3("T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + Ndb * pNDB = (Ndb *) obj; + NdbConnection * MyTransaction = 0; + NdbOperation * MyOperation = 0; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), 0); + + MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T5-1: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T5-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T5-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T5-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T5-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T5-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T5-1: getValue sessions", + MyTransaction); + + check = MyOperation->subValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T5-4: dec value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T5-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T5-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T5-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_DELETE, + (char *)&permission); + CHECK_NULL(check2, "T5-2: getValue allow_delete", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-2: NoCommit", + MyTransaction); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("deleting - "); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T5-3: getNdbOperation", + MyTransaction); + + check = MyOperation->deleteTuple(); + CHECK_MINUS_ONE(check, "T5-3: deleteTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T5-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-3: equal server id", + MyTransaction); + + /* Operation 4 */ + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T5-5: getNdbOperation", + MyTransaction); + + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T5-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_DELETES, (uint32)1); + CHECK_MINUS_ONE(check, "T5-5: inc value", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback && (* outBranchExecuted)){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T5: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T5:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + diff --git a/ndb/test/ndbapi/bench/ndb_user_transaction5.cpp b/ndb/test/ndbapi/bench/ndb_user_transaction5.cpp new file mode 100644 index 00000000000..86580008d10 --- /dev/null +++ b/ndb/test/ndbapi/bench/ndb_user_transaction5.cpp @@ -0,0 +1,769 @@ +/* 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 */ + +//#define DEBUG_ON + +extern "C" { +#include "user_transaction.h" +}; + +#include "macros.h" +#include "ndb_schema.hpp" +#include "ndb_error.hpp" + +#include <time.h> +#include <NdbApi.hpp> + +/** + * Transaction 1 - T1 + * + * Update location and changed by/time on a subscriber + * + * Input: + * SubscriberNumber, + * Location, + * ChangedBy, + * ChangedTime + * + * Output: + */ +int +T1(void * obj, + const SubscriberNumber number, + const Location new_location, + const ChangedBy changed_by, + const ChangedTime changed_time, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + DEBUG2("T1(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number); + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T1-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction); + + check = MyOperation->updateTuple(); + CHECK_MINUS_ONE(check, "T1: updateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T1: equal subscriber", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_LOCATION, + (char *)&new_location); + CHECK_MINUS_ONE(check, "T1: setValue location", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_MINUS_ONE(check, "T1: setValue changed_by", + MyTransaction); + + check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_MINUS_ONE(check, "T1: setValue changed_time", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T1: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 2 - T2 + * + * Read from Subscriber: + * + * Input: + * SubscriberNumber + * + * Output: + * Location + * Changed by + * Changed Timestamp + * Name + */ +int +T2(void * obj, + const SubscriberNumber number, + Location * readLocation, + ChangedBy changed_by, + ChangedTime changed_time, + SubscriberName subscriberName, + BenchmarkTime * transaction_time){ + + Ndb * pNDB = (Ndb *) obj; + + DEBUG2("T2(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number); + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T2-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + CHECK_MINUS_ONE(check, "T2: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)readLocation); + CHECK_NULL(check2, "T2: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + CHECK_NULL(check2, "T2: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + CHECK_NULL(check2, "T2: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_NAME, + subscriberName); + CHECK_NULL(check2, "T2: getValue name", + MyTransaction); + + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T2: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + get_time(transaction_time); + time_diff(transaction_time, &start); + return 0; +} + +/** + * Transaction 3 - T3 + * + * Read session details + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * + * Output: + * BranchExecuted + * SessionDetails + * ChangedBy + * ChangedTime + * Location + */ +int +T3(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + SessionDetails outSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T3-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T3-1: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T3-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T3-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T3-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T3-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T3-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T3-1: getValue sessions", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T3-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T3-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T3-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_READ, + (char *)&permission); + CHECK_NULL(check2, "T3-2: getValue allow_read", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-2: NoCommit", + MyTransaction); + + DEBUG3("T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("reading - "); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T3-3: getNdbOperation", + MyTransaction); + + check = MyOperation->simpleRead(); + CHECK_MINUS_ONE(check, "T3-3: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T3-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-3: equal server id", + MyTransaction); + + check2 = MyOperation->getValue(IND_SESSION_DATA, + (char *)outSessionDetails); + CHECK_NULL(check2, "T3-3: getValue session details", + MyTransaction); + + /* Operation 4 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T3-4: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T3-4: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T3-4: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T3-4: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_READS, (uint32)1); + CHECK_MINUS_ONE(check, "T3-4: inc value", + MyTransaction); + (* outBranchExecuted) = 1; + } else { + (* outBranchExecuted) = 0; + } + DEBUG("commit..."); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T3: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + DEBUG("done\n"); + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 4 - T4 + * + * Create session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * SessionDetails, + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T4(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + const SessionDetails inSessionDetails, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T4-1: startTranscation", pNDB->getNdbErrorString(), 0); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T4-1: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T4-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T4-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T4-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T4-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T4-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T4-1: getValue sessions", + MyTransaction); + + check = MyOperation->incValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T4-4: inc value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T4-2: getNdbOperation", + MyTransaction); + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T4-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T4-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_INSERT, + (char *)&permission); + CHECK_NULL(check2, "T4-2: getValue allow_insert", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-2: NoCommit", + MyTransaction); + + DEBUG3("T4(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == 0)){ + + DEBUG("inserting - "); + + /* Operation 3 */ + + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T4-3: getNdbOperation", + MyTransaction); + + check = MyOperation->insertTuple(); + CHECK_MINUS_ONE(check, "T4-3: insertTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T4-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-3: equal server id", + MyTransaction); + + check = MyOperation->setValue(SESSION_DATA, + (char *)inSessionDetails); + CHECK_MINUS_ONE(check, "T4-3: setValue session details", + MyTransaction); + + /* Operation 4 */ + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T4-5: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T4-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T4-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T4-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_INSERTS, (uint32)1); + CHECK_MINUS_ONE(check, "T4-5: inc value", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback && (* outBranchExecuted)){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T4: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T4:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + + +/** + * Transaction 5 - T5 + * + * Delete session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +int +T5(void * obj, + const SubscriberNumber inNumber, + const SubscriberSuffix inSuffix, + const ServerId inServerId, + const ServerBit inServerBit, + ChangedBy outChangedBy, + ChangedTime outChangedTime, + Location * outLocation, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted, + BenchmarkTime * outTransactionTime){ + + Ndb * pNDB = (Ndb *) obj; + NdbConnection * MyTransaction = 0; + NdbOperation * MyOperation = 0; + + GroupId groupId; + ActiveSessions sessions; + Permission permission; + + BenchmarkTime start; + get_time(&start); + + int check; + NdbRecAttr * check2; + + MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), 0); + + MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T5-1: getNdbOperation", + MyTransaction); + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-1: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + CHECK_MINUS_ONE(check, "T5-1: equal subscriber", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)outLocation); + CHECK_NULL(check2, "T5-1: getValue location", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + CHECK_NULL(check2, "T5-1: getValue changed_by", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + CHECK_NULL(check2, "T5-1: getValue changed_time", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + CHECK_NULL(check2, "T5-1: getValue group", + MyTransaction); + + check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + CHECK_NULL(check2, "T5-1: getValue sessions", + MyTransaction); + + check = MyOperation->subValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + CHECK_MINUS_ONE(check, "T5-4: dec value", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T5-2: getNdbOperation", + MyTransaction); + + + check = MyOperation->readTuple(); + CHECK_MINUS_ONE(check, "T5-2: readTuple", + MyTransaction); + + check = MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + CHECK_MINUS_ONE(check, "T5-2: equal group", + MyTransaction); + + check2 = MyOperation->getValue(IND_GROUP_ALLOW_DELETE, + (char *)&permission); + CHECK_NULL(check2, "T5-2: getValue allow_delete", + MyTransaction); + + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-2: NoCommit", + MyTransaction); + + DEBUG3("T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + DEBUG("deleting - "); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T5-3: getNdbOperation", + MyTransaction); + + check = MyOperation->deleteTuple(); + CHECK_MINUS_ONE(check, "T5-3: deleteTuple", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + CHECK_MINUS_ONE(check, "T5-3: equal number", + MyTransaction); + + check = MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-3: equal server id", + MyTransaction); + + /* Operation 4 */ + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T5-5: getNdbOperation", + MyTransaction); + + + check = MyOperation->interpretedUpdateTuple(); + CHECK_MINUS_ONE(check, "T5-5: interpretedUpdateTuple", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + CHECK_MINUS_ONE(check, "T5-5: equal serverId", + MyTransaction); + + check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + CHECK_MINUS_ONE(check, "T5-5: equal suffix", + MyTransaction); + + check = MyOperation->incValue(IND_SERVER_DELETES, (uint32)1); + CHECK_MINUS_ONE(check, "T5-5: inc value", + MyTransaction); + + (* outBranchExecuted) = 1; + } else { + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + (* outBranchExecuted) = 0; + } + + if(!inDoRollback && (* outBranchExecuted)){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T5: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T5:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); + + get_time(outTransactionTime); + time_diff(outTransactionTime, &start); + return 0; +} + diff --git a/ndb/test/ndbapi/bench/ndb_user_transaction6.cpp b/ndb/test/ndbapi/bench/ndb_user_transaction6.cpp new file mode 100644 index 00000000000..262f38e9ffb --- /dev/null +++ b/ndb/test/ndbapi/bench/ndb_user_transaction6.cpp @@ -0,0 +1,561 @@ +/* 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 */ + +//#define DEBUG_ON + +#include <string.h> +#include "userHandle.h" +#include "userInterface.h" + +#include "macros.h" +#include "ndb_schema.hpp" +#include "ndb_error.hpp" + +#include <NdbApi.hpp> + + +void +userCheckpoint(UserHandle *uh){ +} + +inline +NdbConnection * +startTransaction(Ndb * pNDB, ServerId inServerId, const SubscriberNumber inNumber){ + + const int keyDataLenBytes = sizeof(ServerId)+SUBSCRIBER_NUMBER_LENGTH; + const int keyDataLen_64Words = keyDataLenBytes >> 3; + + Uint64 keyDataBuf[keyDataLen_64Words+1]; // The "+1" is for rounding... + + char * keyDataBuf_charP = (char *)&keyDataBuf[0]; + Uint32 * keyDataBuf_wo32P = (Uint32 *)&keyDataBuf[0]; + + // Server Id comes first + keyDataBuf_wo32P[0] = inServerId; + // Then subscriber number + memcpy(&keyDataBuf_charP[sizeof(ServerId)], inNumber, SUBSCRIBER_NUMBER_LENGTH); + + return pNDB->startTransaction(0, keyDataBuf_charP, keyDataLenBytes); +} + +/** + * Transaction 1 - T1 + * + * Update location and changed by/time on a subscriber + * + * Input: + * SubscriberNumber, + * Location, + * ChangedBy, + * ChangedTime + * + * Output: + */ +void +userTransaction_T1(UserHandle * uh, + SubscriberNumber number, + Location new_location, + ChangedBy changed_by, + ChangedTime changed_time){ + Ndb * pNDB = uh->pNDB; + + DEBUG2("T1(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction != NULL) { + NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + if (MyOperation != NULL) { + MyOperation->updateTuple(); + MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + MyOperation->setValue(IND_SUBSCRIBER_LOCATION, + (char *)&new_location); + MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + check = MyTransaction->execute( Commit ); + if (check != -1) { + pNDB->closeTransaction(MyTransaction); + return; + } else { + CHECK_MINUS_ONE(check, "T1: Commit", + MyTransaction); + }//if + } else { + CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction); + }//if + } else { + error_handler("T1-1: startTranscation", pNDB->getNdbErrorString(), pNDB->getNdbError()); + }//if +} + +/** + * Transaction 2 - T2 + * + * Read from Subscriber: + * + * Input: + * SubscriberNumber + * + * Output: + * Location + * Changed by + * Changed Timestamp + * Name + */ +void +userTransaction_T2(UserHandle * uh, + SubscriberNumber number, + Location * readLocation, + ChangedBy changed_by, + ChangedTime changed_time, + SubscriberName subscriberName){ + Ndb * pNDB = uh->pNDB; + + DEBUG2("T2(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T2-1: startTransaction", pNDB->getNdbErrorString(), pNDB->getNdbError()); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T2: getNdbOperation", + MyTransaction); + + MyOperation->readTuple(); + MyOperation->equal(IND_SUBSCRIBER_NUMBER, + number); + MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)readLocation); + MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + changed_by); + MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + changed_time); + MyOperation->getValue(IND_SUBSCRIBER_NAME, + subscriberName); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T2: Commit", + MyTransaction); + pNDB->closeTransaction(MyTransaction); +} + +/** + * Transaction 3 - T3 + * + * Read session details + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * + * Output: + * BranchExecuted + * SessionDetails + * ChangedBy + * ChangedTime + * Location + */ +void +userTransaction_T3(UserHandle * uh, + SubscriberNumber inNumber, + ServerId inServerId, + ServerBit inServerBit, + SessionDetails outSessionDetails, + BranchExecuted * outBranchExecuted){ + Ndb * pNDB = uh->pNDB; + + char outChangedBy [sizeof(ChangedBy) +(4-(sizeof(ChangedBy) & 3))]; + char outChangedTime [sizeof(ChangedTime)+(4-(sizeof(ChangedTime) & 3))]; + Location outLocation; + GroupId groupId; + ActiveSessions sessions; + Permission permission; + SubscriberSuffix inSuffix; + + DEBUG3("T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = startTransaction(pNDB, inServerId, inNumber); + if (MyTransaction == NULL) + error_handler("T3-1: startTranscation", pNDB->getNdbErrorString(), pNDB->getNdbError()); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T3-1: getNdbOperation", + MyTransaction); + + MyOperation->readTuple(); + MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&outLocation); + MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-1: NoCommit", + MyTransaction); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T3-2: getNdbOperation", + MyTransaction); + + + MyOperation->readTuple(); + MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + MyOperation->getValue(IND_GROUP_ALLOW_READ, + (char *)&permission); + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T3-2: NoCommit", + MyTransaction); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + memcpy(inSuffix, + &inNumber[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH], SUBSCRIBER_NUMBER_SUFFIX_LENGTH); + DEBUG2("reading(%.*s) - ", SUBSCRIBER_NUMBER_SUFFIX_LENGTH, inSuffix); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T3-3: getNdbOperation", + MyTransaction); + + MyOperation->simpleRead(); + + MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + MyOperation->getValue(IND_SESSION_DATA, + (char *)outSessionDetails); + /* Operation 4 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T3-4: getNdbOperation", + MyTransaction); + + MyOperation->interpretedUpdateTuple(); + MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + MyOperation->incValue(IND_SERVER_READS, (uint32)1); + (* outBranchExecuted) = 1; + } else { + (* outBranchExecuted) = 0; + } + DEBUG("commit..."); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T3: Commit", + MyTransaction); + + pNDB->closeTransaction(MyTransaction); + + DEBUG("done\n"); +} + + +/** + * Transaction 4 - T4 + * + * Create session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * SessionDetails, + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +void +userTransaction_T4(UserHandle * uh, + SubscriberNumber inNumber, + ServerId inServerId, + ServerBit inServerBit, + SessionDetails inSessionDetails, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted){ + + Ndb * pNDB = uh->pNDB; + + char outChangedBy [sizeof(ChangedBy) +(4-(sizeof(ChangedBy) & 3))]; + char outChangedTime [sizeof(ChangedTime)+(4-(sizeof(ChangedTime) & 3))]; + Location outLocation; + GroupId groupId; + ActiveSessions sessions; + Permission permission; + SubscriberSuffix inSuffix; + + DEBUG3("T4(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + int check; + NdbRecAttr * check2; + + NdbConnection * MyTransaction = startTransaction(pNDB, inServerId, inNumber); + if (MyTransaction == NULL) + error_handler("T4-1: startTranscation", pNDB->getNdbErrorString(), pNDB->getNdbError()); + + NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T4-1: getNdbOperation", + MyTransaction); + + MyOperation->interpretedUpdateTuple(); + MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&outLocation); + MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + outChangedBy); + MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + outChangedTime); + MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + MyOperation->incValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + check = MyTransaction->execute( NoCommit ); + + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T4-2: getNdbOperation", + MyTransaction); + + MyOperation->readTuple(); + MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + MyOperation->getValue(IND_GROUP_ALLOW_INSERT, + (char *)&permission); + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T4-2: NoCommit", + MyTransaction); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == 0)){ + + memcpy(inSuffix, + &inNumber[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH], SUBSCRIBER_NUMBER_SUFFIX_LENGTH); + + DEBUG2("inserting(%.*s) - ", SUBSCRIBER_NUMBER_SUFFIX_LENGTH, inSuffix); + + /* Operation 3 */ + + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T4-3: getNdbOperation", + MyTransaction); + + MyOperation->insertTuple(); + MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + MyOperation->setValue(SESSION_DATA, + (char *)inSessionDetails); + /* Operation 4 */ + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T4-5: getNdbOperation", + MyTransaction); + + MyOperation->interpretedUpdateTuple(); + MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + MyOperation->incValue(IND_SERVER_INSERTS, (uint32)1); + (* outBranchExecuted) = 1; + } else { + (* outBranchExecuted) = 0; + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + } + + if(!inDoRollback && (* outBranchExecuted)){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T4: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T4:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); +} + + +/** + * Transaction 5 - T5 + * + * Delete session + * + * Input: + * SubscriberNumber + * ServerId + * ServerBit + * DoRollback + * Output: + * ChangedBy + * ChangedTime + * Location + * BranchExecuted + */ +void +userTransaction_T5(UserHandle * uh, + SubscriberNumber inNumber, + ServerId inServerId, + ServerBit inServerBit, + DoRollback inDoRollback, + BranchExecuted * outBranchExecuted){ + Ndb * pNDB = uh->pNDB; + + DEBUG3("T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId); + + NdbConnection * MyTransaction = 0; + NdbOperation * MyOperation = 0; + + char outChangedBy [sizeof(ChangedBy) +(4-(sizeof(ChangedBy) & 3))]; + char outChangedTime [sizeof(ChangedTime)+(4-(sizeof(ChangedTime) & 3))]; + Location outLocation; + GroupId groupId; + ActiveSessions sessions; + Permission permission; + SubscriberSuffix inSuffix; + + int check; + NdbRecAttr * check2; + + MyTransaction = pNDB->startTransaction(); + if (MyTransaction == NULL) + error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), pNDB->getNdbError()); + + MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "T5-1: getNdbOperation", + MyTransaction); + + MyOperation->interpretedUpdateTuple(); + MyOperation->equal(IND_SUBSCRIBER_NUMBER, + inNumber); + MyOperation->getValue(IND_SUBSCRIBER_LOCATION, + (char *)&outLocation); + MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY, + &outChangedBy[0]); + MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME, + &outChangedTime[0]); + MyOperation->getValue(IND_SUBSCRIBER_GROUP, + (char *)&groupId); + MyOperation->getValue(IND_SUBSCRIBER_SESSIONS, + (char *)&sessions); + MyOperation->subValue(IND_SUBSCRIBER_SESSIONS, + (uint32)inServerBit); + MyTransaction->execute( NoCommit ); + /* Operation 2 */ + + MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "T5-2: getNdbOperation", + MyTransaction); + + MyOperation->readTuple(); + MyOperation->equal(IND_GROUP_ID, + (char*)&groupId); + MyOperation->getValue(IND_GROUP_ALLOW_DELETE, + (char *)&permission); + check = MyTransaction->execute( NoCommit ); + CHECK_MINUS_ONE(check, "T5-2: NoCommit", + MyTransaction); + + if(((permission & inServerBit) == inServerBit) && + ((sessions & inServerBit) == inServerBit)){ + + memcpy(inSuffix, + &inNumber[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH], SUBSCRIBER_NUMBER_SUFFIX_LENGTH); + + DEBUG2("deleting(%.*s) - ", SUBSCRIBER_NUMBER_SUFFIX_LENGTH, inSuffix); + + /* Operation 3 */ + MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE); + CHECK_NULL(MyOperation, "T5-3: getNdbOperation", + MyTransaction); + + MyOperation->deleteTuple(); + MyOperation->equal(IND_SESSION_SUBSCRIBER, + (char*)inNumber); + MyOperation->equal(IND_SESSION_SERVER, + (char*)&inServerId); + /* Operation 4 */ + + /* Operation 5 */ + MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "T5-5: getNdbOperation", + MyTransaction); + + + MyOperation->interpretedUpdateTuple(); + MyOperation->equal(IND_SERVER_ID, + (char*)&inServerId); + MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX, + (char*)inSuffix); + MyOperation->incValue(IND_SERVER_DELETES, (uint32)1); + (* outBranchExecuted) = 1; + } else { + (* outBranchExecuted) = 0; + DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - ")); + DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - ")); + } + + if(!inDoRollback && (* outBranchExecuted)){ + DEBUG("commit\n"); + check = MyTransaction->execute( Commit ); + CHECK_MINUS_ONE(check, "T5: Commit", + MyTransaction); + } else { + DEBUG("rollback\n"); + check = MyTransaction->execute(Rollback); + CHECK_MINUS_ONE(check, "T5:Rollback", + MyTransaction); + + } + + pNDB->closeTransaction(MyTransaction); +} + diff --git a/ndb/test/ndbapi/bench/testData.h b/ndb/test/ndbapi/bench/testData.h new file mode 100644 index 00000000000..3db85e7342e --- /dev/null +++ b/ndb/test/ndbapi/bench/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/ndb/test/ndbapi/bench/testDefinitions.h b/ndb/test/ndbapi/bench/testDefinitions.h new file mode 100644 index 00000000000..2f4aeb30975 --- /dev/null +++ b/ndb/test/ndbapi/bench/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/ndb/test/ndbapi/bench/userInterface.cpp b/ndb/test/ndbapi/bench/userInterface.cpp new file mode 100644 index 00000000000..683552c3133 --- /dev/null +++ b/ndb/test/ndbapi/bench/userInterface.cpp @@ -0,0 +1,744 @@ +/* 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 "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; +#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, + 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 + +UserHandle* +userDbConnect(uint32 createDb, char *dbName) +{ + Ndb_cluster_connection *con= new Ndb_cluster_connection(); + if(con->connect(12, 5, 1) != 0) + { + ndbout << "Unable to connect to management server." << endl; + return 0; + } + if (con->wait_until_ready(30,0) < 0) + { + ndbout << "Cluster nodes not ready in 30 seconds." << endl; + return 0; + } + + Ndb * pNdb = new Ndb(con, dbName); + + //printf("Initializing...\n"); + pNdb->init(); + + //printf("Waiting..."); + while(pNdb->waitUntilReady() != 0){ + //printf("..."); + } + // printf("done\n"); + + if( createDb ) + dbCreate(pNdb); + + + UserHandle * uh = new UserHandle; + uh->pNCC = con; + uh->pNDB = pNdb; + uh->pCurrTrans = 0; + + return uh; +} + +void userDbDisconnect(UserHandle *uh) +{ + delete uh; +} + +int userDbInsertServer(UserHandle *uh, + ServerId serverId, + SubscriberSuffix suffix, + ServerName name) +{ + int check; + + uint32 noOfRead = 0; + uint32 noOfInsert = 0; + uint32 noOfDelete = 0; + + NdbConnection * MyTransaction = 0; + if(uh->pCurrTrans != 0){ + MyTransaction = uh->pCurrTrans; + } else { + uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction(); + } + if (MyTransaction == NULL) + error_handler("startTranscation", uh->pNDB->getNdbError(), 0); + + NdbOperation *MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE); + CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction); + + check = MyOperation->insertTuple(); + CHECK_MINUS_ONE(check, "insert tuple", MyTransaction); + + check = MyOperation->equal(SERVER_ID, (char*)&serverId); + CHECK_MINUS_ONE(check, "setValue id", MyTransaction); + + check = MyOperation->setValue(SERVER_SUBSCRIBER_SUFFIX, suffix); + CHECK_MINUS_ONE(check, "setValue suffix", MyTransaction); + + check = MyOperation->setValue(SERVER_NAME, name); + CHECK_MINUS_ONE(check, "setValue name", MyTransaction); + + check = MyOperation->setValue(SERVER_READS, (char*)&noOfRead); + CHECK_MINUS_ONE(check, "setValue reads", MyTransaction); + + check = MyOperation->setValue(SERVER_INSERTS, (char*)&noOfInsert); + CHECK_MINUS_ONE(check, "setValue inserts", MyTransaction); + + check = MyOperation->setValue(SERVER_DELETES, (char*)&noOfDelete); + CHECK_MINUS_ONE(check, "setValue deletes", MyTransaction); + + return 0; +} + +int userDbInsertSubscriber(UserHandle *uh, + SubscriberNumber number, + uint32 groupId, + SubscriberName name) +{ + int check; + uint32 activeSessions = 0; + Location l = 0; + ChangedBy changedBy; snprintf(changedBy, sizeof(changedBy), "ChangedBy"); + ChangedTime changedTime; snprintf(changedTime, sizeof(changedTime), "ChangedTime"); + + NdbConnection * MyTransaction = 0; + if(uh->pCurrTrans != 0){ + MyTransaction = uh->pCurrTrans; + } else { + uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction(); + } + if (MyTransaction == NULL) + error_handler("startTranscation", uh->pNDB->getNdbError(), 0); + + NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE); + CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction); + + check = MyOperation->insertTuple(); + CHECK_MINUS_ONE(check, "insertTuple", MyTransaction); + + check = MyOperation->equal(SUBSCRIBER_NUMBER, number); + CHECK_MINUS_ONE(check, "equal", MyTransaction); + + check = MyOperation->setValue(SUBSCRIBER_NAME, name); + CHECK_MINUS_ONE(check, "setValue name", MyTransaction); + + check = MyOperation->setValue(SUBSCRIBER_GROUP, (char*)&groupId); + CHECK_MINUS_ONE(check, "setValue group", MyTransaction); + + check = MyOperation->setValue(SUBSCRIBER_LOCATION, (char*)&l); + CHECK_MINUS_ONE(check, "setValue location", MyTransaction); + + check = MyOperation->setValue(SUBSCRIBER_SESSIONS, (char*)&activeSessions); + CHECK_MINUS_ONE(check, "setValue sessions", MyTransaction); + + check = MyOperation->setValue(SUBSCRIBER_CHANGED_BY, changedBy); + CHECK_MINUS_ONE(check, "setValue changedBy", MyTransaction); + + check = MyOperation->setValue(SUBSCRIBER_CHANGED_TIME, changedTime); + CHECK_MINUS_ONE(check, "setValue changedTime", MyTransaction); + + return 0; +} + +int userDbInsertGroup(UserHandle *uh, + GroupId groupId, + GroupName name, + Permission allowRead, + Permission allowInsert, + Permission allowDelete) +{ + int check; + + NdbConnection * MyTransaction = 0; + if(uh->pCurrTrans != 0){ + MyTransaction = uh->pCurrTrans; + } else { + uh->pCurrTrans = MyTransaction = uh->pNDB->startTransaction(); + } + if (MyTransaction == NULL) + error_handler("startTranscation", uh->pNDB->getNdbError(), 0); + + NdbOperation *MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE); + CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction); + + check = MyOperation->insertTuple(); + CHECK_MINUS_ONE(check, "insertTuple", MyTransaction); + + check = MyOperation->equal(GROUP_ID, (char*)&groupId); + CHECK_MINUS_ONE(check, "equal", MyTransaction); + + check = MyOperation->setValue(GROUP_NAME, name); + CHECK_MINUS_ONE(check, "setValue name", MyTransaction); + + check = MyOperation->setValue(GROUP_ALLOW_READ, (char*)&allowRead); + CHECK_MINUS_ONE(check, "setValue allowRead", MyTransaction); + + check = MyOperation->setValue(GROUP_ALLOW_INSERT, (char*)&allowInsert); + CHECK_MINUS_ONE(check, "setValue allowInsert", MyTransaction); + + check = MyOperation->setValue(GROUP_ALLOW_DELETE, (char*)&allowDelete); + CHECK_MINUS_ONE(check, "setValue allowDelete", MyTransaction); + + return 0; +} + diff --git a/ndb/test/ndbapi/bench/userInterface.h b/ndb/test/ndbapi/bench/userInterface.h new file mode 100644 index 00000000000..9e3b6f8f2a5 --- /dev/null +++ b/ndb/test/ndbapi/bench/userInterface.h @@ -0,0 +1,151 @@ +/* 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 + + + +/***************************************************************/ +/* 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_cluster_connection* pNCC; + 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); + +#ifdef __cplusplus +} +#endif + +/*************************************************************** +* E X T E R N A L D A T A * +***************************************************************/ + +#endif /* DBINTERFACE_H */ + diff --git a/ndb/test/ndbapi/benchronja.cpp b/ndb/test/ndbapi/benchronja.cpp index 91b2a041186..a7523e8e416 100644 --- a/ndb/test/ndbapi/benchronja.cpp +++ b/ndb/test/ndbapi/benchronja.cpp @@ -984,7 +984,6 @@ void* ThreadExec(void* ThreadData){ delete pMyNdb; pMyNdb = NULL ; ThreadReady[thread_no] = 1; - NdbThread_Exit(0) ; return 0 ; }//if @@ -1197,7 +1196,6 @@ void* ThreadExec(void* ThreadData){ } // for(;;) delete pMyNdb ; - NdbThread_Exit(0) ; - return 0 ; // Compiler is happy now + return 0 ; } diff --git a/ndb/test/ndbapi/flexAsynch.cpp b/ndb/test/ndbapi/flexAsynch.cpp index 1953444d640..4b87b2c70ed 100644 --- a/ndb/test/ndbapi/flexAsynch.cpp +++ b/ndb/test/ndbapi/flexAsynch.cpp @@ -494,8 +494,7 @@ threadLoop(void* ThreadData) delete localNdb; ThreadReady[threadNo] = 1; - NdbThread_Exit(0); - return NULL; // Just to keep compiler happy + return NULL; }//threadLoop() static diff --git a/ndb/test/ndbapi/flexBench.cpp b/ndb/test/ndbapi/flexBench.cpp index 2a2388109a1..cc2bfb391da 100644 --- a/ndb/test/ndbapi/flexBench.cpp +++ b/ndb/test/ndbapi/flexBench.cpp @@ -617,7 +617,7 @@ static void* flexBenchThread(void* pArg) free(attrRefValue) ; free(pOps) ; delete pNdb ; - NdbThread_Exit(0) ; + return 0; // thread exits } pNdb->init(); @@ -934,8 +934,7 @@ static void* flexBenchThread(void* pArg) free(longKeyAttrValue); } // if - NdbThread_Exit(0); - return NULL; // Just to keep compiler happy + return NULL; // Thread exits } diff --git a/ndb/test/ndbapi/flexHammer.cpp b/ndb/test/ndbapi/flexHammer.cpp index 688e70d501a..13cd2d5e561 100644 --- a/ndb/test/ndbapi/flexHammer.cpp +++ b/ndb/test/ndbapi/flexHammer.cpp @@ -612,10 +612,7 @@ flexHammerThread(void* pArg) flexHammerErrorData->resetErrorCounters(); - // And exit using NDBT - NdbThread_Exit(0); - - return NULL; + return NULL; // thread exits } // flexHammerThread diff --git a/ndb/test/ndbapi/flexScan.cpp b/ndb/test/ndbapi/flexScan.cpp index c7f4041a525..4d2c85d6955 100644 --- a/ndb/test/ndbapi/flexScan.cpp +++ b/ndb/test/ndbapi/flexScan.cpp @@ -701,8 +701,7 @@ flexScanThread(void* ThreadData) free(pkValue); } // if - NdbThread_Exit(0); - return NULL; + return NULL; // thread exits } // flexScanThread diff --git a/ndb/test/ndbapi/flexTT.cpp b/ndb/test/ndbapi/flexTT.cpp index 3b976f9f87e..8d5be2bb399 100644 --- a/ndb/test/ndbapi/flexTT.cpp +++ b/ndb/test/ndbapi/flexTT.cpp @@ -389,8 +389,7 @@ threadLoop(void* ThreadData) delete localNdb; ThreadReady[loc_threadNo] = 1; - NdbThread_Exit(0); - return NULL; // Just to keep compiler happy + return NULL; // Thread exits }//threadLoop() static diff --git a/ndb/test/ndbapi/flexTimedAsynch.cpp b/ndb/test/ndbapi/flexTimedAsynch.cpp index 27380cc79fd..2b8c0bdd5f8 100644 --- a/ndb/test/ndbapi/flexTimedAsynch.cpp +++ b/ndb/test/ndbapi/flexTimedAsynch.cpp @@ -406,9 +406,8 @@ threadLoop(void* ThreadData) delete localNdb; ThreadReady[threadNo] = 1; - NdbThread_Exit(0); - return NULL; + return NULL; // thread exits } void executeThread(StartType aType, Ndb* aNdbObject, ThreadNdb* threadInfo) diff --git a/ndb/test/ndbapi/flex_bench_mysql.cpp b/ndb/test/ndbapi/flex_bench_mysql.cpp index c8d4d85bedf..c15175bfb00 100644 --- a/ndb/test/ndbapi/flex_bench_mysql.cpp +++ b/ndb/test/ndbapi/flex_bench_mysql.cpp @@ -710,7 +710,7 @@ static void* flexBenchThread(void* pArg) the_socket_name, 0) == NULL ) { ndbout << "failed" << endl; - NdbThread_Exit(0) ; + return 0; } ndbout << "ok" << endl; @@ -722,7 +722,7 @@ static void* flexBenchThread(void* pArg) if (r) { ndbout << "autocommit on/off failed" << endl; - NdbThread_Exit(0) ; + return 0; } } #endif @@ -741,7 +741,7 @@ static void* flexBenchThread(void* pArg) ndbout << threadNo << endl ; ndbout << "Thread #" << threadNo << " will now exit" << endl ; tResult = 13 ; - NdbThread_Exit(0) ; + return 0; } if (use_ndb) { @@ -750,7 +750,7 @@ static void* flexBenchThread(void* pArg) ndbout << "Failed to get an NDB object" << endl; ndbout << "Thread #" << threadNo << " will now exit" << endl ; tResult = 13; - NdbThread_Exit(0) ; + return 0; } pNdb->waitUntilReady(); return_ndb_object(pNdb, ndb_id); @@ -900,11 +900,11 @@ static void* flexBenchThread(void* pArg) prep_insert[i] = mysql_prepare(&mysql, buf, pos); if (prep_insert[i] == 0) { ndbout << "mysql_prepare: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_param(prep_insert[i], bind_insert)) { ndbout << "mysql_bind_param: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } } @@ -926,11 +926,11 @@ static void* flexBenchThread(void* pArg) prep_update[i] = mysql_prepare(&mysql, buf, pos); if (prep_update[i] == 0) { ndbout << "mysql_prepare: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_param(prep_update[i], bind_update)) { ndbout << "mysql_bind_param: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } } @@ -953,15 +953,15 @@ static void* flexBenchThread(void* pArg) prep_read[i] = mysql_prepare(&mysql, buf, pos); if (prep_read[i] == 0) { ndbout << "mysql_prepare: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_param(prep_read[i], bind_read)) { ndbout << "mysql_bind_param: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_result(prep_read[i], &bind_read[1])) { ndbout << "mysql_bind_result: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } } @@ -978,11 +978,11 @@ static void* flexBenchThread(void* pArg) prep_delete[i] = mysql_prepare(&mysql, buf, pos); if (prep_delete[i] == 0) { ndbout << "mysql_prepare: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } if (mysql_bind_param(prep_delete[i], bind_delete)) { ndbout << "mysql_bind_param: " << mysql_error(&mysql) << endl; - NdbThread_Exit(0) ; + return 0; } } } @@ -1431,8 +1431,7 @@ static void* flexBenchThread(void* pArg) ndbout << "I got here " << endl; return_ndb_object(pNdb, ndb_id); } - NdbThread_Exit(0); - return NULL; // Just to keep compiler happy + return NULL; } diff --git a/ndb/test/ndbapi/mainAsyncGenerator.cpp b/ndb/test/ndbapi/mainAsyncGenerator.cpp index 16cb50e160f..73a8b98ab57 100644 --- a/ndb/test/ndbapi/mainAsyncGenerator.cpp +++ b/ndb/test/ndbapi/mainAsyncGenerator.cpp @@ -274,8 +274,6 @@ threadRoutine(void *arg) asyncDbDisconnect(pNDB); - NdbThread_Exit(0); - return NULL; } diff --git a/ndb/test/ndbapi/old_dirs/flexBench/Makefile_old b/ndb/test/ndbapi/old_dirs/flexBench/Makefile_old deleted file mode 100644 index bfff5cd161a..00000000000 --- a/ndb/test/ndbapi/old_dirs/flexBench/Makefile_old +++ /dev/null @@ -1,11 +0,0 @@ -include .defs.mk - -TYPE := ndbapitest - -BIN_TARGET := flexBench - -# Source files of non-templated classes (.C files) -SOURCES = flexBench.cpp - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp index 41bb82f3e06..7b30777456f 100644 --- a/ndb/test/ndbapi/testBlobs.cpp +++ b/ndb/test/ndbapi/testBlobs.cpp @@ -22,13 +22,15 @@ #include <NdbMain.h> #include <NdbOut.hpp> #include <NdbTest.hpp> +#include <NdbTick.h> +#include <ndb/src/ndbapi/NdbBlobImpl.hpp> struct Bcol { bool m_nullable; unsigned m_inline; unsigned m_partsize; unsigned m_stripe; - char m_btname[NdbBlob::BlobTableNameSize]; + char m_btname[NdbBlobImpl::BlobTableNameSize]; Bcol(bool a, unsigned b, unsigned c, unsigned d) : m_nullable(a), m_inline(b), @@ -42,13 +44,14 @@ struct Opt { bool m_core; bool m_dbg; bool m_dbgall; + const char* m_dbug; bool m_full; unsigned m_loop; unsigned m_parts; unsigned m_rows; unsigned m_seed; const char* m_skip; - const char* m_style; + const char* m_test; // metadata const char* m_tname; const char* m_x1name; // hash index @@ -58,6 +61,9 @@ struct Opt { bool m_oneblob; Bcol m_blob1; Bcol m_blob2; + // perf + const char* m_tnameperf; + unsigned m_rowsperf; // bugs int m_bug; int (*m_bugtest)(); @@ -66,13 +72,14 @@ struct Opt { m_core(false), m_dbg(false), m_dbgall(false), + m_dbug(0), m_full(false), m_loop(1), m_parts(10), m_rows(100), m_seed(0), - m_skip(""), - m_style("012"), + m_skip(0), + m_test(0), // metadata m_tname("TBLOB1"), m_x1name("TBLOB1X1"), @@ -82,6 +89,9 @@ struct Opt { m_oneblob(false), m_blob1(false, 7, 1137, 10), m_blob2(true, 99, 55, 1), + // perf + m_tnameperf("TBLOB2"), + m_rowsperf(10000), // bugs m_bug(0), m_bugtest(0) { @@ -100,48 +110,51 @@ printusage() << " -core dump core on error" << endl << " -dbg print debug" << endl << " -dbgall print also NDB API debug (if compiled in)" << endl + << " -dbug opt dbug options" << endl << " -full read/write only full blob values" << endl - << " -inline read/write only blobs which fit inline" << endl << " -loop N loop N times 0=forever [" << d.m_loop << "]" << endl << " -parts N max parts in blob value [" << d.m_parts << "]" << endl << " -rows N number of rows [" << d.m_rows << "]" << endl + << " -rowsperf N rows for performace test [" << d.m_rowsperf << "]" << endl << " -seed N random seed 0=loop number [" << d.m_seed << "]" << endl - << " -skip xxx skip these tests (see list) [" << d.m_skip << endl - << " -style xxx access styles to test (see list) [" << d.m_style << "]" << endl + << " -skip xxx skip given tests (see list) [no tests]" << endl + << " -test xxx only given tests (see list) [all tests]" << endl << "metadata" << endl << " -pk2len N length of PK2 [" << d.m_pk2len << "/" << g_max_pk2len <<"]" << endl << " -oneblob only 1 blob attribute [default 2]" << endl - << "testcases for -skip" << endl + << "testcases for test/skip" << endl << " k primary key ops" << endl << " i hash index ops" << endl << " s table scans" << endl << " r ordered index scans" << endl - << " u update blob value" << endl - << "access styles for -style" << endl + << " p performance test" << endl + << "additional flags for test/skip" << endl + << " u update existing blob value" << endl + << " n normal insert and update" << endl + << " w insert and update using writeTuple" << endl << " 0 getValue / setValue" << endl << " 1 setActiveHook" << endl << " 2 readData / writeData" << endl << "bug tests (no blob test)" << endl << " -bug 4088 ndb api hang with mixed ops on index table" << endl - << " -bug 2222 delete + write gives 626" << endl - << " -bug 3333 acc crash on delete and long key" << endl + << " -bug nnnn delete + write gives 626" << endl + << " -bug nnnn acc crash on delete and long key" << endl ; } static Opt g_opt; static bool -skipcase(int x) +testcase(char x) { - return strchr(g_opt.m_skip, x) != 0; -} - -static bool -skipstyle(int x) -{ - return strchr(g_opt.m_style, '0' + x) == 0; + if (x < 10) + x += '0'; + return + (g_opt.m_test == 0 || strchr(g_opt.m_test, x) != 0) && + (g_opt.m_skip == 0 || strchr(g_opt.m_skip, x) == 0); } +static Ndb_cluster_connection* g_ncc = 0; static Ndb* g_ndb = 0; static NdbDictionary::Dictionary* g_dic = 0; static NdbConnection* g_con = 0; @@ -435,7 +448,9 @@ getBlobLength(NdbBlob* h, unsigned& len) CHK(h->getLength(len2) == 0); len = (unsigned)len2; assert(len == len2); - DBG("getBlobLength " << h->getColumn()->getName() << " len=" << len); + bool isNull; + CHK(h->getNull(isNull) == 0); + DBG("getBlobLength " << h->getColumn()->getName() << " len=" << len << " null=" << isNull); return 0; } @@ -912,6 +927,41 @@ updatePk(int style) } static int +writePk(int style) +{ + DBG("--- writePk " << stylename[style] << " ---"); + for (unsigned k = 0; k < g_opt.m_rows; k++) { + Tup& tup = g_tups[k]; + DBG("writePk pk1=" << hex << tup.m_pk1); + CHK((g_con = g_ndb->startTransaction()) != 0); + CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0); + CHK(g_opr->writeTuple() == 0); + CHK(g_opr->equal("PK1", tup.m_pk1) == 0); + if (g_opt.m_pk2len != 0) + CHK(g_opr->equal("PK2", tup.m_pk2) == 0); + CHK(getBlobHandles(g_opr) == 0); + if (style == 0) { + CHK(setBlobValue(tup) == 0); + } else if (style == 1) { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); + CHK(setBlobWriteHook(tup) == 0); + } else { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); + CHK(g_con->execute(NoCommit) == 0); + CHK(writeBlobData(tup) == 0); + } + CHK(g_con->execute(Commit) == 0); + g_ndb->closeTransaction(g_con); + g_opr = 0; + g_con = 0; + tup.m_exists = true; + } + return 0; +} + +static int deletePk() { DBG("--- deletePk ---"); @@ -996,6 +1046,39 @@ updateIdx(int style) } static int +writeIdx(int style) +{ + DBG("--- writeIdx " << stylename[style] << " ---"); + for (unsigned k = 0; k < g_opt.m_rows; k++) { + Tup& tup = g_tups[k]; + DBG("writeIdx pk1=" << hex << tup.m_pk1); + CHK((g_con = g_ndb->startTransaction()) != 0); + CHK((g_opx = g_con->getNdbIndexOperation(g_opt.m_x1name, g_opt.m_tname)) != 0); + CHK(g_opx->writeTuple() == 0); + CHK(g_opx->equal("PK2", tup.m_pk2) == 0); + CHK(getBlobHandles(g_opx) == 0); + if (style == 0) { + CHK(setBlobValue(tup) == 0); + } else if (style == 1) { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); + CHK(setBlobWriteHook(tup) == 0); + } else { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); + CHK(g_con->execute(NoCommit) == 0); + CHK(writeBlobData(tup) == 0); + } + CHK(g_con->execute(Commit) == 0); + g_ndb->closeTransaction(g_con); + g_opx = 0; + g_con = 0; + tup.m_exists = true; + } + return 0; +} + +static int deleteIdx() { DBG("--- deleteIdx ---"); @@ -1167,11 +1250,17 @@ deleteScan(bool idx) // main +// from here on print always +#undef DBG +#define DBG(x) \ + do { \ + ndbout << "line " << __LINE__ << " " << x << endl; \ + } while (0) + static int testmain() { - int style; - g_ndb = new Ndb("TEST_DB"); + g_ndb = new Ndb(g_ncc, "TEST_DB"); CHK(g_ndb->init() == 0); CHK(g_ndb->waitUntilReady() == 0); g_dic = g_ndb->getDictionary(); @@ -1194,55 +1283,88 @@ testmain() if (g_opt.m_seed != 0) srandom(g_opt.m_seed); for (g_loop = 0; g_opt.m_loop == 0 || g_loop < g_opt.m_loop; g_loop++) { + int style; DBG("=== loop " << g_loop << " ==="); if (g_opt.m_seed == 0) srandom(g_loop); // pk for (style = 0; style <= 2; style++) { - if (skipcase('k') || skipstyle(style)) + if (! testcase('k') || ! testcase(style)) continue; DBG("--- pk ops " << stylename[style] << " ---"); - calcTups(false); - CHK(insertPk(style) == 0); - CHK(verifyBlob() == 0); - CHK(readPk(style) == 0); - if (! skipcase('u')) { - calcTups(style); - CHK(updatePk(style) == 0); + if (testcase('n')) { + calcTups(false); + CHK(insertPk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readPk(style) == 0); + if (testcase('u')) { + calcTups(style); + CHK(updatePk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readPk(style) == 0); + } + CHK(deletePk() == 0); + CHK(verifyBlob() == 0); + } + if (testcase('w')) { + calcTups(false); + CHK(writePk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readPk(style) == 0); + if (testcase('u')) { + calcTups(style); + CHK(writePk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readPk(style) == 0); + } + CHK(deletePk() == 0); CHK(verifyBlob() == 0); } - CHK(readPk(style) == 0); - CHK(deletePk() == 0); - CHK(verifyBlob() == 0); } // hash index for (style = 0; style <= 2; style++) { - if (skipcase('i') || skipstyle(style)) + if (! testcase('i') || ! testcase(style)) continue; DBG("--- idx ops " << stylename[style] << " ---"); - calcTups(false); - CHK(insertPk(style) == 0); - CHK(verifyBlob() == 0); - CHK(readIdx(style) == 0); - calcTups(style); - if (! skipcase('u')) { - CHK(updateIdx(style) == 0); + if (testcase('n')) { + calcTups(false); + CHK(insertPk(style) == 0); CHK(verifyBlob() == 0); CHK(readIdx(style) == 0); + if (testcase('u')) { + calcTups(style); + CHK(updateIdx(style) == 0); + CHK(verifyBlob() == 0); + CHK(readIdx(style) == 0); + } + CHK(deleteIdx() == 0); + CHK(verifyBlob() == 0); + } + if (testcase('w')) { + calcTups(false); + CHK(writePk(style) == 0); + CHK(verifyBlob() == 0); + CHK(readIdx(style) == 0); + if (testcase('u')) { + calcTups(style); + CHK(writeIdx(style) == 0); + CHK(verifyBlob() == 0); + CHK(readIdx(style) == 0); + } + CHK(deleteIdx() == 0); + CHK(verifyBlob() == 0); } - CHK(deleteIdx() == 0); - CHK(verifyBlob() == 0); } // scan table for (style = 0; style <= 2; style++) { - if (skipcase('s') || skipstyle(style)) + if (! testcase('s') || ! testcase(style)) continue; DBG("--- table scan " << stylename[style] << " ---"); calcTups(false); CHK(insertPk(style) == 0); CHK(verifyBlob() == 0); CHK(readScan(style, false) == 0); - if (! skipcase('u')) { + if (testcase('u')) { CHK(updateScan(style, false) == 0); CHK(verifyBlob() == 0); } @@ -1251,14 +1373,14 @@ testmain() } // scan index for (style = 0; style <= 2; style++) { - if (skipcase('r') || skipstyle(style)) + if (! testcase('r') || ! testcase(style)) continue; DBG("--- index scan " << stylename[style] << " ---"); calcTups(false); CHK(insertPk(style) == 0); CHK(verifyBlob() == 0); CHK(readScan(style, true) == 0); - if (! skipcase('u')) { + if (testcase('u')) { CHK(updateScan(style, true) == 0); CHK(verifyBlob() == 0); } @@ -1270,6 +1392,292 @@ testmain() return 0; } +// separate performance test + +struct Tmr { // stolen from testOIBasic + Tmr() { + clr(); + } + void clr() { + m_on = m_ms = m_cnt = m_time[0] = m_text[0] = 0; + } + void on() { + assert(m_on == 0); + m_on = NdbTick_CurrentMillisecond(); + } + void off(unsigned cnt = 0) { + NDB_TICKS off = NdbTick_CurrentMillisecond(); + assert(m_on != 0 && off >= m_on); + m_ms += off - m_on; + m_cnt += cnt; + m_on = 0; + } + const char* time() { + if (m_cnt == 0) + sprintf(m_time, "%u ms", m_ms); + else + sprintf(m_time, "%u ms per %u ( %u ms per 1000 )", m_ms, m_cnt, (1000 * m_ms) / m_cnt); + return m_time; + } + const char* pct (const Tmr& t1) { + if (0 < t1.m_ms) + sprintf(m_text, "%u pct", (100 * m_ms) / t1.m_ms); + else + sprintf(m_text, "[cannot measure]"); + return m_text; + } + const char* over(const Tmr& t1) { + if (0 < t1.m_ms) { + if (t1.m_ms <= m_ms) + sprintf(m_text, "%u pct", (100 * (m_ms - t1.m_ms)) / t1.m_ms); + else + sprintf(m_text, "-%u pct", (100 * (t1.m_ms - m_ms)) / t1.m_ms); + } else + sprintf(m_text, "[cannot measure]"); + return m_text; + } + NDB_TICKS m_on; + unsigned m_ms; + unsigned m_cnt; + char m_time[100]; + char m_text[100]; +}; + +static int +testperf() +{ + if (! testcase('p')) + return 0; + DBG("=== perf test ==="); + g_ndb = new Ndb(g_ncc, "TEST_DB"); + CHK(g_ndb->init() == 0); + CHK(g_ndb->waitUntilReady() == 0); + g_dic = g_ndb->getDictionary(); + NdbDictionary::Table tab(g_opt.m_tnameperf); + if (g_dic->getTable(tab.getName()) != 0) + CHK(g_dic->dropTable(tab) == 0); + // col A - pk + { NdbDictionary::Column col("A"); + col.setType(NdbDictionary::Column::Unsigned); + col.setPrimaryKey(true); + tab.addColumn(col); + } + // col B - char 20 + { NdbDictionary::Column col("B"); + col.setType(NdbDictionary::Column::Char); + col.setLength(20); + col.setNullable(true); + tab.addColumn(col); + } + // col C - text + { NdbDictionary::Column col("C"); + col.setType(NdbDictionary::Column::Text); + col.setInlineSize(20); + col.setPartSize(512); + col.setStripeSize(1); + col.setNullable(true); + tab.addColumn(col); + } + // create + CHK(g_dic->createTable(tab) == 0); + Uint32 cA = 0, cB = 1, cC = 2; + // timers + Tmr t1; + Tmr t2; + // insert char (one trans) + { + DBG("--- insert char ---"); + t1.on(); + CHK((g_con = g_ndb->startTransaction()) != 0); + for (Uint32 k = 0; k < g_opt.m_rowsperf; k++) { + CHK((g_opr = g_con->getNdbOperation(tab.getName())) != 0); + CHK(g_opr->insertTuple() == 0); + CHK(g_opr->equal(cA, (char*)&k) == 0); + CHK(g_opr->setValue(cB, "b") == 0); + CHK(g_con->execute(NoCommit) == 0); + } + t1.off(g_opt.m_rowsperf); + CHK(g_con->execute(Rollback) == 0); + DBG(t1.time()); + g_opr = 0; + g_con = 0; + } + // insert text (one trans) + { + DBG("--- insert text ---"); + t2.on(); + CHK((g_con = g_ndb->startTransaction()) != 0); + for (Uint32 k = 0; k < g_opt.m_rowsperf; k++) { + CHK((g_opr = g_con->getNdbOperation(tab.getName())) != 0); + CHK(g_opr->insertTuple() == 0); + CHK(g_opr->equal(cA, (char*)&k) == 0); + CHK((g_bh1 = g_opr->getBlobHandle(cC)) != 0); + CHK((g_bh1->setValue("c", 1) == 0)); + CHK(g_con->execute(NoCommit) == 0); + } + t2.off(g_opt.m_rowsperf); + CHK(g_con->execute(Rollback) == 0); + DBG(t2.time()); + g_bh1 = 0; + g_opr = 0; + g_con = 0; + } + // insert overhead + DBG("insert overhead: " << t2.over(t1)); + t1.clr(); + t2.clr(); + // insert + { + DBG("--- insert for read test ---"); + unsigned n = 0; + CHK((g_con = g_ndb->startTransaction()) != 0); + for (Uint32 k = 0; k < g_opt.m_rowsperf; k++) { + CHK((g_opr = g_con->getNdbOperation(tab.getName())) != 0); + CHK(g_opr->insertTuple() == 0); + CHK(g_opr->equal(cA, (char*)&k) == 0); + CHK(g_opr->setValue(cB, "b") == 0); + CHK((g_bh1 = g_opr->getBlobHandle(cC)) != 0); + CHK((g_bh1->setValue("c", 1) == 0)); + if (++n == g_opt.m_batch) { + CHK(g_con->execute(Commit) == 0); + g_ndb->closeTransaction(g_con); + CHK((g_con = g_ndb->startTransaction()) != 0); + n = 0; + } + } + if (n != 0) { + CHK(g_con->execute(Commit) == 0); + n = 0; + } + g_bh1 = 0; + g_opr = 0; + g_con = 0; + } + // pk read char (one trans) + { + DBG("--- pk read char ---"); + CHK((g_con = g_ndb->startTransaction()) != 0); + Uint32 a; + char b[20]; + t1.on(); + for (Uint32 k = 0; k < g_opt.m_rowsperf; k++) { + CHK((g_opr = g_con->getNdbOperation(tab.getName())) != 0); + CHK(g_opr->readTuple() == 0); + CHK(g_opr->equal(cA, (char*)&k) == 0); + CHK(g_opr->getValue(cA, (char*)&a) != 0); + CHK(g_opr->getValue(cB, b) != 0); + a = (Uint32)-1; + b[0] = 0; + CHK(g_con->execute(NoCommit) == 0); + CHK(a == k && strcmp(b, "b") == 0); + } + CHK(g_con->execute(Commit) == 0); + t1.off(g_opt.m_rowsperf); + DBG(t1.time()); + g_opr = 0; + g_con = 0; + } + // pk read text (one trans) + { + DBG("--- pk read text ---"); + CHK((g_con = g_ndb->startTransaction()) != 0); + Uint32 a; + char c[20]; + t2.on(); + for (Uint32 k = 0; k < g_opt.m_rowsperf; k++) { + CHK((g_opr = g_con->getNdbOperation(tab.getName())) != 0); + CHK(g_opr->readTuple() == 0); + CHK(g_opr->equal(cA, (char*)&k) == 0); + CHK(g_opr->getValue(cA, (char*)&a) != 0); + CHK((g_bh1 = g_opr->getBlobHandle(cC)) != 0); + a = (Uint32)-1; + c[0] = 0; + CHK(g_con->execute(NoCommit) == 0); + Uint32 m = 20; + CHK(g_bh1->readData(c, m) == 0); + CHK(a == k && m == 1 && strcmp(c, "c") == 0); + } + CHK(g_con->execute(Commit) == 0); + t2.off(g_opt.m_rowsperf); + DBG(t2.time()); + g_opr = 0; + g_con = 0; + } + // pk read overhead + DBG("pk read overhead: " << t2.over(t1)); + t1.clr(); + t2.clr(); + // scan read char + { + DBG("--- scan read char ---"); + NdbResultSet* rs; + Uint32 a; + char b[20]; + CHK((g_con = g_ndb->startTransaction()) != 0); + CHK((g_ops = g_con->getNdbScanOperation(tab.getName())) != 0); + CHK((rs = g_ops->readTuples(NdbScanOperation::LM_Read)) != 0); + CHK(g_ops->getValue(cA, (char*)&a) != 0); + CHK(g_ops->getValue(cB, b) != 0); + CHK(g_con->execute(NoCommit) == 0); + unsigned n = 0; + t1.on(); + while (1) { + a = (Uint32)-1; + b[0] = 0; + int ret; + CHK((ret = rs->nextResult(true)) == 0 || ret == 1); + if (ret == 1) + break; + CHK(a < g_opt.m_rowsperf && strcmp(b, "b") == 0); + n++; + } + CHK(n == g_opt.m_rowsperf); + t1.off(g_opt.m_rowsperf); + DBG(t1.time()); + g_ops = 0; + g_con = 0; + } + // scan read text + { + DBG("--- read text ---"); + NdbResultSet* rs; + Uint32 a; + char c[20]; + CHK((g_con = g_ndb->startTransaction()) != 0); + CHK((g_ops = g_con->getNdbScanOperation(tab.getName())) != 0); + CHK((rs = g_ops->readTuples(NdbScanOperation::LM_Read)) != 0); + CHK(g_ops->getValue(cA, (char*)&a) != 0); + CHK((g_bh1 = g_ops->getBlobHandle(cC)) != 0); + CHK(g_con->execute(NoCommit) == 0); + unsigned n = 0; + t2.on(); + while (1) { + a = (Uint32)-1; + c[0] = 0; + int ret; + CHK((ret = rs->nextResult(true)) == 0 || ret == 1); + if (ret == 1) + break; + Uint32 m = 20; + CHK(g_bh1->readData(c, m) == 0); + CHK(a < g_opt.m_rowsperf && m == 1 && strcmp(c, "c") == 0); + n++; + } + CHK(n == g_opt.m_rowsperf); + t2.off(g_opt.m_rowsperf); + DBG(t2.time()); + g_bh1 = 0; + g_ops = 0; + g_con = 0; + } + // scan read overhead + DBG("scan read overhead: " << t2.over(t1)); + t1.clr(); + t2.clr(); + delete g_ndb; + return 0; +} + // bug tests static int @@ -1331,9 +1739,7 @@ static struct { int m_bug; int (*m_test)(); } g_bugtest[] = { - { 4088, bugtest_4088 }, - { 2222, bugtest_2222 }, - { 3333, bugtest_3333 } + { 4088, bugtest_4088 } }; NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) @@ -1361,6 +1767,12 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) putenv(strdup("NDB_BLOB_DEBUG=1")); continue; } + if (strcmp(arg, "-dbug") == 0) { + if (++argv, --argc > 0) { + g_opt.m_dbug = strdup(argv[0]); + continue; + } + } if (strcmp(arg, "-full") == 0) { g_opt.m_full = true; continue; @@ -1383,6 +1795,12 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) continue; } } + if (strcmp(arg, "-rowsperf") == 0) { + if (++argv, --argc > 0) { + g_opt.m_rowsperf = atoi(argv[0]); + continue; + } + } if (strcmp(arg, "-seed") == 0) { if (++argv, --argc > 0) { g_opt.m_seed = atoi(argv[0]); @@ -1395,9 +1813,9 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) continue; } } - if (strcmp(arg, "-style") == 0) { + if (strcmp(arg, "-test") == 0) { if (++argv, --argc > 0) { - g_opt.m_style = strdup(argv[0]); + g_opt.m_test = strdup(argv[0]); continue; } } @@ -1431,17 +1849,25 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) printusage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } + if (g_opt.m_dbug != 0) { + DBUG_PUSH(g_opt.m_dbug); + } if (g_opt.m_pk2len == 0) { char b[100]; - strcpy(b, g_opt.m_skip); + b[0] = 0; + if (g_opt.m_skip != 0) + strcpy(b, g_opt.m_skip); strcat(b, "i"); strcat(b, "r"); g_opt.m_skip = strdup(b); } - if (testmain() == -1) { + g_ncc = new Ndb_cluster_connection(); + if (g_ncc->connect(30) != 0 || testmain() == -1 || testperf() == -1) { ndbout << "line " << __LINE__ << " FAIL loop=" << g_loop << endl; return NDBT_ProgramExit(NDBT_FAILED); } + delete g_ncc; + g_ncc = 0; return NDBT_ProgramExit(NDBT_OK); } diff --git a/ndb/test/ndbapi/testDataBuffers.cpp b/ndb/test/ndbapi/testDataBuffers.cpp index 04602f51d5f..03d52252334 100644 --- a/ndb/test/ndbapi/testDataBuffers.cpp +++ b/ndb/test/ndbapi/testDataBuffers.cpp @@ -123,15 +123,15 @@ chkerror(char const* fmt, ...) // alignment of addresses and data sizes -static bool isAligned(unsigned x) +static bool isAligned(UintPtr x) { return ((x & 3) == 0); } static bool isAligned(char* p) { - return isAligned(unsigned(p)); + return isAligned(UintPtr(p)); } -static unsigned toAligned(unsigned x) +static unsigned toAligned(UintPtr x) { while (! isAligned(x)) x++; @@ -223,10 +223,10 @@ testcase(int flag) noRandom = ! (flag & 8); ndbout << (noRandom ? "simple sizes" : "randomize sizes") << endl; - int smax = 0, stot = 0; + int smax = 0, stot = 0, i; if (xverbose) ndbout << "- define table " << tab << endl; - for (int i = 0; i < attrcnt; i++) { + for (i = 0; i < attrcnt; i++) { col& c = ccol[i]; memset(&c, 0, sizeof(c)); sprintf(c.aAttrName, "C%d", i); @@ -266,7 +266,7 @@ testcase(int flag) return ndberror("getNdbSchemaOp"); if (top->createTable(tab) < 0) return ndberror("createTable"); - for (int i = 0; i < attrcnt; i++) { + for (i = 0; i < attrcnt; i++) { col& c = ccol[i]; if (top->createAttribute( c.aAttrName, @@ -299,7 +299,7 @@ testcase(int flag) return ndberror("getNdbOperation key=%d", key); if (op->deleteTuple() < 0) return ndberror("deleteTuple key=%d", key); - for (int i = 0; i < attrcnt; i++) { + for (i = 0; i < attrcnt; i++) { col& c = ccol[i]; if (i == 0) { if (op->equal(c.aAttrName, (char*)&key, sizeof(key)) < 0) @@ -329,7 +329,7 @@ testcase(int flag) return ndberror("getNdbOperation key=%d", key); if (op->insertTuple() < 0) return ndberror("insertTuple key=%d", key); - for (int i = 0; i < attrcnt; i++) { + for (i = 0; i < attrcnt; i++) { col& c = ccol[i]; if (i == 0) { if (op->equal(c.aAttrName, (char*)&key, sizeof(key)) < 0) @@ -362,7 +362,7 @@ testcase(int flag) return ndberror("getNdbOperation key=%d", key); if (op->readTuple() < 0) return ndberror("readTuple key=%d", key); - for (int i = 0; i < attrcnt; i++) { + for (i = 0; i < attrcnt; i++) { col& c = ccol[i]; if (i == 0) { if (op->equal(c.aAttrName, (char*)&key, sizeof(key)) < 0) @@ -371,7 +371,7 @@ testcase(int flag) if (xverbose) { char tmp[20]; if (useBuf) - sprintf(tmp, "0x%x", int(c.buf + off)); + sprintf(tmp, "0x%p", c.buf + off); else strcpy(tmp, "ndbapi"); ndbout << "--- column " << i << " addr=" << tmp << endl; @@ -388,23 +388,24 @@ testcase(int flag) } if (con->execute(Commit) != 0) return ndberror("execute key=%d", key); - for (int i = 0; i < attrcnt; i++) { + for (i = 0; i < attrcnt; i++) { col& c = ccol[i]; if (i == 0) { } else if (useBuf) { - for (int j = 0; j < off; j++) { + int j; + for (j = 0; j < off; j++) { if (c.buf[j] != 'B') { return chkerror("mismatch before key=%d col=%d pos=%d ok=%02x bad=%02x", key, i, j, 'B', c.buf[j]); } } - for (int j = 0; j < c.aArraySize; j++) { + for (j = 0; j < c.aArraySize; j++) { if (c.buf[j + off] != byteVal(key, i, j)) { return chkerror("mismatch key=%d col=%d pos=%d ok=%02x bad=%02x", key, i, j, byteVal(key, i, j), c.buf[j]); } } - for (int j = c.aArraySize + off; j < c.bufsiz; j++) { + for (j = c.aArraySize + off; j < c.bufsiz; j++) { if (c.buf[j] != 'B') { return chkerror("mismatch after key=%d col=%d pos=%d ok=%02x bad=%02x", key, i, j, 'B', c.buf[j]); @@ -431,7 +432,8 @@ testcase(int flag) if (xverbose) ndbout << "- scan" << endl; char found[MaxOper]; - for (int k = 0; k < opercnt; k++) + int k; + for (k = 0; k < opercnt; k++) found[k] = 0; for (key = 0; key < opercnt; key++) { int off = makeOff(key); @@ -459,7 +461,7 @@ testcase(int flag) if (op->interpret_exit_ok() < 0) return ndberror("interpret_exit_ok"); } - for (int i = 0; i < attrcnt; i++) { + for (i = 0; i < attrcnt; i++) { col& c = ccol[i]; if (i == 0) { if (op->getValue(c.aAttrName, (char*)&newkey) < 0) @@ -468,7 +470,7 @@ testcase(int flag) if (xverbose) { char tmp[20]; if (useBuf) - sprintf(tmp, "0x%x", int(c.buf + off)); + sprintf(tmp, "0x%p", c.buf + off); else strcpy(tmp, "ndbapi"); ndbout << "--- column " << i << " addr=" << tmp << endl; @@ -489,22 +491,23 @@ testcase(int flag) while ((ret = rs->nextResult()) == 0) { if (key != newkey) return ndberror("unexpected key=%d newkey=%d", key, newkey); - for (int i = 1; i < attrcnt; i++) { + for (i = 1; i < attrcnt; i++) { col& c = ccol[i]; if (useBuf) { - for (int j = 0; j < off; j++) { + int j; + for (j = 0; j < off; j++) { if (c.buf[j] != 'C') { return chkerror("mismatch before key=%d col=%d pos=%d ok=%02x bad=%02x", key, i, j, 'C', c.buf[j]); } } - for (int j = 0; j < c.aArraySize; j++) { + for (j = 0; j < c.aArraySize; j++) { if (c.buf[j + off] != byteVal(key, i, j)) { return chkerror("mismatch key=%d col=%d pos=%d ok=%02x bad=%02x", key, i, j, byteVal(key, i, j), c.buf[j]); } } - for (int j = c.aArraySize + off; j < c.bufsiz; j++) { + for (j = c.aArraySize + off; j < c.bufsiz; j++) { if (c.buf[j] != 'C') { return chkerror("mismatch after key=%d col=%d pos=%d ok=%02x bad=%02x", key, i, j, 'C', c.buf[j]); @@ -533,7 +536,7 @@ testcase(int flag) } con = 0; op = 0; - for (int k = 0; k < opercnt; k++) + for (k = 0; k < opercnt; k++) if (! found[k]) return ndberror("key %d not found", k); ndbout << "scanned " << key << endl; @@ -545,6 +548,7 @@ testcase(int flag) NDB_COMMAND(testDataBuffers, "testDataBuffers", "testDataBuffers", "testDataBuffers", 65535) { + int i; ndb_init(); while (++argv, --argc > 0) { char const* p = argv[0]; @@ -602,7 +606,7 @@ NDB_COMMAND(testDataBuffers, "testDataBuffers", "testDataBuffers", "testDataBuff } } unsigned ok = true; - for (int i = 1; 0 == loopcnt || i <= loopcnt; i++) { + for (i = 1; 0 == loopcnt || i <= loopcnt; i++) { ndbout << "=== loop " << i << " ===" << endl; for (int flag = 0; flag < (1<<testbits); flag++) { if (testcase(flag) < 0) { diff --git a/ndb/test/ndbapi/testDeadlock.cpp b/ndb/test/ndbapi/testDeadlock.cpp index 66fa48173cc..eb985e815ac 100644 --- a/ndb/test/ndbapi/testDeadlock.cpp +++ b/ndb/test/ndbapi/testDeadlock.cpp @@ -459,7 +459,8 @@ wl1822_main(char scantx) static const unsigned thrcount = 2; // create threads for tx1 and tx2 Thr* thrlist[2]; - for (int n = 0; n < thrcount; n++) { + int n; + for (n = 0; n < thrcount; n++) { Thr& thr = *(thrlist[n] = new Thr(1 + n)); CHK(thr.m_ret == 0); } @@ -472,7 +473,7 @@ wl1822_main(char scantx) if (runstep != 0) thr.start(runstep); } - for (int n = 0; n < thrcount; n++) { + for (n = 0; n < thrcount; n++) { Thr& thr = *thrlist[n]; Runstep runstep = wl1822_step[i][n]; if (runstep != 0) @@ -480,7 +481,7 @@ wl1822_main(char scantx) } } // delete threads - for (int n = 0; n < thrcount; n++) { + for (n = 0; n < thrcount; n++) { Thr& thr = *thrlist[n]; thr.exit(); thr.join(); diff --git a/ndb/test/ndbapi/testDict.cpp b/ndb/test/ndbapi/testDict.cpp index 89232de2535..5f88342705a 100644 --- a/ndb/test/ndbapi/testDict.cpp +++ b/ndb/test/ndbapi/testDict.cpp @@ -1211,7 +1211,7 @@ runTableRename(NDBT_Context* ctx, NDBT_Step* step){ const NdbDictionary::Table * oldTable = dict->getTable(pTabName.c_str()); if (oldTable) { - NdbDictionary::Table newTable = dict->getTableForAlteration(pTabName.c_str()); + NdbDictionary::Table newTable = *oldTable; newTable.setName(pTabNewName.c_str()); CHECK2(dict->alterTable(newTable) == 0, "TableRename failed"); @@ -1280,7 +1280,7 @@ runTableRenameNF(NDBT_Context* ctx, NDBT_Step* step){ const NdbDictionary::Table * oldTable = dict->getTable(pTabName.c_str()); if (oldTable) { - NdbDictionary::Table newTable = dict->getTableForAlteration(pTabName.c_str()); + NdbDictionary::Table newTable = *oldTable; newTable.setName(pTabNewName.c_str()); CHECK2(dict->alterTable(newTable) == 0, "TableRename failed"); @@ -1377,7 +1377,7 @@ runTableRenameSR(NDBT_Context* ctx, NDBT_Step* step){ const NdbDictionary::Table * oldTable = dict->getTable(pTabName.c_str()); if (oldTable) { - NdbDictionary::Table newTable = dict->getTableForAlteration(pTabName.c_str()); + NdbDictionary::Table newTable = *oldTable; newTable.setName(pTabNewName.c_str()); CHECK2(dict->alterTable(newTable) == 0, "TableRename failed"); @@ -1431,11 +1431,12 @@ int runTestDictionaryPerf(NDBT_Context* ctx, NDBT_Step* step){ Vector<char*> cols; Vector<const NdbDictionary::Table*> tabs; + int i; Ndb* pNdb = GETNDB(step); const Uint32 count = NDBT_Tables::getNumTables(); - for (int i=0; i < count; i++){ + for (i=0; i < count; i++){ const NdbDictionary::Table * tab = NDBT_Tables::getTable(i); pNdb->getDictionary()->createTable(* tab); @@ -1458,7 +1459,7 @@ runTestDictionaryPerf(NDBT_Context* ctx, NDBT_Step* step){ Uint32 size = cols.size() / 2; char ** columns = &cols[0]; Uint64 start = NdbTick_CurrentMillisecond(); - for(int i = 0; i<times; i++){ + for(i = 0; i<times; i++){ int j = 2 * (rand() % size); const NdbDictionary::Table* tab = (const NdbDictionary::Table*)tcols[j]; const char * col = tcols[j+1]; @@ -1478,6 +1479,84 @@ runTestDictionaryPerf(NDBT_Context* ctx, NDBT_Step* step){ return NDBT_OK; } +int runFailAddFragment(NDBT_Context* ctx, NDBT_Step* step){ + static int acclst[] = { 3001 }; + static int tuplst[] = { 4007, 4008, 4009, 4010, 4011, 4012 }; + static int tuxlst[] = { 12001, 12002, 12003, 12004, 12005, 12006 }; + static unsigned acccnt = sizeof(acclst)/sizeof(acclst[0]); + static unsigned tupcnt = sizeof(tuplst)/sizeof(tuplst[0]); + static unsigned tuxcnt = sizeof(tuxlst)/sizeof(tuxlst[0]); + + NdbRestarter restarter; + int nodeId = restarter.getMasterNodeId(); + Ndb* pNdb = GETNDB(step); + NdbDictionary::Dictionary* pDic = pNdb->getDictionary(); + NdbDictionary::Table tab(*ctx->getTab()); + tab.setFragmentType(NdbDictionary::Object::FragAllLarge); + + // ordered index on first few columns + NdbDictionary::Index idx("X"); + idx.setTable(tab.getName()); + idx.setType(NdbDictionary::Index::OrderedIndex); + idx.setLogging(false); + for (int i_hate_broken_compilers = 0; + i_hate_broken_compilers < 3 && + i_hate_broken_compilers < tab.getNoOfColumns(); + i_hate_broken_compilers++) { + idx.addColumn(*tab.getColumn(i_hate_broken_compilers)); + } + + const int loops = ctx->getNumLoops(); + int result = NDBT_OK; + (void)pDic->dropTable(tab.getName()); + + for (int l = 0; l < loops; l++) { + for (unsigned i0 = 0; i0 < acccnt; i0++) { + unsigned j = (l == 0 ? i0 : myRandom48(acccnt)); + int errval = acclst[j]; + g_info << "insert error node=" << nodeId << " value=" << errval << endl; + CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0, + "failed to set error insert"); + CHECK2(pDic->createTable(tab) != 0, + "failed to fail after error insert " << errval); + CHECK2(pDic->createTable(tab) == 0, + pDic->getNdbError()); + CHECK2(pDic->dropTable(tab.getName()) == 0, + pDic->getNdbError()); + } + for (unsigned i1 = 0; i1 < tupcnt; i1++) { + unsigned j = (l == 0 ? i1 : myRandom48(tupcnt)); + int errval = tuplst[j]; + g_info << "insert error node=" << nodeId << " value=" << errval << endl; + CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0, + "failed to set error insert"); + CHECK2(pDic->createTable(tab) != 0, + "failed to fail after error insert " << errval); + CHECK2(pDic->createTable(tab) == 0, + pDic->getNdbError()); + CHECK2(pDic->dropTable(tab.getName()) == 0, + pDic->getNdbError()); + } + for (unsigned i2 = 0; i2 < tuxcnt; i2++) { + unsigned j = (l == 0 ? i2 : myRandom48(tuxcnt)); + int errval = tuxlst[j]; + g_info << "insert error node=" << nodeId << " value=" << errval << endl; + CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0, + "failed to set error insert"); + CHECK2(pDic->createTable(tab) == 0, + pDic->getNdbError()); + CHECK2(pDic->createIndex(idx) != 0, + "failed to fail after error insert " << errval); + CHECK2(pDic->createIndex(idx) == 0, + pDic->getNdbError()); + CHECK2(pDic->dropTable(tab.getName()) == 0, + pDic->getNdbError()); + } + } +end: + return result; +} + NDBT_TESTSUITE(testDict); TESTCASE("CreateAndDrop", "Try to create and drop the table loop number of times\n"){ @@ -1573,6 +1652,10 @@ TESTCASE("DictionaryPerf", ""){ INITIALIZER(runTestDictionaryPerf); } +TESTCASE("FailAddFragment", + "Fail add fragment or attribute in ACC or TUP or TUX\n"){ + INITIALIZER(runFailAddFragment); +} NDBT_TESTSUITE_END(testDict); int main(int argc, const char** argv){ @@ -1582,5 +1665,3 @@ int main(int argc, const char** argv){ myRandom48Init(NdbTick_CurrentMillisecond()); return testDict.execute(argc, argv); } - - diff --git a/ndb/test/ndbapi/testIndex.cpp b/ndb/test/ndbapi/testIndex.cpp index ed9e114fd92..6623ad35a7f 100644 --- a/ndb/test/ndbapi/testIndex.cpp +++ b/ndb/test/ndbapi/testIndex.cpp @@ -58,7 +58,9 @@ void AttribList::buildAttribList(const NdbDictionary::Table* pTab){ // Build attrib definitions that describes which attributes to build index // Try to build strange combinations, not just "all" or all PK's - for(int i = 1; i <= pTab->getNoOfColumns(); i++){ + int i; + + for(i = 1; i <= pTab->getNoOfColumns(); i++){ attr = new Attrib; attr->numAttribs = i; for(int a = 0; a<i; a++) @@ -66,7 +68,7 @@ void AttribList::buildAttribList(const NdbDictionary::Table* pTab){ attriblist.push_back(attr); } int b = 0; - for(int i = pTab->getNoOfColumns()-1; i > 0; i--){ + for(i = pTab->getNoOfColumns()-1; i > 0; i--){ attr = new Attrib; attr->numAttribs = i; b++; @@ -74,21 +76,21 @@ void AttribList::buildAttribList(const NdbDictionary::Table* pTab){ attr->attribs[a] = a+b; attriblist.push_back(attr); } - for(int i = pTab->getNoOfColumns(); i > 0; i--){ + for(i = pTab->getNoOfColumns(); i > 0; i--){ attr = new Attrib; attr->numAttribs = pTab->getNoOfColumns() - i; for(int a = 0; a<pTab->getNoOfColumns() - i; a++) attr->attribs[a] = pTab->getNoOfColumns()-a-1; attriblist.push_back(attr); } - for(int i = 1; i < pTab->getNoOfColumns(); i++){ + for(i = 1; i < pTab->getNoOfColumns(); i++){ attr = new Attrib; attr->numAttribs = pTab->getNoOfColumns() - i; for(int a = 0; a<pTab->getNoOfColumns() - i; a++) attr->attribs[a] = pTab->getNoOfColumns()-a-1; attriblist.push_back(attr); } - for(int i = 1; i < pTab->getNoOfColumns(); i++){ + for(i = 1; i < pTab->getNoOfColumns(); i++){ attr = new Attrib; attr->numAttribs = 2; for(int a = 0; a<2; a++){ @@ -226,8 +228,8 @@ int runCreateIndexes(NDBT_Context* ctx, NDBT_Step* step){ while (l < loops && result == NDBT_OK){ - - for (unsigned int i = 0; i < attrList.attriblist.size(); i++){ + unsigned int i; + for (i = 0; i < attrList.attriblist.size(); i++){ // Try to create index if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED) @@ -235,7 +237,7 @@ int runCreateIndexes(NDBT_Context* ctx, NDBT_Step* step){ } // Now drop all indexes that where created - for (unsigned int i = 0; i < attrList.attriblist.size(); i++){ + for (i = 0; i < attrList.attriblist.size(); i++){ // Try to drop index if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK) @@ -1083,8 +1085,8 @@ runUniqueNullTransactions(NDBT_Context* ctx, NDBT_Step* step){ else pIdx.setType(NdbDictionary::Index::UniqueHashIndex); pIdx.setStoredIndex(logged); - - for (int c = 0; c< pTab->getNoOfColumns(); c++){ + int c; + for (c = 0; c< pTab->getNoOfColumns(); c++){ const NdbDictionary::Column * col = pTab->getColumn(c); if(col->getPrimaryKey()){ pIdx.addIndexColumn(col->getName()); @@ -1093,7 +1095,7 @@ runUniqueNullTransactions(NDBT_Context* ctx, NDBT_Step* step){ } int colId = -1; - for (int c = 0; c< pTab->getNoOfColumns(); c++){ + for (c = 0; c< pTab->getNoOfColumns(); c++){ const NdbDictionary::Column * col = pTab->getColumn(c); if(col->getNullable()){ pIdx.addIndexColumn(col->getName()); diff --git a/ndb/test/ndbapi/testLcp.cpp b/ndb/test/ndbapi/testLcp.cpp index c92be091a97..d11692db761 100644 --- a/ndb/test/ndbapi/testLcp.cpp +++ b/ndb/test/ndbapi/testLcp.cpp @@ -85,7 +85,8 @@ main(int argc, char ** argv){ g_info << " where ZLCP_OP_WRITE_RT_BREAK is finished before SAVE_PAGES" << endl; require(!pause_lcp()); - for(size_t j = 0; j<g_rows; j++){ + size_t j; + for(j = 0; j<g_rows; j++){ require(!do_op(j)); } require(!continue_lcp(5900)); @@ -98,7 +99,7 @@ main(int argc, char ** argv){ << endl; require(!load_table()); require(!pause_lcp()); - for(size_t j = 0; j<g_rows; j++){ + for(j = 0; j<g_rows; j++){ require(!do_op(j)); } require(!continue_lcp(5901)); @@ -109,7 +110,7 @@ main(int argc, char ** argv){ g_info << "Testing pre LCP operations, undo-ed at commit" << endl; require(!load_table()); require(!pause_lcp()); - for(size_t j = 0; j<g_rows; j++){ + for(j = 0; j<g_rows; j++){ require(!do_op(j)); } require(!continue_lcp(5902)); diff --git a/ndb/test/ndbapi/testNdbApi.cpp b/ndb/test/ndbapi/testNdbApi.cpp index 74cb1f8bcd0..69e534e6860 100644 --- a/ndb/test/ndbapi/testNdbApi.cpp +++ b/ndb/test/ndbapi/testNdbApi.cpp @@ -88,10 +88,10 @@ int runTestMaxNdb(NDBT_Context* ctx, NDBT_Step* step){ oldi = i; - for(size_t i = 0; i < ndbVector.size(); i++){ - delete ndbVector[i]; - if(((i+1) % 250) == 0){ - ndbout << "Deleted " << (Uint64) i << " ndb objects " << endl; + for(size_t j = 0; j < ndbVector.size(); j++){ + delete ndbVector[j]; + if(((j+1) % 250) == 0){ + ndbout << "Deleted " << (Uint64) j << " ndb objects " << endl; } } ndbVector.clear(); @@ -142,14 +142,22 @@ int runTestMaxTransaction(NDBT_Context* ctx, NDBT_Step* step){ 4); break; case 2: + ndbout_c("startTransactionDGroup not supported"); + abort(); + /* pCon = pNdb->startTransactionDGroup(1, "TEST", 0); + */ break; case 3: + ndbout_c("startTransactionDGroup not supported"); + abort(); + /* pCon = pNdb->startTransactionDGroup(2, "TEST", 1); + */ break; default: @@ -178,8 +186,8 @@ int runTestMaxTransaction(NDBT_Context* ctx, NDBT_Step* step){ oldi = i; - for(size_t i = 0; i < conVector.size(); i++){ - pNdb->closeTransaction(conVector[i]); + for(size_t j = 0; j < conVector.size(); j++){ + pNdb->closeTransaction(conVector[j]); } conVector.clear(); l++; @@ -537,8 +545,8 @@ int runTestDeleteNdb(NDBT_Context* ctx, NDBT_Step* step){ } // Delete the ndb objects - for(size_t i = 0; i < ndbVector.size(); i++) - delete ndbVector[i]; + for(size_t j = 0; j < ndbVector.size(); j++) + delete ndbVector[j]; ndbVector.clear(); l++; } diff --git a/ndb/test/ndbapi/testOIBasic.cpp b/ndb/test/ndbapi/testOIBasic.cpp index 21862e02328..e6d3844d18e 100644 --- a/ndb/test/ndbapi/testOIBasic.cpp +++ b/ndb/test/ndbapi/testOIBasic.cpp @@ -59,7 +59,7 @@ struct Opt { unsigned m_subloop; const char* m_table; unsigned m_threads; - unsigned m_v; + int m_v; Opt() : m_batch(32), m_bound("01234"), @@ -407,10 +407,11 @@ Col::verify(const void* addr) const const unsigned char* p = (const unsigned char*)addr; unsigned n = (p[0] << 8) | p[1]; assert(n <= m_length); - for (unsigned i = 0; i < n; i++) { + unsigned i; + for (i = 0; i < n; i++) { assert(p[2 + i] != 0); } - for (unsigned i = n; i < m_length; i++) { + for (i = n; i < m_length; i++) { assert(p[2 + i] == 0); } } @@ -671,6 +672,8 @@ tabcount = sizeof(tablist) / sizeof(tablist[0]); // connections +static Ndb_cluster_connection* g_ncc = 0; + struct Con { Ndb* m_ndb; NdbDictionary::Dictionary* m_dic; @@ -719,7 +722,7 @@ int Con::connect() { assert(m_ndb == 0); - m_ndb = new Ndb("TEST_DB"); + m_ndb = new Ndb(g_ncc, "TEST_DB"); CHKCON(m_ndb->init() == 0, *this); CHKCON(m_ndb->waitUntilReady(30) == 0, *this); m_tx = 0, m_op = 0; @@ -3021,7 +3024,8 @@ runstep(Par par, const char* fname, TFunc func, unsigned mode) { LL2(fname); const int threads = (mode & ST ? 1 : par.m_threads); - for (int n = 0; n < threads; n++) { + int n; + for (n = 0; n < threads; n++) { LL4("start " << n); Thr& thr = *g_thrlist[n]; thr.m_par.m_tab = par.m_tab; @@ -3033,7 +3037,7 @@ runstep(Par par, const char* fname, TFunc func, unsigned mode) thr.start(); } unsigned errs = 0; - for (int n = threads - 1; n >= 0; n--) { + for (n = threads - 1; n >= 0; n--) { LL4("stop " << n); Thr& thr = *g_thrlist[n]; thr.stopped(); @@ -3301,10 +3305,11 @@ runtest(Par par) CHK(con.connect() == 0); par.m_con = &con; g_thrlist = new Thr* [par.m_threads]; - for (unsigned n = 0; n < par.m_threads; n++) { + unsigned n; + for (n = 0; n < par.m_threads; n++) { g_thrlist[n] = 0; } - for (unsigned n = 0; n < par.m_threads; n++) { + for (n = 0; n < par.m_threads; n++) { g_thrlist[n] = new Thr(par, n); Thr& thr = *g_thrlist[n]; assert(thr.m_thread != 0); @@ -3330,11 +3335,11 @@ runtest(Par par) } } } - for (unsigned n = 0; n < par.m_threads; n++) { + for (n = 0; n < par.m_threads; n++) { Thr& thr = *g_thrlist[n]; thr.exit(); } - for (unsigned n = 0; n < par.m_threads; n++) { + for (n = 0; n < par.m_threads; n++) { Thr& thr = *g_thrlist[n]; thr.join(); delete &thr; @@ -3511,8 +3516,11 @@ NDB_COMMAND(testOIBasic, "testOIBasic", "testOIBasic", "testOIBasic", 65535) } { Par par(g_opt); - if (runtest(par) < 0) + g_ncc = new Ndb_cluster_connection(); + if (g_ncc->connect(30) != 0 || runtest(par) < 0) goto failed; + delete g_ncc; + g_ncc = 0; } // always exit with NDBT code ok: diff --git a/ndb/test/ndbapi/testOperations.cpp b/ndb/test/ndbapi/testOperations.cpp index f31906dd737..e254aff58dc 100644 --- a/ndb/test/ndbapi/testOperations.cpp +++ b/ndb/test/ndbapi/testOperations.cpp @@ -98,6 +98,15 @@ OperationTestCase matrix[] = { result = NDBT_FAILED; \ break; } +#define C3(b) if (!(b)) { \ + g_err << "ERR: "<< step->getName() \ + << " failed on line " << __LINE__ << endl; \ + abort(); return NDBT_FAILED; } + +#define C3(b) if (!(b)) { \ + g_err << "ERR: failed on line " << __LINE__ << endl; \ + return NDBT_FAILED; } + int runOp(HugoOperations & hugoOps, Ndb * pNdb, @@ -171,7 +180,7 @@ runTwoOperations(NDBT_Context* ctx, NDBT_Step* step){ // Insert, read CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(runOp(hugoOps, pNdb, op1, val1) == 0); - AbortOption oa = (res1 == 0) ? AbortOnError : IgnoreError; + AbortOption oa = (res1 == 0) ? AbortOnError : AO_IgnoreError; CHECK(hugoOps.execute_NoCommit(pNdb, oa) == res1); CHECK(checkVal(hugoOps, op1, val1, res1) == 0); @@ -228,11 +237,369 @@ runClearTable(NDBT_Context* ctx, NDBT_Step* step){ return NDBT_OK; } +enum OPS { o_DONE= 0, o_INS= 1, o_UPD= 2, o_DEL= 3 }; +typedef Vector<OPS> Sequence; + +static +bool +valid(const Sequence& s) +{ + if(s.size() == 0) + return false; + + for(size_t i = 1; i<s.size(); i++) + { + switch(s[i]){ + case o_INS: + if(s[i-1] != o_DEL) + return false; + break; + case o_UPD: + case o_DEL: + if(s[i-1] == o_DEL) + return false; + break; + case o_DONE: + return true; + } + } + return true; +} + +static +NdbOut& operator<<(NdbOut& out, const Sequence& s) +{ + out << "[ "; + for(size_t i = 0; i<s.size(); i++) + { + switch(s[i]){ + case o_INS: + out << "INS "; + break; + case o_DEL: + out << "DEL "; + break; + case o_UPD: + out << "UPD "; + break; + case o_DONE: + abort(); + } + } + out << "]"; + return out; +} + +static +void +generate(Sequence& out, int no) +{ + while(no & 3) + { + out.push_back((OPS)(no & 3)); + no >>= 2; + } +} + +static +void +generate(Vector<int>& out, size_t len) +{ + int max= 1; + while(len) + { + max <<= 2; + len--; + } + + len= 1; + for(int i = 0; i<max; i++) + { + Sequence tmp; + generate(tmp, i); + + if(tmp.size() >= len && valid(tmp)) + { + out.push_back(i); + len= tmp.size(); + } + else + { + //ndbout << "DISCARD: " << tmp << endl; + } + } +} + +static const Uint32 DUMMY = 0; +static const Uint32 ROW = 1; + +int +verify_other(NDBT_Context* ctx, + Ndb* pNdb, int seq, OPS latest, bool initial_row, bool commit) +{ + Uint32 no_wait = NdbOperation::LM_CommittedRead* + ctx->getProperty("NoWait", (Uint32)1); + + for(size_t j = no_wait; j<3; j++) + { + HugoOperations other(*ctx->getTab()); + C3(other.startTransaction(pNdb) == 0); + C3(other.pkReadRecord(pNdb, ROW, 1, (NdbOperation::LockMode)j) == 0); + int tmp= other.execute_Commit(pNdb); + if(seq == 0){ + if(j == NdbOperation::LM_CommittedRead) + { + C3(initial_row? tmp==0 && other.verifyUpdatesValue(0) == 0 : tmp==626); + } + else + { + C3(tmp == 266); + } + } + else if(commit) + { + switch(latest){ + case o_INS: + case o_UPD: + C3(tmp == 0 && other.verifyUpdatesValue(seq) == 0); + break; + case o_DEL: + C3(tmp == 626); + break; + case o_DONE: + abort(); + } + } + else + { + // rollback + C3(initial_row? tmp==0 && other.verifyUpdatesValue(0) == 0 : tmp==626); + } + } + + return NDBT_OK; +} + +int +verify_savepoint(NDBT_Context* ctx, + Ndb* pNdb, int seq, OPS latest, + Uint64 transactionId) +{ + bool initial_row= (seq == 0) && latest == o_INS; + + for(size_t j = 0; j<3; j++) + { + const NdbOperation::LockMode lm= (NdbOperation::LockMode)j; + + HugoOperations same(*ctx->getTab()); + C3(same.startTransaction(pNdb) == 0); + same.setTransactionId(transactionId); // Cheat + + /** + * Increase savepoint to <em>k</em> + */ + for(size_t l = 1; l<=seq; l++) + { + C3(same.pkReadRecord(pNdb, DUMMY, 1, lm) == 0); // Read dummy row + C3(same.execute_NoCommit(pNdb) == 0); + g_info << "savepoint: " << l << endl; + } + + g_info << "op(" << seq << "): " + << " lock mode " << lm << endl; + + C3(same.pkReadRecord(pNdb, ROW, 1, lm) == 0); // Read real row + int tmp= same.execute_Commit(pNdb); + if(seq == 0) + { + if(initial_row) + { + C3(tmp == 0 && same.verifyUpdatesValue(0) == 0); + } else + { + C3(tmp == 626); + } + } + else + { + switch(latest){ + case o_INS: + case o_UPD: + C3(tmp == 0 && same.verifyUpdatesValue(seq) == 0); + break; + case o_DEL: + C3(tmp == 626); + break; + case o_DONE: + abort(); + } + } + } + return NDBT_OK; +} + +int +runOperations(NDBT_Context* ctx, NDBT_Step* step) +{ + int tmp; + Ndb* pNdb = GETNDB(step); + + Uint32 seqNo = ctx->getProperty("Sequence", (Uint32)0); + Uint32 commit= ctx->getProperty("Commit", (Uint32)1); + + if(seqNo == 0) + { + return NDBT_FAILED; + } + + Sequence seq; + generate(seq, seqNo); + + { + // Dummy row + HugoOperations hugoOps(*ctx->getTab()); + C3(hugoOps.startTransaction(pNdb) == 0); + C3(hugoOps.pkInsertRecord(pNdb, DUMMY, 1, 0) == 0); + C3(hugoOps.execute_Commit(pNdb) == 0); + } + + const bool initial_row= (seq[0] != o_INS); + if(initial_row) + { + HugoOperations hugoOps(*ctx->getTab()); + C3(hugoOps.startTransaction(pNdb) == 0); + C3(hugoOps.pkInsertRecord(pNdb, ROW, 1, 0) == 0); + C3(hugoOps.execute_Commit(pNdb) == 0); + } + + HugoOperations trans1(*ctx->getTab()); + C3(trans1.startTransaction(pNdb) == 0); + for(size_t i = 0; i<seq.size(); i++) + { + /** + * Perform operation + */ + switch(seq[i]){ + case o_INS: + C3(trans1.pkInsertRecord(pNdb, ROW, 1, i+1) == 0); + break; + case o_UPD: + C3(trans1.pkUpdateRecord(pNdb, ROW, 1, i+1) == 0); + break; + case o_DEL: + C3(trans1.pkDeleteRecord(pNdb, ROW, 1) == 0); + break; + case o_DONE: + abort(); + } + C3(trans1.execute_NoCommit(pNdb) == 0); + + /** + * Verify other transaction + */ + if(verify_other(ctx, pNdb, 0, seq[0], initial_row, commit) != NDBT_OK) + return NDBT_FAILED; + + /** + * Verify savepoint read + */ + Uint64 transactionId= trans1.getTransaction()->getTransactionId(); + + for(size_t k=0; k<=i+1; k++) + { + if(verify_savepoint(ctx, pNdb, k, + k>0 ? seq[k-1] : initial_row ? o_INS : o_DONE, + transactionId) != NDBT_OK) + return NDBT_FAILED; + } + } + + if(commit) + { + C3(trans1.execute_Commit(pNdb) == 0); + } + else + { + C3(trans1.execute_Rollback(pNdb) == 0); + } + + if(verify_other(ctx, pNdb, seq.size(), seq.back(), + initial_row, commit) != NDBT_OK) + return NDBT_FAILED; + + return NDBT_OK; +} + int main(int argc, const char** argv){ ndb_init(); + Vector<int> tmp; + generate(tmp, 5); + NDBT_TestSuite ts("testOperations"); + for(size_t i = 0; i<tmp.size(); i++) + { + BaseString name; + Sequence s; + generate(s, tmp[i]); + for(size_t j = 0; j<s.size(); j++){ + switch(s[j]){ + case o_INS: + name.append("_INS"); + break; + case o_DEL: + name.append("_DEL"); + break; + case o_UPD: + name.append("_UPD"); + break; + case o_DONE: + abort(); + } + } + + BaseString n1; + n1.append(name); + n1.append("_COMMIT"); + + NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts, + n1.c_str()+1, ""); + + pt->setProperty("Sequence", tmp[i]); + pt->addInitializer(new NDBT_Initializer(pt, + "runClearTable", + runClearTable)); + + pt->addStep(new NDBT_ParallelStep(pt, + "run", + runOperations)); + + pt->addFinalizer(new NDBT_Finalizer(pt, + "runClearTable", + runClearTable)); + + ts.addTest(pt); + + name.append("_ABORT"); + pt = new NDBT_TestCaseImpl1(&ts, name.c_str()+1, ""); + pt->setProperty("Sequence", tmp[i]); + pt->setProperty("Commit", (Uint32)0); + pt->addInitializer(new NDBT_Initializer(pt, + "runClearTable", + runClearTable)); + + pt->addStep(new NDBT_ParallelStep(pt, + "run", + runOperations)); + + pt->addFinalizer(new NDBT_Finalizer(pt, + "runClearTable", + runClearTable)); + + ts.addTest(pt); + } + for(Uint32 i = 0; i<sizeof(matrix)/sizeof(matrix[0]); i++){ NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts, matrix[i].name, ""); @@ -270,3 +637,5 @@ main(int argc, const char** argv){ return ts.execute(argc, argv); } +template class Vector<OPS>; +template class Vector<Sequence>; diff --git a/ndb/test/ndbapi/testReadPerf.cpp b/ndb/test/ndbapi/testReadPerf.cpp index 8d0d78cbe8c..3adcb5a2d9b 100644 --- a/ndb/test/ndbapi/testReadPerf.cpp +++ b/ndb/test/ndbapi/testReadPerf.cpp @@ -99,7 +99,8 @@ main(int argc, const char** argv){ { "verbose", 'v', arg_flag, &verbose, "Print verbose status", "verbose" } }; const int num_args = 1 + P_MAX; - for(int i = 0; i<P_MAX; i++){ + int i; + for(i = 0; i<P_MAX; i++){ args[i+1].long_name = g_paramters[i].name; args[i+1].short_name = * g_paramters[i].name; args[i+1].type = arg_integer; @@ -127,7 +128,7 @@ main(int argc, const char** argv){ g_err << "Wait until ready failed" << endl; goto error; } - for(int i = optind; i<argc; i++){ + for(i = optind; i<argc; i++){ const char * T = argv[i]; g_info << "Testing " << T << endl; BaseString::snprintf(g_table, sizeof(g_table), T); @@ -390,8 +391,15 @@ run_read(){ void print_result(){ + int tmp = 1; + tmp *= g_paramters[P_RANGE].value; + tmp *= g_paramters[P_LOOPS].value; + + int t, t2; for(int i = 0; i<P_OP_TYPES; i++){ - g_err.println("%s avg: %u us/row", g_ops[i], - (1000*g_times[i])/(g_paramters[P_RANGE].value*g_paramters[P_LOOPS].value)); + g_err << g_ops[i] << " avg: " + << (int)((1000*g_times[i])/tmp) + << " us/row (" + << (1000 * tmp)/g_times[i] << " rows / sec)" << endl; } } diff --git a/ndb/test/ndbapi/testRestartGci.cpp b/ndb/test/ndbapi/testRestartGci.cpp index e817245af55..4e541d1f38f 100644 --- a/ndb/test/ndbapi/testRestartGci.cpp +++ b/ndb/test/ndbapi/testRestartGci.cpp @@ -132,7 +132,8 @@ int runVerifyInserts(NDBT_Context* ctx, NDBT_Step* step){ // RULE1: The vector with saved records should have exactly as many // records with lower or same gci as there are in DB int recordsWithLowerOrSameGci = 0; - for (unsigned i = 0; i < savedRecords.size(); i++){ + unsigned i; + for (i = 0; i < savedRecords.size(); i++){ if (savedRecords[i].m_gci <= restartGCI) recordsWithLowerOrSameGci++; } @@ -144,7 +145,7 @@ int runVerifyInserts(NDBT_Context* ctx, NDBT_Step* step){ // RULE2: The records found in db should have same or lower // gci as in the vector - for (unsigned i = 0; i < savedRecords.size(); i++){ + for (i = 0; i < savedRecords.size(); i++){ CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.pkReadRecord(pNdb, i) == 0); if (hugoOps.execute_Commit(pNdb) != 0){ diff --git a/ndb/test/ndbapi/testScan.cpp b/ndb/test/ndbapi/testScan.cpp index 0cd30dfefde..f1018d29846 100644 --- a/ndb/test/ndbapi/testScan.cpp +++ b/ndb/test/ndbapi/testScan.cpp @@ -35,7 +35,8 @@ getTable(Ndb* pNdb, int i){ int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){ - int records = ctx->getNumRecords(); + int records = ctx->getProperty("Rows", ctx->getNumRecords()); + HugoTransactions hugoTrans(*ctx->getTab()); if (hugoTrans.loadTable(GETNDB(step), records) != 0){ return NDBT_FAILED; @@ -90,11 +91,59 @@ int runLoadAllTables(NDBT_Context* ctx, NDBT_Step* step){ return NDBT_OK; } +char orderedPkIdxName[255]; + +int createOrderedPkIndex(NDBT_Context* ctx, NDBT_Step* step){ + + const NdbDictionary::Table* pTab = ctx->getTab(); + Ndb* pNdb = GETNDB(step); + + // Create index + BaseString::snprintf(orderedPkIdxName, sizeof(orderedPkIdxName), + "IDC_O_PK_%s", pTab->getName()); + NdbDictionary::Index pIdx(orderedPkIdxName); + pIdx.setTable(pTab->getName()); + pIdx.setType(NdbDictionary::Index::OrderedIndex); + pIdx.setLogging(false); + + for (int c = 0; c< pTab->getNoOfColumns(); c++){ + const NdbDictionary::Column * col = pTab->getColumn(c); + if(col->getPrimaryKey()){ + pIdx.addIndexColumn(col->getName()); + } + } + + if (pNdb->getDictionary()->createIndex(pIdx) != 0){ + ndbout << "FAILED! to create index" << endl; + const NdbError err = pNdb->getDictionary()->getNdbError(); + ERR(err); + return NDBT_FAILED; + } + + return NDBT_OK; +} + +int createOrderedPkIndex_Drop(NDBT_Context* ctx, NDBT_Step* step){ + const NdbDictionary::Table* pTab = ctx->getTab(); + Ndb* pNdb = GETNDB(step); + + // Drop index + if (pNdb->getDictionary()->dropIndex(orderedPkIdxName, + pTab->getName()) != 0){ + ndbout << "FAILED! to drop index" << endl; + ERR(pNdb->getDictionary()->getNdbError()); + return NDBT_FAILED; + } + + return NDBT_OK; +} + + int runScanReadRandomTable(NDBT_Context* ctx, NDBT_Step* step){ int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int parallelism = ctx->getProperty("Parallelism", 240); - int abort = ctx->getProperty("AbortProb"); + int abort = ctx->getProperty("AbortProb", 5); int i = 0; while (i<loops) { @@ -216,9 +265,9 @@ int runVerifyTable(NDBT_Context* ctx, NDBT_Step* step){ int runScanRead(NDBT_Context* ctx, NDBT_Step* step){ int loops = ctx->getNumLoops(); - int records = ctx->getNumRecords(); + int records = ctx->getProperty("Rows", ctx->getNumRecords()); int parallelism = ctx->getProperty("Parallelism", 240); - int abort = ctx->getProperty("AbortProb"); + int abort = ctx->getProperty("AbortProb", 5); int i = 0; HugoTransactions hugoTrans(*ctx->getTab()); @@ -232,18 +281,66 @@ int runScanRead(NDBT_Context* ctx, NDBT_Step* step){ return NDBT_OK; } +int runRandScanRead(NDBT_Context* ctx, NDBT_Step* step){ + int loops = ctx->getNumLoops(); + int records = ctx->getNumRecords(); + int parallelism = ctx->getProperty("Parallelism", 240); + int abort = ctx->getProperty("AbortProb", 5); + + int i = 0; + HugoTransactions hugoTrans(*ctx->getTab()); + while (i<loops && !ctx->isTestStopped()) { + g_info << i << ": "; + NdbOperation::LockMode lm = (NdbOperation::LockMode)(rand() % 3); + if (hugoTrans.scanReadRecords(GETNDB(step), + records, abort, parallelism, + lm) != 0){ + return NDBT_FAILED; + } + i++; + } + return NDBT_OK; +} + +int runScanReadIndex(NDBT_Context* ctx, NDBT_Step* step){ + int loops = ctx->getNumLoops(); + int records = ctx->getNumRecords(); + int parallelism = ctx->getProperty("Parallelism", 240); + int abort = ctx->getProperty("AbortProb", 5); + const NdbDictionary::Index * pIdx = + GETNDB(step)->getDictionary()->getIndex(orderedPkIdxName, + ctx->getTab()->getName()); + + int i = 0; + HugoTransactions hugoTrans(*ctx->getTab()); + while (pIdx && i<loops && !ctx->isTestStopped()) { + g_info << i << ": "; + bool sort = (rand() % 100) > 50 ? true : false; + NdbOperation::LockMode lm = (NdbOperation::LockMode)(rand() % 3); + if (hugoTrans.scanReadRecords(GETNDB(step), pIdx, + records, abort, parallelism, + lm, + sort) != 0){ + return NDBT_FAILED; + } + i++; + } + return NDBT_OK; +} + int runScanReadCommitted(NDBT_Context* ctx, NDBT_Step* step){ int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int parallelism = ctx->getProperty("Parallelism", 240); - int abort = ctx->getProperty("AbortProb"); + int abort = ctx->getProperty("AbortProb", 5); int i = 0; HugoTransactions hugoTrans(*ctx->getTab()); while (i<loops && !ctx->isTestStopped()) { g_info << i << ": "; - if (hugoTrans.scanReadCommittedRecords(GETNDB(step), records, - abort, parallelism) != 0){ + if (hugoTrans.scanReadRecords(GETNDB(step), records, + abort, parallelism, + NdbOperation::LM_CommittedRead) != 0){ return NDBT_FAILED; } i++; @@ -279,7 +376,20 @@ int runScanReadError(NDBT_Context* ctx, NDBT_Step* step){ restarter.insertErrorInAllNodes(0); return result; } - + +int +runInsertError(NDBT_Context* ctx, NDBT_Step* step){ + int error = ctx->getProperty("ErrorCode"); + NdbRestarter restarter; + + ctx->setProperty("ErrorCode", (Uint32)0); + if (restarter.insertErrorInAllNodes(error) != 0){ + ndbout << "Could not insert error in all nodes "<<endl; + return NDBT_FAILED; + } + return NDBT_OK; +} + int runScanReadErrorOneNode(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); @@ -424,7 +534,7 @@ int runScanUpdate(NDBT_Context* ctx, NDBT_Step* step){ int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int parallelism = ctx->getProperty("Parallelism", 1); - int abort = ctx->getProperty("AbortProb"); + int abort = ctx->getProperty("AbortProb", 5); int i = 0; HugoTransactions hugoTrans(*ctx->getTab()); while (i<loops) { @@ -464,7 +574,7 @@ int runScanUpdate2(NDBT_Context* ctx, NDBT_Step* step){ int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int parallelism = ctx->getProperty("Parallelism", 240); - int abort = ctx->getProperty("AbortProb"); + int abort = ctx->getProperty("AbortProb", 5); int i = 0; HugoTransactions hugoTrans(*ctx->getTab()); while (i<loops) { @@ -639,7 +749,7 @@ int runCheckGetValue(NDBT_Context* ctx, NDBT_Step* step){ g_info << (unsigned)i << endl; if(utilTrans.scanReadRecords(GETNDB(step), parallelism, - false, + NdbOperation::LM_Read, records, alist.attriblist[i]->numAttribs, alist.attriblist[i]->attribs) != 0){ @@ -647,7 +757,7 @@ int runCheckGetValue(NDBT_Context* ctx, NDBT_Step* step){ } if(utilTrans.scanReadRecords(GETNDB(step), parallelism, - true, + NdbOperation::LM_Read, records, alist.attriblist[i]->numAttribs, alist.attriblist[i]->attribs) != 0){ @@ -1079,7 +1189,30 @@ TESTCASE("ScanRead488", "When this limit is exceeded the scan will be aborted with errorcode "\ "488."){ INITIALIZER(runLoadTable); - STEPS(runScanRead, 70); + STEPS(runRandScanRead, 70); + FINALIZER(runClearTable); +} +TESTCASE("ScanRead488O", + "Verify scan requirement: It's only possible to have 11 concurrent "\ + "scans per fragment running in Ndb kernel at the same time. "\ + "When this limit is exceeded the scan will be aborted with errorcode "\ + "488."){ + INITIALIZER(createOrderedPkIndex); + INITIALIZER(runLoadTable); + STEPS(runScanReadIndex, 70); + FINALIZER(createOrderedPkIndex_Drop); + FINALIZER(runClearTable); +} +TESTCASE("ScanRead488_Mixed", + "Verify scan requirement: It's only possible to have 11 concurrent "\ + "scans per fragment running in Ndb kernel at the same time. "\ + "When this limit is exceeded the scan will be aborted with errorcode "\ + "488."){ + INITIALIZER(createOrderedPkIndex); + INITIALIZER(runLoadTable); + STEPS(runRandScanRead, 50); + STEPS(runScanReadIndex, 50); + FINALIZER(createOrderedPkIndex_Drop); FINALIZER(runClearTable); } TESTCASE("ScanRead488Timeout", @@ -1102,6 +1235,16 @@ TESTCASE("ScanRead100", STEPS(runScanRead, 100); FINALIZER(runClearTable); } +TESTCASE("Scan-bug8262", + ""){ + TC_PROPERTY("Rows", 1); + TC_PROPERTY("ErrorCode", 8035); + INITIALIZER(runLoadTable); + INITIALIZER(runInsertError); // Will reset error code + STEPS(runScanRead, 25); + FINALIZER(runInsertError); + FINALIZER(runClearTable); +} TESTCASE("ScanRead40RandomTable", "Verify scan requirement: Scan with 40 simultaneous threads. "\ "Use random table for the scan"){ diff --git a/ndb/test/ndbapi/testScanPerf.cpp b/ndb/test/ndbapi/testScanPerf.cpp index c1334125978..45f0468bc70 100644 --- a/ndb/test/ndbapi/testScanPerf.cpp +++ b/ndb/test/ndbapi/testScanPerf.cpp @@ -39,8 +39,9 @@ struct Parameter { #define P_LOOPS 8 #define P_CREATE 9 #define P_LOAD 10 +#define P_RESET 11 -#define P_MAX 11 +#define P_MAX 12 static Parameter @@ -55,7 +56,8 @@ g_paramters[] = { { "size", 1000000, 1, ~0 }, { "iterations", 3, 1, ~0 }, { "create_drop", 1, 0, 1 }, - { "data", 1, 0, 1 } + { "data", 1, 0, 1 }, + { "q-reset bounds", 0, 1, 0 } }; static Ndb* g_ndb = 0; @@ -80,7 +82,8 @@ main(int argc, const char** argv){ { "verbose", 'v', arg_flag, &verbose, "Print verbose status", "verbose" } }; const int num_args = 1 + P_MAX; - for(int i = 0; i<P_MAX; i++){ + int i; + for(i = 0; i<P_MAX; i++){ args[i+1].long_name = g_paramters[i].name; args[i+1].short_name = * g_paramters[i].name; args[i+1].type = arg_integer; @@ -107,7 +110,7 @@ main(int argc, const char** argv){ g_err << "Wait until ready failed" << endl; goto error; } - for(int i = optind; i<argc; i++){ + for(i = optind; i<argc; i++){ const char * T = argv[i]; g_info << "Testing " << T << endl; BaseString::snprintf(g_tablename, sizeof(g_tablename), T); @@ -218,21 +221,30 @@ run_scan(){ NDB_TICKS start1, stop; int sum_time= 0; + int sample_rows = 0; + int tot_rows = 0; + NDB_TICKS sample_start = NdbTick_CurrentMillisecond(); + Uint32 tot = g_paramters[P_ROWS].value; + if(g_paramters[P_BOUND].value == 2 || g_paramters[P_FILT].value == 2) + iter *= g_paramters[P_ROWS].value; + + NdbScanOperation * pOp = 0; + NdbIndexScanOperation * pIOp = 0; + NdbConnection * pTrans = 0; + NdbResultSet * rs = 0; + int check = 0; + for(int i = 0; i<iter; i++){ start1 = NdbTick_CurrentMillisecond(); - NdbConnection * pTrans = g_ndb->startTransaction(); + pTrans = pTrans ? pTrans : g_ndb->startTransaction(); if(!pTrans){ g_err << "Failed to start transaction" << endl; err(g_ndb->getNdbError()); return -1; } - NdbScanOperation * pOp; - NdbIndexScanOperation * pIOp; - - NdbResultSet * rs; int par = g_paramters[P_PARRA].value; int bat = g_paramters[P_BATCH].value; NdbScanOperation::LockMode lm; @@ -255,9 +267,17 @@ run_scan(){ assert(pOp); rs = pOp->readTuples(lm, bat, par); } else { - pOp = pIOp = pTrans->getNdbIndexScanOperation(g_indexname, g_tablename); - bool ord = g_paramters[P_ACCESS].value == 2; - rs = pIOp->readTuples(lm, bat, par, ord); + if(g_paramters[P_RESET].value == 0 || pIOp == 0) + { + pOp= pIOp= pTrans->getNdbIndexScanOperation(g_indexname, g_tablename); + bool ord = g_paramters[P_ACCESS].value == 2; + rs = pIOp->readTuples(lm, bat, par, ord); + } + else + { + pIOp->reset_bounds(); + } + switch(g_paramters[P_BOUND].value){ case 0: // All break; @@ -267,20 +287,22 @@ run_scan(){ case 2: { // 1 row default: assert(g_table->getNoOfPrimaryKeys() == 1); // only impl. so far - abort(); -#if 0 int tot = g_paramters[P_ROWS].value; int row = rand() % tot; +#if 0 fix_eq_bound(pIOp, row); +#else + pIOp->setBound((Uint32)0, NdbIndexScanOperation::BoundEQ, &row); #endif break; } } + if(g_paramters[P_RESET].value == 2) + goto execute; } assert(pOp); assert(rs); - int check = 0; switch(g_paramters[P_FILT].value){ case 0: // All check = pOp->interpret_exit_ok(); @@ -309,10 +331,13 @@ run_scan(){ } assert(check == 0); + if(g_paramters[P_RESET].value == 1) + g_paramters[P_RESET].value = 2; + for(int i = 0; i<g_table->getNoOfColumns(); i++){ pOp->getValue(i); } - +execute: int rows = 0; check = pTrans->execute(NoCommit); assert(check == 0); @@ -333,19 +358,30 @@ run_scan(){ return -1; } assert(check == 1); - g_info << "Found " << rows << " rows" << endl; - - pTrans->close(); - + if(g_paramters[P_RESET].value == 0) + { + pTrans->close(); + pTrans = 0; + } stop = NdbTick_CurrentMillisecond(); + int time_passed= (int)(stop - start1); - g_err.println("Time: %d ms = %u rows/sec", time_passed, - (1000*tot)/time_passed); + sample_rows += rows; sum_time+= time_passed; + tot_rows+= rows; + + if(sample_rows >= tot) + { + int sample_time = (int)(stop - sample_start); + g_info << "Found " << sample_rows << " rows" << endl; + g_err.println("Time: %d ms = %u rows/sec", sample_time, + (1000*sample_rows)/sample_time); + sample_rows = 0; + sample_start = stop; + } } - sum_time= sum_time / iter; - g_err.println("Avg time: %d ms = %u rows/sec", sum_time, - (1000*tot)/sum_time); + g_err.println("Avg time: %d ms = %u rows/sec", sum_time/tot_rows, + (1000*tot_rows)/sum_time); return 0; } diff --git a/ndb/test/ndbapi/testSystemRestart.cpp b/ndb/test/ndbapi/testSystemRestart.cpp index f8f2b84acc4..35016896495 100644 --- a/ndb/test/ndbapi/testSystemRestart.cpp +++ b/ndb/test/ndbapi/testSystemRestart.cpp @@ -452,7 +452,7 @@ int runSystemRestart3(NDBT_Context* ctx, NDBT_Step* step){ } Vector<int> nodeIds; - for(Uint32 i = 0; i<nodeCount; i++) + for(i = 0; i<nodeCount; i++) nodeIds.push_back(restarter.getDbNodeId(i)); Uint32 currentRestartNodeIndex = 0; @@ -561,7 +561,7 @@ int runSystemRestart4(NDBT_Context* ctx, NDBT_Step* step){ } Vector<int> nodeIds; - for(Uint32 i = 0; i<nodeCount; i++) + for(i = 0; i<nodeCount; i++) nodeIds.push_back(restarter.getDbNodeId(i)); Uint32 currentRestartNodeIndex = 0; @@ -691,7 +691,7 @@ int runSystemRestart5(NDBT_Context* ctx, NDBT_Step* step){ } Vector<int> nodeIds; - for(Uint32 i = 0; i<nodeCount; i++) + for(i = 0; i<nodeCount; i++) nodeIds.push_back(restarter.getDbNodeId(i)); Uint32 currentRestartNodeIndex = 0; @@ -821,7 +821,7 @@ int runSystemRestart6(NDBT_Context* ctx, NDBT_Step* step){ } Vector<int> nodeIds; - for(Uint32 i = 0; i<nodeCount; i++) + for(i = 0; i<nodeCount; i++) nodeIds.push_back(restarter.getDbNodeId(i)); Uint32 currentRestartNodeIndex = 0; @@ -877,7 +877,7 @@ int runSystemRestart7(NDBT_Context* ctx, NDBT_Step* step){ } Vector<int> nodeIds; - for(Uint32 i = 0; i<nodeCount; i++) + for(i = 0; i<nodeCount; i++) nodeIds.push_back(restarter.getDbNodeId(i)); int a_nodeIds[64]; @@ -952,7 +952,7 @@ int runSystemRestart8(NDBT_Context* ctx, NDBT_Step* step){ } Vector<int> nodeIds; - for(Uint32 i = 0; i<nodeCount; i++) + for(i = 0; i<nodeCount; i++) nodeIds.push_back(restarter.getDbNodeId(i)); int a_nodeIds[64]; diff --git a/ndb/test/odbc/tpcb/Makefile b/ndb/test/odbc/tpcb/Makefile deleted file mode 100644 index 8ab429c8ea1..00000000000 --- a/ndb/test/odbc/tpcb/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -include .defs.mk - -TYPE = * - -BIN_TARGET = tpcb - -SOURCES = ttTime.c tpcb.cpp - -CCFLAGS_LOC += \ - -I$(NDB_TOP)/include \ - -I$(NDB_TOP)/include/ndbapi \ - -I$(NDB_TOP)/include/portlib \ - -I$(NDB_TOP)/include/util \ - -I$(NDB_TOP)/test/include \ - -I/usr/local/include - -CCFLAGS_WARNINGS += -Wno-unused -Wno-sign-compare -Wformat - -CCFLAGS_TOP += -DndbODBC - -BIN_TARGET_LIBS = NDB_API_pic NDB_ODBC_pic NDBT - -ifeq ($(NDB_OS),SOLARIS) -BIN_TARGET_LIBS += dmallocthcxx -CCFLAGS_TOP += -DDMALLOC -endif - -include $(NDB_TOP)/Epilogue.mk - -$(BIN_DIR)$(BIN_TARGET): Makefile diff --git a/ndb/test/odbc/tpcb/Makefile_mysql b/ndb/test/odbc/tpcb/Makefile_mysql deleted file mode 100644 index 4e1b9a25fe2..00000000000 --- a/ndb/test/odbc/tpcb/Makefile_mysql +++ /dev/null @@ -1,33 +0,0 @@ -include $(NDB_TOP)/Defs.mk - -TYPE = odbcclient - -BIN_TARGET = tpcb - -SOURCES = ttTime.c tpcb.cpp - -CCFLAGS_LOC += -I/usr/local/include \ - -I$(NDB_TOP)/test/include \ - -I$(NDB_TOP)/include \ - -I$(NDB_TOP)/include/util \ - -I$(NDB_TOP)/src/client/odbc/common - - - - -#CCFLAGS_WARNINGS += -Wno-unused - -LIBS_LOC += -L/usr/local/lib -BIN_TARGET_LIBS_DIRS += /usr/local/lib -BIN_TARGET_LIBS += odbc odbcinst - -#LIBS_SPEC += -pg -# -lNDBT \ -# -lodbc \ -# -lodbcinst \ -# -lportlib - - - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/test/odbc/tpcb/Makefile_ndb b/ndb/test/odbc/tpcb/Makefile_ndb deleted file mode 100644 index 85960413ef0..00000000000 --- a/ndb/test/odbc/tpcb/Makefile_ndb +++ /dev/null @@ -1,30 +0,0 @@ -include $(NDB_TOP)/Defs.mk - -TYPE = * - -BIN_TARGET = tpcb - -SOURCES = ttTime.c tpcb.cpp - -CCFLAGS_LOC += \ - -I$(NDB_TOP)/include \ - -I$(NDB_TOP)/include/ndbapi \ - -I$(NDB_TOP)/include/portlib \ - -I$(NDB_TOP)/include/util \ - -I$(NDB_TOP)/test/include \ - -I/usr/local/include - -CCFLAGS_WARNINGS += -Wno-unused -Wno-sign-compare -Wformat - -CCFLAGS_TOP += -DndbODBC - -BIN_TARGET_LIBS = NDB_API_pic NDB_ODBC_pic NDBT - -ifeq ($(NDB_OS),SOLARIS) -BIN_TARGET_LIBS += dmallocthcxx -CCFLAGS_TOP += -DDMALLOC -endif - -include $(NDB_TOP)/Epilogue.mk - -$(BIN_DIR)$(BIN_TARGET): Makefile diff --git a/ndb/test/odbc/tpcb/readme.txt b/ndb/test/odbc/tpcb/readme.txt deleted file mode 100644 index 008cafb9d2f..00000000000 --- a/ndb/test/odbc/tpcb/readme.txt +++ /dev/null @@ -1,15 +0,0 @@ -'tpcb' requires an .odbc.ini file in -/etc/ -or in -/home/user/ - -The .odbc.ini file must contain a DSN entry called ndb: - -#--------- .odbc.ini example -------------------- - -[ndb] -Driver = /path_to_installation/lib/libNDB_ODBC.so - -#--------- End of example ----------------------- - - diff --git a/ndb/test/odbc/tpcb/timesten.h b/ndb/test/odbc/tpcb/timesten.h deleted file mode 100644 index 45579f9d277..00000000000 --- a/ndb/test/odbc/tpcb/timesten.h +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; 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 */ - -/* - * $Revision: 1.1 $ - * (c) Copyright 1997-2003, TimesTen, Inc. - * All rights reserved. - */ - -#ifndef TIMESTEN_H_INCLUDED -#define TIMESTEN_H_INCLUDED - -#ifdef _WIN32 -#include <windows.h> -#endif - -#include <sql.h> -#include <sqltypes.h> -#include <sqlext.h> -/* - * TimesTen extension to application data types; only usable - * when application directly linked to the TimesTen driver. - */ -#define SQL_C_ADDR 100 - -#ifndef SQL_C_SBIGINT -#if (ODBCVER < 0x0300) -#define SQL_C_SBIGINT (SQL_BIGINT+SQL_SIGNED_OFFSET) -#define SQL_C_UBIGINT (SQL_BIGINT+SQL_UNSIGNED_OFFSET) -#endif -#endif - -#define SQL_C_BIGINT SQL_C_SBIGINT - -#if (ODBCVER < 0x0300) -#ifdef _WIN32 -typedef __int64 SQLBIGINT; -/* On Unix platforms SQLBIGINT is defined in odbcinclude directory*/ -#endif -#endif - -#define BIGINT SQLBIGINT - -#ifdef _WIN32 -#define UBIGINT unsigned __int64 -#else -#define UBIGINT unsigned long long -#endif - - -#define SQL_WCHAR (-8) -#define SQL_WVARCHAR (-9) -#define SQL_WLONGVARCHAR (-10) -#define SQL_C_WCHAR SQL_WCHAR - -/* SQLGetInfo() InfoTypes */ -#define SQL_CONVERT_WCHAR 122 -#define SQL_CONVERT_WLONGVARCHAR 125 -#define SQL_CONVERT_WVARCHAR 126 - -/* TimesTen specific SQLGetInfo types */ -#define TT_REPLICATION_INVALID (SQL_INFO_DRIVER_START + 2000) - -/* SQLGetInfo() return value bitmasks */ -#ifndef SQL_CVT_WCHAR -/* -** These definitions differ from Microsoft in that they are not -** specified as long (e.g. 0x00200000L), hence they are protected -** by the ifndef above. -*/ -#define SQL_CVT_WCHAR 0x00200000 -#define SQL_CVT_WLONGVARCHAR 0x00400000 -#define SQL_CVT_WVARCHAR 0x00800000 -#endif - -/* -** The Microsoft Driver Manager SQLBindParameter() will not pass SQL_WCHAR -** through. Use this hack to get around it. -*/ -#define SQL_WCHAR_DM_SQLBINDPARAMETER_BYPASS -888 - -/* This is an extension to ODBC's isolation levels. It reflects an - * earlier implementation of read-committed that released locks on - * next fetch, rather than releasing locks before returning value to - * application. */ -#define SQL_TXN_CURSOR_STABILITY 0x00001000 -#define SQL_TXN_NOBLOCK_DELETE 0x00002000 - -/* TimesTen-specific connection option */ -#define TT_PREFETCH_CLOSE 10001 -#define TT_PREFETCH_CLOSE_OFF 0 -#define TT_PREFETCH_CLOSE_ON 1 - -/* Adding a new sql connection option */ -#define TT_PREFETCH_COUNT 10003 -#define TT_PREFETCH_COUNT_MAX 128 - -/* - * Platform specific data types for integers that scale - * with pointer size - */ - -#ifdef _IA64_ -typedef signed __int64 tt_ptrint; -typedef unsigned __int64 tt_uptrint; -#else -#ifdef _WIN32 -typedef signed long tt_ptrint; -typedef unsigned long tt_uptrint; -#else -typedef signed long tt_ptrint; -typedef unsigned long tt_uptrint; -#endif -#endif - -#ifdef _WIN32 -typedef signed __int64 tt_int8; -typedef unsigned __int64 tt_uint8; -#else -typedef signed long long tt_int8; -typedef unsigned long long tt_uint8; -#endif - -/* printf formats for pointer-sized integers */ -#ifdef _IA64_ /* 64-bit NT */ -#define PTRINT_FMT "I64d" -#define UPTRINT_FMT "I64u" -#define xPTRINT_FMT "I64x" -#define XPTRINT_FMT "I64X" -#else -#ifdef _WIN32 /* 32-bit NT */ -#define PTRINT_FMT "ld" -#define UPTRINT_FMT "lu" -#define xPTRINT_FMT "lx" -#define XPTRINT_FMT "lX" -#else /* 32 and 64-bit UNIX */ -#define PTRINT_FMT "ld" -#define UPTRINT_FMT "lu" -#define xPTRINT_FMT "lx" -#define XPTRINT_FMT "lX" -#endif -#endif - -/* printf formats for 8-byte integers */ -#ifndef INT8_FMT_DEFINED -#ifdef _WIN32 /* 32 and 64-bit NT */ -#define INT8_FMT "I64d" -#define UINT8_FMT "I64u" -#define xINT8_FMT "I64x" -#define XINT8_FMT "I64X" -#else /* 32 and 64-bit UNIX */ -#define INT8_FMT "lld" -#define UINT8_FMT "llu" -#define xINT8_FMT "llx" -#define XINT8_FMT "llX" -#endif -#define INT8_FMT_DEFINED 1 -#endif - -/* The following types are defined in the newer odbc include files - from Microsoft -*/ -#if defined (_WIN32) && !defined (_IA64_) -#ifndef SQLROWSETSIZE -#define SQLROWSETSIZE SQLUINTEGER -#define SQLLEN SQLINTEGER -#define SQLROWOFFSET SQLINTEGER -#define SQLROWCOUNT SQLUINTEGER -#define SQLULEN SQLUINTEGER -#define SQLSETPOSIROW SQLUSMALLINT -#endif -#endif - - -#endif diff --git a/ndb/test/odbc/tpcb/tpcb.cpp b/ndb/test/odbc/tpcb/tpcb.cpp deleted file mode 100644 index 60d746e7844..00000000000 --- a/ndb/test/odbc/tpcb/tpcb.cpp +++ /dev/null @@ -1,1415 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; 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 */ - -static const volatile char cvsid[] = "$Id: tpcb.cpp,v 1.4 2003/09/26 09:04:34 johan Exp $"; -/* - * $Revision: 1.4 $ - * (c) Copyright 1996-2003, TimesTen, Inc. - * All rights reserved. - */ - -/* This source is best displayed with a tabstop of 4 */ - -#define NDB - -//#define MYSQL - -#ifdef WIN32 -#include <windows.h> -#include "ttRand.h" -#else -#if !defined NDB && !defined MYSQL -#include <sqlunix.h> -#endif -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#ifdef SB_P_OS_CHORUS -#include "ttRand.h" -#endif -#endif - -#include <math.h> -#include <time.h> -#include <sql.h> -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> - -#if !defined NDB && !defined MYSQL -#include "ttTime.h" -#include "utils.h" -#include "tt_version.h" -#include "timesten.h" -#endif - -#if defined NDB || defined MYSQL -#include <NdbOut.hpp> -#include <string.h> - -#include <sqlext.h> -#include <sql.h> -extern "C" { -#include "ttTime.h" -#include "timesten.h" - void ttGetWallClockTime(ttWallClockTime* timeP); - void ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisecondsP); - void ttGetThreadTimes(ttThreadTimes * endRes); - void ttCalcElapsedThreadTimes(ttThreadTimes* startRes, - ttThreadTimes * endRes, - double * kernel, - double * user); -} - -#define app_exit exit -#define status_msg0 ndbout_c -#define status_msg1 ndbout_c -#define status_msg2 ndbout_c -#define err_msg0 ndbout_c -#define err_msg1 ndbout_c -#define err_msg3 ndbout_c -#define out_msg0 ndbout_c -#define out_msg1 ndbout_c -#define out_msg3 ndbout_c -#define CONN_STR_LEN 255 -#define DBMS_TIMESTEN 1 -#define DBMS_MSSQL 2 -#define DBMS_UNKNOWN 3 -#define ABORT_DISCONNECT_EXIT 1 -#define NO_EXIT 0 -#define ERROR_EXIT 1 -#define DISCONNECT_EXIT 2 -#endif - -#define VERBOSE_NOMSGS 0 -/* this value is used for results (and err msgs) only */ -#define VERBOSE_RESULTS 1 -/* this value is the default for the cmdline demo */ -#define VERBOSE_DFLT 2 -#define VERBOSE_ALL 3 - -#ifdef MYSQL -#define DSNNAME "DSN=myodbc3" -#elif defined NDB -#define DSNNAME "DSN=ndb" -#else -#define DSNNAME "DSN=" -#endif - -/* number of branches, tellers, and accounts */ - -#define NumBranches 1 -#define TellersPerBranch 10 -#define AccountsPerBranch 10000 - -/* number of transactions to execute */ - -#define NumXacts 25000 - -/* starting seed value for the random number generator */ - -#define SeedVal 84773 - -/* for MS SQL, the drop, create and use database statements */ - -#define DatabaseDropStmt "drop database tpcbDB;" -#ifdef MYSQL -#define DatabaseCreateStmt "create database tpcbDB;" -#else -#define DatabaseCreateStmt "create database tpcbDB ON DEFAULT = %d;" -#endif -#define DatabaseUseStmt "use tpcbDB;" - -/* - * Specifications of table columns. - * Fillers of 80, 80, 84, and 24 bytes, respectively, are used - * to ensure that rows are the width required by the benchmark. - * - * Note: The TimesTen and MS SQL CREATE TABLE statements for the - * accounts, tellers and branches tables are different. - * - */ - -#define TuplesPerPage 256 - - -#ifdef MYSQL - -#define AccountCrTblStmt "create table accounts \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float not null, \ -filler char(80));" - -#define TellerCrTblStmt "create table tellers \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float not null, \ -filler char(80));" - -#define BranchCrTblStmt "create table branches \ -(number integer not null primary key, \ -balance float not null, \ -filler char(84));" - -#endif - - -#ifdef NDB -#define AccountCrTblStmt "create table accounts \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float not null, \ -filler char(80)) nologging" - -#define TellerCrTblStmt "create table tellers \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float not null, \ -filler char(80)) nologging" - -#define BranchCrTblStmt "create table branches \ -(number integer not null primary key, \ -balance float not null, \ -filler char(84)) nologging" -#endif - -#ifdef NDB - -#define HistoryCrTblStmt "create table History \ -(tellernum integer not null, \ -branchnum integer not null, \ -accountnum integer not null, \ -delta float not null, \ -createtime integer not null, \ -filler char(24), \ -primary key (tellernum, branchnum, accountnum, delta, createtime)) nologging" - -#else - -#ifdef MYSQL - -#define HistoryCrTblStmt "create table History \ -(tellernum integer not null, \ -branchnum integer not null, \ -accountnum integer not null, \ -delta float(53) not null, \ -createtime integer not null, \ -filler char(24))" -#endif - -#define HistoryCrTblStmt "create table History \ -(tellernum integer not null, \ -branchnum integer not null, \ -accountnum integer not null, \ -delta float(53) not null, \ -createtime integer not null, \ -filler char(24));" -#endif - -#define TTAccountCrTblStmt "create table accounts \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float(53) not null, \ -filler char(80)) unique hash on (number) pages = %" PTRINT_FMT ";" - -#define TTTellerCrTblStmt "create table tellers \ -(number integer not null primary key, \ -branchnum integer not null, \ -balance float(53) not null, \ -filler char(80)) unique hash on (number) pages = %" PTRINT_FMT ";" - -#define TTBranchCrTblStmt "create table branches \ -(number integer not null primary key, \ -balance float(53) not null, \ -filler char(84)) unique hash on (number) pages = %" PTRINT_FMT ";" - - -/* Insertion statements used to populate the tables */ - -#define NumInsStmts 3 -char* insStmt[NumInsStmts] = { - "insert into branches values (?, 0.0, NULL)", - "insert into tellers values (?, ?, 0.0, NULL)", - "insert into accounts values (?, ?, 0.0, NULL)" -}; - -/* Transaction statements used to update the tables */ - -#define NumXactStmts 5 - -#ifdef NDB -char* tpcbXactStmt[NumXactStmts] = { - "update accounts \ -set balance = balance + ? \ -where number = ?", - - "select balance \ -from accounts \ -where number = ?", - - "update tellers \ -set balance = balance + ? \ -where number = ?", - - "update branches \ -set balance = balance + ? \ -where number = ?", - - "insert into History(tellernum, branchnum, \ -accountnum, delta, createtime, filler) \ -values (?, ?, ?, ?, ?, NULL)" -}; - -#else -char* tpcbXactStmt[NumXactStmts] = { - "update accounts \ -set balance = balance + ? \ -where number = ?;", - - "select balance \ -from accounts \ -where number = ?;", - - "update tellers \ -set balance = balance + ? \ -where number = ?;", - - "update branches \ -set balance = balance + ? \ -where number = ?;", - - "insert into History \ -values (?, ?, ?, ?, ?, NULL);" -}; - - -#endif - -/* Global parameters and flags (typically set by parse_args()) */ - -int tabFlag = 0; /* Default is NOT tab output mode */ -char szConnStrIn[CONN_STR_LEN]; /* ODBC Connection String */ -int printXactTimes = 0; /* Transaction statistics - * gathering flag */ -char statFile[FILENAME_MAX]; /* Transaction statistics filename */ -int scaleFactor = 2; /* Default TPS scale factor */ -int numBranchTups; /* Number of branches */ -int numTellerTups; /* Number of tellers */ -int numAccountTups; /* Number of accounts */ -int numNonLocalAccountTups; /* Number of local accounts */ -int numXacts = NumXacts; /* Default number of transactions */ -int verbose = VERBOSE_DFLT; /* Verbose level */ -FILE *statusfp; /* File for status messages */ - - - -int DBMSType; /* DBMS type (DBMS_TIMESTEN, DBMS_MSSQL...) */ - - -SQLHENV henv; /* Environment handle */ - - - - - - - -void handle_errors( SQLHDBC hdbc, SQLHSTMT hstmt, int errcode, int action, char * msg, - char * file, int line) { - - if (errcode == SQL_SUCCESS) - return; - - if(errcode == SQL_ERROR) { - int ret; - long diagCount=0; - short length=0; - SQLCHAR state[10] = ""; - SQLCHAR message[200] = ""; - long native = 0; - if(hstmt != 0) { - ret = SQLGetDiagField(SQL_HANDLE_STMT, hstmt, 0, SQL_DIAG_NUMBER, &diagCount, SQL_IS_INTEGER, 0); - - for(long i = 0; i < diagCount; i++) { - ret = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, i, (SQLCHAR*)state, &native, (SQLCHAR*)message, 200, &length); - ndbout_c("GetDiagRec: Message : %s ", message); - } - } - } - - if(errcode != SQL_SUCCESS) { - ndbout_c("Message: %s", msg); - switch(errcode) { - case SQL_SUCCESS_WITH_INFO: - ndbout_c("SQL_SUCCESS_WITH_INFO"); - break; - case SQL_STILL_EXECUTING: - ndbout_c("SQL_STILL_EXECUTING"); - break; - case SQL_ERROR: - ndbout_c("SQL_ERROR"); - break; - case SQL_INVALID_HANDLE: - ndbout_c("SQL_INVALID_HANDLE"); - break; - default: - ndbout_c("Some other error"); - } - exit(1); - } - - -} - - - - - -/********************************************************************* - * FUNCTION: usage - * - * DESCRIPTION: This function prints a usage message describing - * the command line options of the program. - * - * PARAMETERS: char* prog full program path name - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -static void usage(char *prog) -{ - char *progname; - - /* Get the name of the program (sans path). */ - -#ifdef WIN32 - progname = strrchr(prog, '\\'); -#else - progname = strrchr(prog, '/'); -#endif - if (progname == 0) - progname = prog; - else - ++progname; - - /* Print the usage message */ - - fprintf(stderr, - "Usage:\t%s [-h] [-help] [-V] [-connStr <string>] [-v <level>]\n" - "\t\t[-xact <xacts>] [-scale <scale>] [-tabs] [-s <statfile>]\n\n" - " -h Prints this message and exits.\n" - " -help Same as -h.\n" - " -V Prints version number and exits.\n" - " -connStr <string> Specifies an ODBC connection string to replace the\n" - " default DSN for the program. The default is\n" - " \"DSN=TpcbData<version>;OverWrite=1\".\n" - " -v <level> Verbose level\n" - " 0 = errors only\n" - " 1 = results only\n" - " 2 = results and some status messages (default)\n" - " 3 = all messages\n" - " -xact <xacts> Specifies the number of transactions to be run\n" - " The default is 25000 transactions.\n" - " -scale <scale> Specifies a scale factor which determines the\n" - " number of branches (scale), tellers (scale x 10),\n" - " accounts (scale x 10000) and non-local accounts\n" - " ((scale-1) x 10000. The default scale factor is 2.\n" - " -tabs Specifies that the output be a tab-separated\n" - " format suitable for import into a spreadsheet.\n" - " Results only go to stdout; status and other\n" - " messages go to stderr.\n" - " -s <statfile> Prints individual transaction times to <statfile>.\n", - progname); -} - -/********************************************************************* - * - * FUNCTION: parse_args - * - * DESCRIPTION: This function parses the command line arguments - * passed to main(), setting the appropriate global - * variables and issuing a usage message for - * invalid arguments. - * - * PARAMETERS: int argc # of arguments from main() - * char *argv[] arguments from main() - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -parse_args(int argc, char *argv[]) -{ - int i = 1; - - *szConnStrIn = 0; - - while (i < argc) { - - if ( !strcmp(argv[i], "-h") || !strcmp(argv[i], "-help") ) { - usage(argv[0]); - app_exit(0); - } - /* - if (!strcmp(argv[i], "-V")) { - printf("%s\n", TTVERSION_STRING); - app_exit(0); - } - */ - if (strcmp(argv[i], "-s") == 0) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - if (sscanf(argv[i+1], "%s", statFile) == 0) { - usage(argv[0]); - app_exit(1); - } - printXactTimes = 1; - i += 2; - } - else if (!strcmp(argv[i], "-connStr")) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - strcpy(szConnStrIn, argv[i+1]); - i += 2; - continue; - } - else if (strcmp("-v", argv[i]) == 0) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - if (sscanf(argv[i+1], "%d", &verbose) == -1 || - verbose < 0 || verbose > 3) { - fprintf(stderr, "-v flag requires an integer parameter (0-3)\n"); - usage(argv[0]); - app_exit(1); - } - i += 2; - } - else if (strcmp("-xact",argv[i]) == 0) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - - if (sscanf(argv[i+1], "%" PTRINT_FMT, &numXacts) == -1 || numXacts < 0) { - fprintf(stderr, "-xact flag requires a non-negative integer argument\n"); - usage(argv[0]); - app_exit(1); - } - - i += 2; - } - else if (strcmp("-scale",argv[i]) == 0) { - if (argc < i+2 ) { - usage(argv[0]); - app_exit(1); - } - if (sscanf(argv[i+1], "%d", &scaleFactor) == -1 || scaleFactor < 1) { - fprintf(stderr, "-scale flag requires an integer argument >= 1\n"); - usage(argv[0]); - app_exit(1); - } - /* Calculate tuple sizes */ - numBranchTups = NumBranches * scaleFactor; - numTellerTups = TellersPerBranch * scaleFactor; - numAccountTups = AccountsPerBranch * scaleFactor; - numNonLocalAccountTups = AccountsPerBranch * (scaleFactor-1); - i += 2; - } - else if (strcmp("-tabs",argv[i]) == 0) { - tabFlag = 1; - statusfp = stderr; - i += 1; - } - else { - usage(argv[0]); - app_exit(1); - } - } -} - -/********************************************************************* - * - * FUNCTION: doImmed - * - * DESCRIPTION: This function executes and frees the specified - * statement. It is used as a direct means to - * create the tables used by this benchmark, - * - * PARAMETERS: SQLHDBC hdbc SQL Connection handle - * SQLHSTMT hs SQL Statement handle - * char* cmd SQL Statement text - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -doImmed(SQLHDBC hdbc, SQLHSTMT hs, char* cmd) -{ - SQLRETURN rc; - - /* Execute the command */ - - rc = SQLExecDirect(hs, (SQLCHAR *) cmd, SQL_NTS); - handle_errors(hdbc, hs, rc, ABORT_DISCONNECT_EXIT, - "Error executing statement", __FILE__, __LINE__); - - /* Close associated cursor and drop pending results */ - - rc = SQLFreeStmt(hs, SQL_CLOSE); - handle_errors(hdbc, hs, rc, ABORT_DISCONNECT_EXIT, - "closing statement handle", - __FILE__, __LINE__); - -} - - -/********************************************************************* - * - * FUNCTION: main - * - * DESCRIPTION: This is the main function of the tpcb benchmark. - * It connects to an ODBC data source, creates and - * populates tables, updates the tables in a user- - * specified number of transactions and reports on - * on the transaction times. - * - * PARAMETERS: int argc # of command line arguments - * char *argv[] command line arguments - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -int -main(int argc, char *argv[]) -{ - - /* variables used for setting up the tables */ - - char cmdStr[1024]; - char errstr[4096]; - - /* variables used during transactions */ - - int accountNum; - int tellerNum; - int branchNum; - int timeStamp; - double delta; - unsigned int lrand; - unsigned short *srands, localLimit; - int lp64; - - /* variables used for timing and statistics */ - - int warmup; - double kernel, user, real; - ttThreadTimes startRes, endRes; - ttWallClockTime startT, endT; - ttWallClockTime** rtStart; - ttWallClockTime** rtEnd; - double** resTime; - double maxTime, totTime; - int i; - int j; - int numLocalXacts=0, numRemoteXacts=0; - - /* variables for ODBC */ - - SQLHDBC hdbc; - SQLHSTMT hstmt; - SQLHSTMT txstmt[NumXactStmts]; - SQLRETURN rc; - char DBMSName[32]; - char DBMSVersion[32]; - int databaseSize; - - int fThreadTime = 1; - -#ifdef WIN32 - OSVERSIONINFO sysInfo; - - sysInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx (&sysInfo); - - /* GetThreadTimes is not supported on 95/98. Hence, - we do not support Resource/User/System times */ - if (sysInfo.dwPlatformId != VER_PLATFORM_WIN32_NT) - fThreadTime = 0; -#endif -#if defined(TTCLIENTSERVER) && defined(__hpux) && !defined(__LP64__) - /* HP requires this for C main programs that call aC++ shared libs */ - _main(); -#endif /* hpux32 */ - - /* Set up default signal handlers */ - -#ifndef NDB - /* StopRequestClear(); - if (HandleSignals() != 0) { - err_msg0("Unable to set signal handlers\n"); - return 1; - } - */ -#endif - /* set IO mode for demo */ - /* set_io_mode(); */ - - /* initialize the file for status messages */ - statusfp = stdout; - - /* set variable for 8-byte longs */ - lp64 = (sizeof(lrand) == 8); - - /* set the default tuple sizes */ - - numBranchTups = NumBranches * scaleFactor; - numTellerTups = TellersPerBranch * scaleFactor; - numAccountTups = AccountsPerBranch * scaleFactor; - numNonLocalAccountTups = AccountsPerBranch * (scaleFactor-1); - - /* parse the command arguments */ - parse_args(argc, argv); - - /* allocate the transaction-based variables */ - - rtStart = (ttWallClockTime**) malloc(numXacts * sizeof(ttWallClockTime*)); - if (!rtStart) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - for (i = 0; i < numXacts; i++) { - rtStart[i] = (ttWallClockTime*) malloc(sizeof(ttWallClockTime)); - if (!rtStart[i]) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - } - - rtEnd = (ttWallClockTime**) malloc(numXacts * sizeof(ttWallClockTime*)); - if (!rtEnd) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - for (i = 0; i < numXacts; i++) { - rtEnd[i] = (ttWallClockTime*) malloc(sizeof(ttWallClockTime)); - if (!rtEnd[i]) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - } - - resTime = (double**) malloc(numXacts * sizeof(double*)); - if (!resTime) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - for (i = 0; i < numXacts; i++) { - resTime[i] = (double*) malloc(sizeof(double)); - if (!resTime[i]) { - err_msg0("Cannot allocate the transaction timing structures"); - app_exit(1); - } - } - - /* ODBC initialization */ - - rc = SQLAllocEnv(&henv); - if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - /* error occurred -- don't bother calling handle_errors, since handle - * is not valid so SQLError won't work */ - err_msg3("ERROR in %s, line %d: %s\n", - __FILE__, __LINE__, "allocating an environment handle"); - app_exit(1); - } - SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER); - - /* call this in case of warning */ - handle_errors(NULL, NULL, rc, NO_EXIT, - "allocating execution environment", - __FILE__, __LINE__); - - rc = SQLAllocConnect(henv, &hdbc); - handle_errors(NULL, NULL, rc, ERROR_EXIT, - "allocating connection handle", - __FILE__, __LINE__); - - /* Connect to data store */ - - status_msg0("Connecting to the data source...\n"); - - /* Set up the connection options if not specified on the command line - * (default to TimesTen settings). - */ - - if ( !*szConnStrIn ) { - /* Running the benchmark with a scale factor creates (scale) branches, - * (scale x 10) tellers, (scale x 10000) accounts and ((scale-1) x 10000) - * non-local accounts. The size of the table rows are branches (141) - * tellers (141) and accounts (141). Therefore the data size requirements - * of this benchmark is: - * size ~= 141 * ((scale * 20011) - 10000) (bytes) - * - * Multiply data size by 20% to account for additional DB overhead (e.g. - * indexes), and round up the nearest 10Mb for safety. - */ - - int est_size = (int) (3.6 * scaleFactor + 10.0); - est_size = est_size - (est_size % 10); - - sprintf(szConnStrIn,"OverWrite=1;PermSize=%d;%s", - est_size, DSNNAME); - status_msg0("Connecting to the data source... %s \n", szConnStrIn); - } - - rc = SQLDriverConnect(hdbc, NULL, (SQLCHAR *) szConnStrIn, SQL_NTS, - NULL, 0, NULL, - SQL_DRIVER_NOPROMPT); - - status_msg0("Connected to the data source...\n"); - sprintf(errstr, "connecting to driver (connect string %s)\n", - szConnStrIn); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - errstr, __FILE__, __LINE__); - - /* Turn auto-commit off */ - - rc = SQLSetConnectOption(hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF); - handle_errors(hdbc, NULL, rc, DISCONNECT_EXIT, - "switching off the AUTO_COMMIT option", - __FILE__, __LINE__); - - /* Allocate a statement handle */ - - rc = SQLAllocStmt(hdbc, &hstmt); - handle_errors(hdbc, NULL, rc, DISCONNECT_EXIT, - "allocating a statement handle", - __FILE__, __LINE__); - - /* (Implicit) Transaction begin */ - - /* Determine the DBMS Type*/ - - DBMSName[0] = '\0'; - rc = SQLGetInfo(hdbc, SQL_DBMS_NAME, (PTR) &DBMSName, - sizeof(DBMSName), NULL); - rc = SQLGetInfo(hdbc, SQL_DRIVER_VER, (PTR) &DBMSVersion, - sizeof(DBMSVersion), NULL); - - if (strcmp(DBMSName, "TimesTen") == 0) - DBMSType = DBMS_TIMESTEN; - else if (strcmp(DBMSName, "Microsoft SQL Server") == 0) - DBMSType = DBMS_MSSQL; - else DBMSType = DBMS_UNKNOWN; - - /* if not TimesTen: delete (if it exists), create & use the new database */ - - if (DBMSType != DBMS_TIMESTEN) { - status_msg0("Deleting the database...\n"); - rc = SQLExecDirect(hstmt, (SQLCHAR *) DatabaseDropStmt, SQL_NTS); - - /* estimate database size, size = data space + log space - * data space = (#tuples)/(tuples per page) * 2K bytes/page - * tuples per page = useable page size / row size (no index) = 2016/(96+2) - * log space = #transactions * average log size for the program transaction mix - * database size is in MB - */ - - databaseSize = (int) ceil((((numBranchTups + numTellerTups + numAccountTups)/ - (2016/98)) * 2048 + (numXacts * 600)) / 1000000.0); - - status_msg1("Creating the database (%dMB)...\n", databaseSize); -#ifndef NDB - sprintf(cmdStr, DatabaseCreateStmt, databaseSize); - doImmed(hdbc, hstmt, cmdStr); - strcpy(cmdStr, DatabaseUseStmt); - doImmed(hdbc, hstmt, cmdStr); -#endif - } - - status_msg2("Connected to '%s' version '%s'...\n", DBMSName, DBMSVersion); - - /* create branches table */ - status_msg0("Creating tasddbles...\n"); -#ifndef NDB - if (DBMSType == DBMS_TIMESTEN) - sprintf(cmdStr, TTBranchCrTblStmt, numBranchTups/TuplesPerPage + 1); - else -#endif - sprintf(cmdStr, BranchCrTblStmt); - doImmed(hdbc, hstmt, cmdStr); - - /* create tellers table */ -#ifndef NDB - if (DBMSType == DBMS_TIMESTEN) - sprintf(cmdStr, TTTellerCrTblStmt, numTellerTups/TuplesPerPage + 1); - - else -#endif - sprintf(cmdStr, TellerCrTblStmt); - doImmed(hdbc, hstmt, cmdStr); - - /* create accounts table */ -#ifndef NDB - if (DBMSType == DBMS_TIMESTEN) - sprintf(cmdStr, TTAccountCrTblStmt, numAccountTups/TuplesPerPage + 1); - else -#endif - sprintf(cmdStr, AccountCrTblStmt); - doImmed(hdbc, hstmt, cmdStr); - - /* create History table */ - - doImmed(hdbc, hstmt, HistoryCrTblStmt); - - /* lock the database during population */ -#ifndef NDB - if ( DBMSType == DBMS_TIMESTEN ) { - rc = SQLExecDirect(hstmt, (SQLCHAR *)"call ttlocklevel('DS')", SQL_NTS); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "specifying dbs lock usage", - __FILE__, __LINE__); - /* make sure dbs lock take effect in next transaction */ - rc = SQLTransact(henv,hdbc,SQL_COMMIT); - if ( rc != SQL_SUCCESS) { - handle_errors(hdbc, SQL_NULL_HSTMT, rc, ERROR_EXIT, - "committing transaction", - __FILE__, __LINE__); - } - } -#endif - /* populate branches table */ - - - rc = SQLPrepare(hstmt, (SQLCHAR *) insStmt[0], SQL_NTS); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "preparing statement", - __FILE__, __LINE__); - - rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 10, 0, &branchNum, sizeof branchNum, NULL); - - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - - status_msg1("Populating branches table (%" PTRINT_FMT " rows)...\n", - numBranchTups); - - - for (i=0; i<numBranchTups; i++) { - branchNum = i; - rc = SQLExecute(hstmt); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "Error executing statement", - __FILE__, __LINE__); - } - - /* Reset all bind-parameters for the statement handle. */ - rc = SQLFreeStmt(hstmt, SQL_RESET_PARAMS); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "resetting parms on statement handle", - __FILE__, __LINE__); - - /* populate tellers table */ - - status_msg1("Populating tellers table (%" PTRINT_FMT " rows)...\n", - numTellerTups); - - - rc = SQLPrepare(hstmt, (SQLCHAR *) insStmt[1], SQL_NTS); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "preparing statement", - __FILE__, __LINE__); - - rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, - 10, 0, &tellerNum, sizeof tellerNum, NULL); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, - 10, 0, &branchNum, sizeof branchNum, NULL); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - for (i=0; i<numTellerTups; i++) { - tellerNum = i; - branchNum = i/TellersPerBranch; - rc = SQLExecute(hstmt); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "Error executing statement", - __FILE__, __LINE__); - } - - /* Reset all bind-parameters for the statement handle. */ - - rc = SQLFreeStmt(hstmt, SQL_RESET_PARAMS); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "resetting parms on statement handle", - __FILE__, __LINE__); - - /* populate accounts table */ - - status_msg1("Populating accounts table (%" PTRINT_FMT " rows)...\n", - numAccountTups); - - rc = SQLPrepare(hstmt, (SQLCHAR *) insStmt[2], SQL_NTS); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "preparing statement", - __FILE__, __LINE__); - - rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, - 10, 0, &accountNum, sizeof accountNum, NULL); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, - 10, 0, &branchNum, sizeof branchNum, NULL); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - for (i=0; i<numAccountTups; i++) { - accountNum = i; - branchNum = i/AccountsPerBranch; - rc = SQLExecute(hstmt); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "Error executing statement", - __FILE__, __LINE__); - } - status_msg0("Commit...\n"); - rc = SQLTransact(henv, hdbc, SQL_COMMIT); - status_msg0("Commit done...\n"); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - "committing transaction", - __FILE__, __LINE__); - - /* compile SQL statements of transaction */ - - status_msg0("Compiling statements of transaction...\n"); - for (i=0; i<NumXactStmts; i++) { -#ifndef NDB - rc = SQLAllocStmt(hdbc, &txstmt[i]); - handle_errors(hdbc, NULL, rc, ABORT_DISCONNECT_EXIT, - "allocating a statement handle", - __FILE__, __LINE__); -#else - rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &txstmt[i]); - handle_errors(hdbc, NULL, rc, ABORT_DISCONNECT_EXIT, - "allocating a statement handle", - __FILE__, __LINE__); - -#endif - - rc = SQLPrepare(txstmt[i], (SQLCHAR *) tpcbXactStmt[i], SQL_NTS); - handle_errors(hdbc, txstmt[i], rc, ABORT_DISCONNECT_EXIT, - "preparing statement", - __FILE__, __LINE__); - } - - /* unuse dbs lock */ -#ifndef NDB - if ( DBMSType == DBMS_TIMESTEN ) { - rc = SQLExecDirect(hstmt, (SQLCHAR *)"call ttlocklevel('Row')", SQL_NTS); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "specifying row lock usage", - __FILE__, __LINE__); - } -#endif - - /* commit transaction */ - - rc = SQLTransact(henv, hdbc, SQL_COMMIT); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - "committing transaction", - __FILE__, __LINE__); - - - /* Initialize random seed and timers */ - - srand48(SeedVal); - localLimit = (unsigned short)((1<<16) * 0.85); - - /* Initialize parameter lists for each of the transactions */ - - rc = SQLBindParameter(txstmt[0], 1, SQL_PARAM_INPUT, SQL_C_DOUBLE, - SQL_DOUBLE, 15, 0, &delta, sizeof delta, NULL); - handle_errors(hdbc, txstmt[0], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[0], 2, SQL_PARAM_INPUT, SQL_C_SLONG, - SQL_INTEGER, 10, 0, &accountNum, sizeof accountNum, - NULL); - handle_errors(hdbc, txstmt[0], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[1], 1, SQL_PARAM_INPUT, SQL_C_SLONG, - SQL_INTEGER, 10, 0, &accountNum, sizeof accountNum, - NULL); - handle_errors(hdbc, txstmt[1], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[2], 1, SQL_PARAM_INPUT, SQL_C_DOUBLE, - SQL_DOUBLE, 15, 0, &delta, sizeof delta, NULL); - handle_errors(hdbc, txstmt[2], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[2], 2, SQL_PARAM_INPUT, SQL_C_SLONG, - SQL_INTEGER, 10, 0, &tellerNum, sizeof tellerNum, - NULL); - handle_errors(hdbc, txstmt[2], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[3], 1, SQL_PARAM_INPUT, SQL_C_DOUBLE, - SQL_DOUBLE, 15, 0, &delta, sizeof delta, NULL); - handle_errors(hdbc, txstmt[3], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[3], 2, SQL_PARAM_INPUT, SQL_C_SLONG, - SQL_INTEGER, 10, 0, &branchNum, sizeof branchNum, - NULL); - handle_errors(hdbc, txstmt[3], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[4], 1, SQL_PARAM_INPUT, SQL_C_SLONG, - SQL_INTEGER, 10, 0, &tellerNum, sizeof tellerNum, - NULL); - handle_errors(hdbc, txstmt[4], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[4], 2, SQL_PARAM_INPUT, SQL_C_SLONG, - SQL_INTEGER, 10, 0, &branchNum, sizeof branchNum, - NULL); - handle_errors(hdbc, txstmt[4], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[4], 3, SQL_PARAM_INPUT, SQL_C_SLONG, - SQL_INTEGER, 10, 0, &accountNum, sizeof accountNum, - NULL); - handle_errors(hdbc, txstmt[4], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[4], 4, SQL_PARAM_INPUT, SQL_C_DOUBLE, - SQL_DOUBLE, 15, 0, &delta, sizeof delta, NULL); - handle_errors(hdbc, txstmt[4], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - rc = SQLBindParameter(txstmt[4], 5, SQL_PARAM_INPUT, SQL_C_SLONG, - SQL_INTEGER, 10, 0, &timeStamp, sizeof timeStamp, - NULL); - handle_errors(hdbc, txstmt[4], rc, ABORT_DISCONNECT_EXIT, - "binding parameter", - __FILE__, __LINE__); - - /* Execute transaction loop. - * Do it twice, once briefly as a warm-up. */ - - - - for (warmup = 1; warmup >= 0; warmup--) { - - int max_i = (warmup ? numXacts/10 : numXacts); - - /* Execute tpcb transaction max_i times.*/ - - if (warmup) { - status_msg1("\nWarming up with %d tpcb transactions...\n", max_i); - } - else { - status_msg1("Executing and timing %d tpcb transactions...\n", max_i); - } - - ttGetWallClockTime(&startT); - ttGetThreadTimes(&startRes); - - for (i = 0; i < max_i; i++) { - - lrand = lrand48(); - srands = (unsigned short *)(&lrand); - if (lp64) srands += 2; /* skip high half -- all zero */ - - /* randomly choose a teller */ - - tellerNum = srands[0] % numTellerTups; - - /* compute branch */ - - branchNum = (tellerNum / TellersPerBranch); - - /* randomly choose an account */ - - if (srands[1] < localLimit || numBranchTups == 1) { - - /* choose account local to selected branch */ - - accountNum = branchNum * AccountsPerBranch + - (lrand48() % AccountsPerBranch); - - ++numLocalXacts; - - } - else { - /* choose account not local to selected branch */ - - /* first select account in range [0,numNonLocalAccountTups) */ - - accountNum = lrand48() % numNonLocalAccountTups; - - /* if branch number of selected account is at least as big - * as local branch number, then increment account number - * by AccountsPerBranch to skip over local accounts - */ - - if ((accountNum/AccountsPerBranch) >= branchNum) - accountNum += AccountsPerBranch; - - ++numRemoteXacts; - } - - /* select delta amount, -999,999 to +999,999 */ - - delta = ((lrand48() % 1999999) - 999999); - - - /* begin timing the "residence time" */ - - ttGetWallClockTime(rtStart[i]); - - for ( j = 0; j < NumXactStmts - 2; j++) { - rc = SQLExecute(txstmt[j]); - handle_errors(hdbc, txstmt[j], rc, ABORT_DISCONNECT_EXIT, - "Error executing statement1", - __FILE__, __LINE__); - - /* Close the handle after the SELECT statement - * (txstmt[1]) for non TimesTen DBMS' */ - - if ((DBMSType != DBMS_TIMESTEN) && (j == 1)) { - SQLFreeStmt(txstmt[1], SQL_CLOSE); - } - - - } - - /* note that time must be taken within the */ - timeStamp = time(NULL); - - rc = SQLExecute(txstmt[NumXactStmts - 1]); - handle_errors(hdbc, txstmt[NumXactStmts - 1], rc, - ABORT_DISCONNECT_EXIT, "Error executing statement2", - __FILE__, __LINE__); - - rc = SQLTransact(henv, hdbc, SQL_COMMIT); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - "Error committing transaction", - __FILE__, __LINE__); - - ttGetWallClockTime(rtEnd[i]); - - } /* end fortransaction loop */ - - - - - ttGetThreadTimes(&endRes); - ttGetWallClockTime(&endT); - ttCalcElapsedThreadTimes(&startRes, &endRes, &kernel, &user); - ttCalcElapsedWallClockTime(&startT, &endT, &real); - - if (warmup) { - if (!tabFlag) { - if (verbose) { - if (fThreadTime) { - out_msg0(" time user system\n"); - - out_msg3("Warmup time (sec): %12.3f %12.3f %12.3f\n\n", - real/1000.0, user, kernel); - } else { - out_msg1("Warmup time (sec): %12.3f\n\n", real/1000.0); - } - } - } else { - if (verbose) { - if (fThreadTime) { - out_msg0("\ttime\tuser\tsystem\n"); - - out_msg3("Warmup time (sec):\t%12.3f\t%12.3f\t%12.3f\n", - real/1000.0, user, kernel); - } else { - out_msg1("Warmup time (sec):\t%12.3f\n", real/1000.0); - } - } - } - } - } - - status_msg0("\nExecution completed...\n"); - - /* Compute and report timing statistics */ - - maxTime = 0.0; - totTime = 0.0; - - for (i = 0; i < numXacts; i++) { - ttCalcElapsedWallClockTime(rtStart[i], rtEnd[i], resTime[i]); - totTime += *(resTime[i]); - - if (*(resTime[i]) > maxTime) maxTime = *(resTime[i]); - } - - if (!tabFlag) { - if (verbose) { - if (fThreadTime) { - out_msg0(" time user system\n"); - out_msg3("Total time (sec): %12.3f %12.3f %12.3f\n", - real/1000.0, user, kernel); - } else { - out_msg1("Total time (sec): %12.3f\n", real/1000.0); - } - } - - if (verbose) - out_msg1("\nAverage transaction time (msec):%12.3f\n", - totTime/numXacts); - if (verbose) - out_msg1("Maximum transaction time (msec):%12.3f\n", maxTime); - if (verbose) - out_msg1("\nLocal transactions: %7" PTRINT_FMT "\n", numLocalXacts); - if (verbose) - out_msg1("Remote transactions: %7" PTRINT_FMT "\n", numRemoteXacts); - - } else { - if (verbose) { - if (fThreadTime) { - out_msg0("\ttime\tuser\tsystem\n"); - out_msg3("Total time (sec):\t%12.3f\t%12.3f\t%12.3f\n", - real/1000.0, user, kernel); - } else { - out_msg1("Total time (sec):\t%12.3f\n", real/1000.0); - } - } - - if (verbose) - out_msg1("\nAverage transaction time (msec):\t%12.3f\n", - totTime/numXacts); - if (verbose) - out_msg1("Maximum transaction time (msec):\t%12.3f\n", maxTime); - if (verbose) - out_msg1("Local transactions:\t%7" PTRINT_FMT "\n", numLocalXacts); - - if (verbose) - out_msg1("Remote transactions:\t%7" PTRINT_FMT "\n", numRemoteXacts); - - - - } - - /* If the statfile option is selected, print each transaction's time */ - - if (printXactTimes) { - FILE * fp; - if ( (fp = fopen (statFile, "w")) == NULL ) { - err_msg1("Unable to open stat file %s for writing\n\n", statFile); - } else { - for (int i = 0; i < numXacts; i++) - fprintf(fp,"%6d: %12.3f\n", i, *(resTime[i])); - fclose(fp); - } - } - - /* Disconnect and return */ - - rc = SQLFreeStmt(hstmt, SQL_DROP); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "dropping the statement handle", - __FILE__, __LINE__); - - for (int i=0; i<NumXactStmts; i++) { - rc = SQLFreeStmt(txstmt[i], SQL_DROP); - handle_errors(hdbc, hstmt, rc, ABORT_DISCONNECT_EXIT, - "dropping the statement handle", - __FILE__, __LINE__); - } - - if (verbose >= VERBOSE_DFLT) - status_msg0("Disconnecting from the data source...\n"); - - rc = SQLDisconnect(hdbc); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - "disconnecting", - __FILE__, __LINE__); - - rc = SQLFreeConnect(hdbc); - handle_errors(hdbc, NULL, rc, ERROR_EXIT, - "freeing connection handle", - __FILE__, __LINE__); - - rc = SQLFreeEnv(henv); - handle_errors(NULL, NULL, rc, ERROR_EXIT, - "freeing environment handle", - __FILE__, __LINE__); - - app_exit(0); - return 0; -} - - - - - -/* Emacs variable settings */ -/* Local Variables: */ -/* tab-width:8 */ -/* indent-tabs-mode:nil */ -/* c-basic-offset:2 */ -/* End: */ - - - diff --git a/ndb/test/odbc/tpcb/ttTime.c b/ndb/test/odbc/tpcb/ttTime.c deleted file mode 100644 index 8f10b0c6b91..00000000000 --- a/ndb/test/odbc/tpcb/ttTime.c +++ /dev/null @@ -1,366 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; 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 */ - -static const volatile char cvsid[] = "$Id: ttTime.c,v 1.1 2003/09/23 12:43:46 johan Exp $"; -/* - * $Revision: 1.1 $ - * (c) Copyright 1996-2003, TimesTen, Inc. - * All rights reserved. - * - */ - - -/* Contains functions for performing elapsed-time calculations - in a portable manner */ - -#include "ttTime.h" - -#ifdef WIN32 - -#include <stdio.h> -#include <mapiutil.h> - -/*------------*/ -/* NT VERSION */ -/*------------*/ - -/********************************************************************* - * - * FUNCTION: ttGetThreadTimes - * - * DESCRIPTION: This function sets the supplied parameter's - * user and kernel time for the current thread. - * - * PARAMETERS: ttThreadTimes* timesP thread time structure - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttGetThreadTimes(ttThreadTimes* timesP) -{ - BOOL rc; - HANDLE curThread; - FILETIME creationTime; - FILETIME exitTime; - FILETIME kTime; - FILETIME uTime; - - memset (&kTime, 0, sizeof (FILETIME)); - memset (&uTime, 0, sizeof (FILETIME)); - - curThread = GetCurrentThread(); - rc = GetThreadTimes(curThread, - &creationTime, - &exitTime, - &kTime, - &uTime); - - timesP->kernelTime = kTime; - timesP->userTime = uTime; - -} - -/********************************************************************* - * - * FUNCTION: ttCalcElapsedThreadTimes - * - * DESCRIPTION: This function calculates the user and kernel - * time deltas. - * - * PARAMETERS: ttThreadTimes* beforeP beginning timestamp (IN) - * ttThreadTimes* afterP ending timestamp (IN) - * double* kernelDeltaP kernel time delta (OUT) - * double* userDeltaP user time delta (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttCalcElapsedThreadTimes(ttThreadTimes* beforeP, - ttThreadTimes* afterP, - double* kernelDeltaP, - double* userDeltaP) -{ - static const double secPerHi = (double) 4.294967296; /* 2**32 * 10**-9 */ - FILETIME *before, *after; - - before = &beforeP->kernelTime; - after = &afterP->kernelTime; - *kernelDeltaP = (double) ((after->dwHighDateTime - before->dwHighDateTime) * secPerHi - + (after->dwLowDateTime - before->dwLowDateTime) * 100e-9); - before = &beforeP->userTime; - after = &afterP->userTime; - *userDeltaP = (double) ((after->dwHighDateTime - before->dwHighDateTime) * secPerHi - + (after->dwLowDateTime - before->dwLowDateTime) * 100e-9); -} - -/********************************************************************* - * - * FUNCTION: ttGetWallClockTime - * - * DESCRIPTION: This function gets the current wall-clock time. - * - * PARAMETERS: ttWallClockTime* timeP tms time structure (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttGetWallClockTime(ttWallClockTime* timeP) -{ - LARGE_INTEGER frequency; - if ( QueryPerformanceFrequency(&frequency) ) { - QueryPerformanceCounter(&(timeP->time64)); - } - else { - _ftime(&(timeP->notSoLargeTime)); - } -} - -/********************************************************************* - * - * FUNCTION: ttCalcElapsedWallClockTime - * - * DESCRIPTION: This function calculates the elapsed wall-clock - * time in msec. - * - * PARAMETERS: ttWallClockTime* beforeP starting timestamp - * ttWallClockTime* afterP ending timestamp - * double* nmillisecondsP elapsed time (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisecondsP) -{ - LARGE_INTEGER frequency; - - if ( QueryPerformanceFrequency(&frequency) ) { - *nmillisecondsP = 1000 * ((double) (afterP->time64.QuadPart - - beforeP->time64.QuadPart)) - / frequency.QuadPart; - - } - else { - double start; - double end; - - start = (double) beforeP->notSoLargeTime.time * 1000. + - (double) beforeP->notSoLargeTime.millitm; - end = (double) afterP->notSoLargeTime.time * 1000. + - (double) afterP->notSoLargeTime.millitm; - - *nmillisecondsP = (double) (end - start); - } -} - -#elif defined (RTSYS_VXWORKS) - -/*-----------------*/ -/* VxWorks VERSION */ -/*-----------------*/ - -/* - * The TimeBase registers have a period of 60ns, i.e. - * 0.00000006 or (6e-8) seconds. - */ -#define TIMER_MSEC_PER_CYC (6e-5) - -void -ttGetWallClockTime(ttWallClockTime* timeP) -{ - vxTimeBaseGet(&timeP->sep.upper32, &timeP->sep.lower32); -} - - -void -ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisecondsP) -{ - *nmillisecondsP = (double)(afterP->val - beforeP->val) * TIMER_MSEC_PER_CYC; -} - - -#else - -/*--------------*/ -/* UNIX VERSION */ -/*--------------*/ - -#include <unistd.h> - -/********************************************************************* - * - * FUNCTION: ttGetThreadTimes - * - * DESCRIPTION: This function sets the supplied parameter's - * tms structure. - * - * PARAMETERS: ttThreadTimes* timesP tms time structure - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -#ifdef SB_P_OS_CHORUS -void ttGetThreadTimes(ttThreadTimes* timesP) -{ - KnCap actorCap; - - if (acap (agetId(), &actorCap) == -1) { - timesP->ins.tmSec = 0; - timesP->ins.tmNSec = 0; - timesP->ext.tmSec = 0; - timesP->ext.tmNSec = 0; - } - else { - (void) threadTimes (&actorCap, K_ALLACTORTHREADS, - ×P->ins, ×P->ext); - } -} -#else -void ttGetThreadTimes(ttThreadTimes* timesP) -{ - (void) times(timesP); -} -#endif - -/********************************************************************* - * - * FUNCTION: ttCalcElapsedThreadTimes - * - * DESCRIPTION: This function calculates the user and kernel - * time deltas. - * - * PARAMETERS: ttThreadTimes* beforeP beginning timestamp (IN) - * ttThreadTimes* afterP ending timestamp (IN) - * double* kernelDeltaP kernel time delta (OUT) - * double* userDeltaP user time delta (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -#ifdef SB_P_OS_CHORUS -void -ttCalcElapsedThreadTimes(ttThreadTimes* beforeP, - ttThreadTimes* afterP, - double* kernelDeltaP, - double* userDeltaP) -{ - double kernelBefore; - double kernelAfter; - double userBefore; - double userAfter; - - kernelBefore = (beforeP->ext.tmSec) + (beforeP->ext.tmNSec / 1e9); - kernelAfter = (afterP->ext.tmSec) + (afterP->ext.tmNSec / 1e9); - *kernelDeltaP = kernelAfter - kernelBefore; - - userBefore = (beforeP->ins.tmSec) + (beforeP->ins.tmNSec / 1e9); - userAfter = (afterP->ins.tmSec) + (afterP->ins.tmNSec / 1e9); - *userDeltaP = userAfter - userBefore; - -} -#else -void -ttCalcElapsedThreadTimes(ttThreadTimes* beforeP, - ttThreadTimes* afterP, - double* kernelDeltaP, - double* userDeltaP) -{ - double ticks = (double)sysconf(_SC_CLK_TCK); - - *kernelDeltaP = (afterP->tms_stime - beforeP->tms_stime) / ticks; - *userDeltaP = (afterP->tms_utime - beforeP->tms_utime) / ticks; -} -#endif - -/********************************************************************* - * - * FUNCTION: ttGetWallClockTime - * - * DESCRIPTION: This function gets the current wall-clock time. - * - * PARAMETERS: ttWallClockTime* timeP tms time structure (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttGetWallClockTime(ttWallClockTime* timeP) -{ - gettimeofday(timeP, NULL); -} - -/********************************************************************* - * - * FUNCTION: ttCalcElapsedWallClockTime - * - * DESCRIPTION: This function calculates the elapsed wall-clock - * time is msec. - * - * PARAMETERS: ttWallClockTime* beforeP starting timestamp - * ttWallClockTime* afterP ending timestamp - * double* nmillisecondsP elapsed time (OUT) - * - * RETURNS: void - * - * NOTES: NONE - * - *********************************************************************/ - -void -ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisP) -{ - *nmillisP = (afterP->tv_sec - beforeP->tv_sec)*1000.0 + - (afterP->tv_usec - beforeP->tv_usec)/1000.0; -} - -#endif - -/* Emacs variable settings */ -/* Local Variables: */ -/* tab-width:8 */ -/* indent-tabs-mode:nil */ -/* c-basic-offset:2 */ -/* End: */ diff --git a/ndb/test/odbc/tpcb/ttTime.h b/ndb/test/odbc/tpcb/ttTime.h deleted file mode 100644 index f78b71667fe..00000000000 --- a/ndb/test/odbc/tpcb/ttTime.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; 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 */ - -/* - * $Revision: 1.1 $ - * (c) Copyright 1996-2003, TimesTen, Inc. - * All rights reserved. - * - */ - -#ifndef __TT_TIME -#define __TT_TIME - - -#ifdef WIN32 - -#include <windows.h> -#include <sys/types.h> -#include <sys/timeb.h> - -typedef struct { - FILETIME kernelTime; - FILETIME userTime; -} ttThreadTimes; - - -typedef union { - LARGE_INTEGER time64; - struct _timeb notSoLargeTime; -} ttWallClockTime; - -#elif defined(RTSYS_VXWORKS) - -#define srand48(x) sb_srand48((x)) -#define drand48() sb_drand48() - -#ifdef SB_P_OS_VXPPC -/* For little-endian switch the lower, upper fields */ -typedef union { - struct { - unsigned int upper32; - unsigned int lower32; - } sep; - long long val; -} ttWallClockTime; - -/* - * This is a VxWorks private function to read the PPC's 64 bit Time Base - * Register. This is the assembler dump of this function. - 001126e4 7cad42e6 mftb r5, TBU - 001126e8 7ccc42e6 mftb r6, TBL - 001126ec 7ced42e6 mftb r7, TBU - 001126f0 7c053800 cmp crf0, 0, r5, r7 - 001126f4 4082fff0 bc 0x4, 0x2, vxTimeBaseGet - 001126f8 90a30000 stw r5, 0x0(r3) - 001126fc 90c40000 stw r6, 0x0(r4) - 00112700 4e800020 blr - * This is a fine grained timer with a period of 60ns. - */ -void vxTimeBaseGet(unsigned int* pUpper32, unsigned int* pLower32); -#endif /* SB_P_OS_VXPPC */ - -#elif defined(SB_P_OS_CHORUS) -#include <sys/types.h> -#include <sys/times.h> -#include <sys/time.h> - -#include <vtimer/chVtimer.h> - -struct chrTimes { - KnTimeVal ins; - KnTimeVal ext; -}; -typedef struct chrTimes ttThreadTimes; - -typedef struct timeval ttWallClockTime; - -#else -/* UNIX version */ - -#include <sys/times.h> -#include <sys/time.h> - -typedef struct tms ttThreadTimes; - -typedef struct timeval ttWallClockTime; - -#endif /* NT, VxWorks, Chorus, Unix */ - - -#ifndef RTSYS_VXWORKS -void ttGetThreadTimes(ttThreadTimes* timesP); -void ttCalcElapsedThreadTimes(ttThreadTimes* beforeP, ttThreadTimes* afterP, - double* kernelDeltaP, double* userDeltaP); -#endif /* ! VXWORKS */ -void ttGetWallClockTime(ttWallClockTime* timeP); -void ttCalcElapsedWallClockTime(ttWallClockTime* beforeP, - ttWallClockTime* afterP, - double* nmillisecondsP); - - - - - -#endif /* __TT_TIME */ - -/* Emacs variable settings */ -/* Local Variables: */ -/* tab-width:8 */ -/* indent-tabs-mode:nil */ -/* c-basic-offset:2 */ -/* End: */ diff --git a/ndb/test/run-test/Makefile.am b/ndb/test/run-test/Makefile.am index 3bf2edde47a..6b3ba0bff09 100644 --- a/ndb/test/run-test/Makefile.am +++ b/ndb/test/run-test/Makefile.am @@ -10,9 +10,9 @@ test_DATA=daily-basic-tests.txt daily-devel-tests.txt test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \ atrt-clear-result.sh make-config.sh make-index.sh make-html-reports.sh -atrt_SOURCES = main.cpp -INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmclient -LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CpcClient.o \ +atrt_SOURCES = main.cpp run-test.hpp +INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include +LDADD_LOC = $(top_builddir)/ndb/test/src/libNDBT.a \ $(top_builddir)/ndb/src/libndbclient.la \ $(top_builddir)/dbug/libdbug.a \ $(top_builddir)/mysys/libmysys.a \ @@ -21,5 +21,9 @@ LDADD_LOC = $(top_builddir)/ndb/src/mgmclient/CpcClient.o \ wrappersdir=$(prefix)/bin wrappers_SCRIPTS=atrt-testBackup atrt-mysql-test-run +EXTRA_DIST = $(test_DATA) $(test_SCRIPTS) $(wrappers_SCRIPTS) README.ATRT + # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: diff --git a/ndb/test/run-test/Makefile_old b/ndb/test/run-test/Makefile_old deleted file mode 100644 index 6b4689b2dbb..00000000000 --- a/ndb/test/run-test/Makefile_old +++ /dev/null @@ -1,22 +0,0 @@ -include .defs.mk - -TYPE := util - -BIN_TARGET := atrt -BIN_TARGET_LIBS := mgmapi - -SOURCES = main.cpp -SCRIPTS = atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \ - atrt-clear-result.sh make-config.sh - -OBJECTS_LOC = $(call fixpath,$(NDB_TOP)/src/mgmclient/CpcClient.o) - -CFLAGS_main.cpp := -I$(call fixpath,$(NDB_TOP)/src/mgmclient) -CCFLAGS_LOC += -I$(call fixpath,$(NDB_TOP)/include/mgmapi) - -include $(NDB_TOP)/Epilogue.mk - -_bins:: - -rm -f $(SCRIPTS:%=$(NDB_TOP)/bin/%) - cp $(SCRIPTS) $(NDB_TOP)/bin - diff --git a/ndb/test/run-test/atrt-mysql-test-run b/ndb/test/run-test/atrt-mysql-test-run index dd7b709bd06..2ebc11b0070 100755 --- a/ndb/test/run-test/atrt-mysql-test-run +++ b/ndb/test/run-test/atrt-mysql-test-run @@ -5,8 +5,8 @@ p=`pwd` cd $MYSQL_BASE_DIR/mysql-test ./mysql-test-run --with-ndbcluster --ndb-connectstring=$NDB_CONNECTSTRING $* | tee $p/output.txt -f=`grep -c fail $p/output.txt` -o=`grep -c pass $p/output.txt` +f=`grep -c '\[ fail \]' $p/output.txt` +o=`grep -c '\[ pass \]' $p/output.txt` if [ $o -gt 0 -a $f -eq 0 ] then diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index 8d7e8a06c72..453fe1ad7ae 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -1,3 +1,11 @@ +max-time: 3600 +cmd: atrt-mysql-test-run +args: --force + +max-time: 600 +cmd: atrt-testBackup +args: -n BackupOne T1 T6 T3 I3 + # BASIC FUNCTIONALITY max-time: 500 cmd: testBasic @@ -222,6 +230,18 @@ max-time: 500 cmd: testScan args: -n ScanRead488 -l 10 T6 +max-time: 500 +cmd: testScan +args: -n ScanRead488O -l 10 T6 + +max-time: 1000 +cmd: testScan +args: -n ScanRead488_Mixed -l 10 T6 + +max-time: 500 +cmd: testScan +args: -n ScanRead488Timeout -l 10 T6 + max-time: 600 cmd: testScan args: -n ScanRead40 -l 100 T2 @@ -358,6 +378,10 @@ max-time: 500 cmd: testScan args: -n ScanRestart T1 +max-time: 500 +cmd: testScan +args: -l 100 -n Scan-bug8262 T7 + # OLD FLEX max-time: 500 cmd: flexBench @@ -474,493 +498,13 @@ args: -n UpdateWithoutValues T6 #cmd: testInterpreter #args: T1 # -max-time: 1500 -cmd: testOperations -args: -n ReadRead - -max-time: 1500 -cmd: testOperations -args: -n ReadReadEx - -max-time: 1500 -cmd: testOperations -args: -n ReadInsert - -max-time: 1500 -cmd: testOperations -args: -n ReadUpdate - -max-time: 1500 -cmd: testOperations -args: -n ReadDelete - -max-time: 1500 -cmd: testOperations -args: -n FReadRead - -max-time: 1500 -cmd: testOperations -args: -n FReadReadEx - -max-time: 1500 -cmd: testOperations -args: -n FReadInsert - -max-time: 1500 -cmd: testOperations -args: -n FReadUpdate - -max-time: 1500 -cmd: testOperations -args: -n FReadDelete - -max-time: 1500 -cmd: testOperations -args: -n ReadExRead - -max-time: 1500 -cmd: testOperations -args: -n ReadExReadEx - -max-time: 1500 -cmd: testOperations -args: -n ReadExInsert - -max-time: 1500 -cmd: testOperations -args: -n ReadExUpdate - -max-time: 1500 -cmd: testOperations -args: -n ReadExDelete - -max-time: 1500 -cmd: testOperations -args: -n InsertRead - -max-time: 1500 -cmd: testOperations -args: -n InsertReadEx - -max-time: 1500 -cmd: testOperations -args: -n InsertInsert - -max-time: 1500 -cmd: testOperations -args: -n InsertUpdate - -max-time: 1500 -cmd: testOperations -args: -n InsertDelete - -max-time: 1500 -cmd: testOperations -args: -n UpdateRead - -max-time: 1500 -cmd: testOperations -args: -n UpdateReadEx - -max-time: 1500 -cmd: testOperations -args: -n UpdateInsert - -max-time: 1500 -cmd: testOperations -args: -n UpdateUpdate - -max-time: 1500 -cmd: testOperations -args: -n UpdateDelete - -max-time: 1500 -cmd: testOperations -args: -n DeleteRead - -max-time: 1500 -cmd: testOperations -args: -n DeleteReadEx - -max-time: 1500 -cmd: testOperations -args: -n DeleteInsert - -max-time: 1500 -cmd: testOperations -args: -n DeleteUpdate - -max-time: 1500 -cmd: testOperations -args: -n DeleteDelete - -max-time: 1500 -cmd: testOperations -args: -n ReadSimpleRead - -max-time: 1500 -cmd: testOperations -args: -n ReadDirtyRead - -max-time: 1500 -cmd: testOperations -args: -n FReadSimpleRead - -max-time: 1500 -cmd: testOperations -args: -n FReadDirtyRead - -max-time: 1500 -cmd: testOperations -args: -n ReadExSimpleRead - -max-time: 1500 -cmd: testOperations -args: -n ReadExDirtyRead - -max-time: 1500 -cmd: testOperations -args: -n InsertSimpleRead - -max-time: 1500 -cmd: testOperations -args: -n InsertDirtyRead - -max-time: 1500 -cmd: testOperations -args: -n UpdateSimpleRead - -max-time: 1500 -cmd: testOperations -args: -n UpdateDirtyRead - -max-time: 1500 -cmd: testOperations -args: -n DeleteSimpleRead - -max-time: 1500 +max-time: 150000 cmd: testOperations -args: -n DeleteDirtyRead - -max-time: 1500 -cmd: testTransactions -args: -n ReadRead - -max-time: 1500 -cmd: testTransactions -args: -n ReadReadEx - -max-time: 1500 -cmd: testTransactions -args: -n ReadInsert - -max-time: 1500 -cmd: testTransactions -args: -n ReadUpdate - -max-time: 1500 -cmd: testTransactions -args: -n ReadDelete - -max-time: 1500 -cmd: testTransactions -args: -n ReadExRead - -max-time: 1500 -cmd: testTransactions -args: -n ReadExReadEx - -max-time: 1500 -cmd: testTransactions -args: -n ReadExInsert - -max-time: 1500 -cmd: testTransactions -args: -n ReadExUpdate - -max-time: 1500 -cmd: testTransactions -args: -n ReadExDelete - -max-time: 1500 -cmd: testTransactions -args: -n InsertRead - -max-time: 1500 -cmd: testTransactions -args: -n InsertReadEx - -max-time: 1500 -cmd: testTransactions -args: -n InsertInsert - -max-time: 1500 -cmd: testTransactions -args: -n InsertUpdate - -max-time: 1500 -cmd: testTransactions -args: -n InsertDelete - -max-time: 1500 -cmd: testTransactions -args: -n UpdateRead - -max-time: 1500 -cmd: testTransactions -args: -n UpdateReadEx - -max-time: 1500 -cmd: testTransactions -args: -n UpdateInsert - -max-time: 1500 -cmd: testTransactions -args: -n UpdateUpdate - -max-time: 1500 -cmd: testTransactions -args: -n UpdateDelete - -max-time: 1500 -cmd: testTransactions -args: -n DeleteRead - -max-time: 1500 -cmd: testTransactions -args: -n DeleteReadEx - -max-time: 1500 -cmd: testTransactions -args: -n DeleteInsert - -max-time: 1500 -cmd: testTransactions -args: -n DeleteUpdate - -max-time: 1500 -cmd: testTransactions -args: -n DeleteDelete - -max-time: 1500 -cmd: testTransactions -args: -n ReadSimpleRead - -max-time: 1500 -cmd: testTransactions -args: -n ReadDirtyRead - -max-time: 1500 -cmd: testTransactions -args: -n ReadExSimpleRead - -max-time: 1500 -cmd: testTransactions -args: -n ReadExDirtyRead - -max-time: 1500 -cmd: testTransactions -args: -n InsertSimpleRead - -max-time: 1500 -cmd: testTransactions -args: -n InsertDirtyRead - -max-time: 1500 -cmd: testTransactions -args: -n UpdateSimpleRead - -max-time: 1500 -cmd: testTransactions -args: -n UpdateDirtyRead - -max-time: 1500 -cmd: testTransactions -args: -n DeleteSimpleRead - -max-time: 1500 -cmd: testTransactions -args: -n DeleteDirtyRead - -max-time: 1500 -cmd: testTransactions -args: -n ReadScan - -max-time: 1500 -cmd: testTransactions -args: -n ReadScanHl - -max-time: 1500 -cmd: testTransactions -args: -n ReadScanEx - -max-time: 1500 -cmd: testTransactions -args: -n ScanRead - -max-time: 1500 -cmd: testTransactions -args: -n ScanReadEx - -max-time: 1500 -cmd: testTransactions -args: -n ScanSimpleRead - -max-time: 1500 -cmd: testTransactions -args: -n ScanDirtyRead - -max-time: 1500 -cmd: testTransactions -args: -n ScanInsert - -max-time: 1500 -cmd: testTransactions -args: -n ScanUpdate - -max-time: 1500 -cmd: testTransactions -args: -n ScanDelete - -max-time: 1500 -cmd: testTransactions -args: -n ScanScan - -max-time: 1500 -cmd: testTransactions -args: -n ScanScanHl - -max-time: 1500 -cmd: testTransactions -args: -n ScanScanEx - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlRead - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlReadEx - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlSimpleRead - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlDirtyRead - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlInsert - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlUpdate - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlDelete - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlScan - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlScanHl - -max-time: 1500 -cmd: testTransactions -args: -n ScanHlScanEx - -max-time: 1500 -cmd: testTransactions -args: -n ScanExRead - -max-time: 1500 -cmd: testTransactions -args: -n ScanExReadEx - -max-time: 1500 -cmd: testTransactions -args: -n ScanExSimpleRead - -max-time: 1500 -cmd: testTransactions -args: -n ScanExDirtyRead - -max-time: 1500 -cmd: testTransactions -args: -n ScanExInsert - -max-time: 1500 -cmd: testTransactions -args: -n ScanExUpdate - -max-time: 1500 -cmd: testTransactions -args: -n ScanExDelete - -max-time: 1500 -cmd: testTransactions -args: -n ScanExScan - -max-time: 1500 -cmd: testTransactions -args: -n ScanExScanHl - -max-time: 1500 -cmd: testTransactions -args: -n ScanExScanEx - -max-time: 1500 -cmd: testTransactions -args: -n ReadExScan - -max-time: 1500 -cmd: testTransactions -args: -n ReadExScanHl - -max-time: 1500 -cmd: testTransactions -args: -n ReadExScanEx - -max-time: 1500 -cmd: testTransactions -args: -n InsertScan - -max-time: 1500 -cmd: testTransactions -args: -n InsertScanHl - -max-time: 1500 -cmd: testTransactions -args: -n InsertScanEx - -max-time: 1500 -cmd: testTransactions -args: -n UpdateScan - -max-time: 1500 -cmd: testTransactions -args: -n UpdateScanHl - -max-time: 1500 -cmd: testTransactions -args: -n UpdateScanEx - -max-time: 1500 -cmd: testTransactions -args: -n DeleteScan - -max-time: 1500 -cmd: testTransactions -args: -n DeleteScanHl +args: -max-time: 1500 +max-time: 150000 cmd: testTransactions -args: -n DeleteScanEx +args: max-time: 1500 cmd: testRestartGci diff --git a/ndb/test/run-test/daily-devel-tests.txt b/ndb/test/run-test/daily-devel-tests.txt index 5c0b2821d85..2cdd39ffa4c 100644 --- a/ndb/test/run-test/daily-devel-tests.txt +++ b/ndb/test/run-test/daily-devel-tests.txt @@ -1,7 +1,3 @@ -max-time: 2500 -cmd: atrt-mysql-test-run -args: --do-test=ndb --force - # # INDEX # @@ -22,10 +18,6 @@ args: -n CreateLoadDrop T1 T10 # # BACKUP # -max-time: 600 -cmd: atrt-testBackup -args: -n BackupOne T1 T6 T3 I3 - max-time: 1000 cmd: atrt-testBackup args: -n BackupBank T6 @@ -212,3 +204,32 @@ max-time: 2500 cmd: test_event args: -n BasicEventOperation T1 T6 +max-time: 300 +cmd: DbCreate +args: + +max-time: 180 +cmd: DbAsyncGenerator +args: -time 60 -p 1 +type: bench + +max-time: 180 +cmd: DbAsyncGenerator +args: -time 60 -p 25 +type: bench + +max-time: 180 +cmd: DbAsyncGenerator +args: -time 60 -p 100 +type: bench + +max-time: 180 +cmd: DbAsyncGenerator +args: -time 60 -p 200 +type: bench + +max-time: 180 +cmd: DbAsyncGenerator +args: -time 60 -p 1 -proc 25 +type: bench + diff --git a/ndb/test/run-test/example.conf b/ndb/test/run-test/example.conf new file mode 100644 index 00000000000..1e152da332d --- /dev/null +++ b/ndb/test/run-test/example.conf @@ -0,0 +1,10 @@ +target=pc-linux-i686 +base_dir=/ndb +src_clone_base=mysqldev@bk-internal.mysql.com:/home/bk/mysql +run_dir=/space/autotest +build_dir=/ndb +hosts="ndb01 ndb02 ndb03 ndb04 ndb05 ndb06 ndb07 ndb08 ndb09 ndb10 ndb11 ndb12" +result_host="ndb.mysql.com" +result_path="public_html" +configure='CC=gcc CXX=gcc CFLAGS="-Wall -pedantic -Wno-long-long" CXXFLAGS="-Wall -pedantic -Wno-long-long" ./configure --with-ndbcluster --with-ndb-test --with-ndbcc-flags="-g -DERROR_INSERT"' + diff --git a/ndb/test/run-test/main.cpp b/ndb/test/run-test/main.cpp index 22799a9a1b2..02c2cc862a3 100644 --- a/ndb/test/run-test/main.cpp +++ b/ndb/test/run-test/main.cpp @@ -219,7 +219,7 @@ main(int argc, const char ** argv){ fflush(g_report_file); } - if(g_mode_bench || (g_mode_regression && result)){ + if(test_case.m_report || g_mode_bench || (g_mode_regression && result)){ BaseString tmp; tmp.assfmt("result.%d", test_no); if(rename("result", tmp.c_str()) != 0){ @@ -228,7 +228,7 @@ main(int argc, const char ** argv){ goto end; } } - + if(g_mode_interactive && result){ g_logger.info ("Encountered failed test in interactive mode - terminating"); @@ -275,6 +275,7 @@ parse_args(int argc, const char** argv){ int tmp = Logger::LL_WARNING - g_verbosity; tmp = (tmp < Logger::LL_DEBUG ? Logger::LL_DEBUG : tmp); g_logger.disable(Logger::LL_ALL); + g_logger.enable(Logger::LL_ON); g_logger.enable((Logger::LoggerLevel)tmp, Logger::LL_ALERT); } @@ -459,7 +460,7 @@ setup_config(atrt_config& config){ proc.m_type = atrt_process::NDB_MGM; proc.m_proc.m_name.assfmt("%d-%s", index, "ndb_mgmd"); proc.m_proc.m_path.assign(dir).append("/libexec/ndb_mgmd"); - proc.m_proc.m_args = "--nodaemon -c initconfig.txt"; + proc.m_proc.m_args = "--nodaemon -f config.ini"; proc.m_proc.m_cwd.appfmt("%d.ndb_mgmd", index); connect_string.appfmt("host=%s:%d;", proc.m_hostname.c_str(), proc.m_ndb_mgm_port); @@ -538,15 +539,19 @@ connect_ndb_mgm(atrt_process & proc){ } BaseString tmp = proc.m_hostname; tmp.appfmt(":%d", proc.m_ndb_mgm_port); - time_t start = time(0); - const time_t max_connect_time = 30; - do { - if(ndb_mgm_connect(handle, tmp.c_str()) != -1){ - proc.m_ndb_mgm_handle = handle; - return true; - } - sleep(1); - } while(time(0) < (start + max_connect_time)); + + if (ndb_mgm_set_connectstring(handle,tmp.c_str())) + { + g_logger.critical("Unable to create parse connectstring"); + return false; + } + + if(ndb_mgm_connect(handle, 30, 1, 0) != -1) + { + proc.m_ndb_mgm_handle = handle; + return true; + } + g_logger.critical("Unable to connect to ndb mgm %s", tmp.c_str()); return false; } @@ -903,6 +908,11 @@ read_test_case(FILE * file, atrt_testcase& tc, int& line){ tc.m_max_time = 60000; else tc.m_max_time = atoi(mt); + + if(p.get("type", &mt) && strcmp(mt, "bench") == 0) + tc.m_report= true; + else + tc.m_report= false; return true; } diff --git a/ndb/test/run-test/make-html-reports.sh b/ndb/test/run-test/make-html-reports.sh index 89f13a4b62a..67395ceba47 100755 --- a/ndb/test/run-test/make-html-reports.sh +++ b/ndb/test/run-test/make-html-reports.sh @@ -154,9 +154,12 @@ do ts=`time_spec $time` res_txt="" case $res in - 0) pass; res_txt="PASSED"; res_dir=" ";; + 0) pass; res_txt="PASSED";; *) fail; res_txt="FAILED";; esac + + if [ ! -d "$src_dir/result.$no" ]; then res_dir=" "; fi + total=`expr $total + $time` ( diff --git a/ndb/test/run-test/ndb-autotest.sh b/ndb/test/run-test/ndb-autotest.sh new file mode 100755 index 00000000000..397df97d52f --- /dev/null +++ b/ndb/test/run-test/ndb-autotest.sh @@ -0,0 +1,228 @@ +#!/bin/sh + +save_args=$* +VERSION="ndb-autotest.sh version 1.0" + +DATE=`date '+%Y-%m-%d'` +export DATE + +set -e +ulimit -Sc unlimited + +echo "`date` starting: $*" + +RSYNC_RSH=ssh +export RSYNC_RSH + +do_clone=yes +build=yes +deploy=yes + +clone=5.0-ndb +RUN="daily-basic daily-devel" +conf=autotest.conf + +while [ "$1" ] +do + case "$1" in + --no-clone) do_clone="";; + --no-build) build="";; + --no-deploy) deploy="";; + --clone=*) clone=`echo $1 | sed s/--clone=//`;; + --conf=*) conf=`echo $1 | sed s/--conf=//`;; + --version) echo $VERSION; exit;; + *) RUN=$*;; + esac + shift +done + +if [ -f $conf ] +then + . $conf +else + echo "Can't find config file: $conf" + exit +fi + +env + +LOCK=$HOME/.autotest-lock +src_clone=$src_clone_base-$clone + +if [ -f $LOCK ] +then + echo "Lock file exists: $LOCK" + exit 1 +fi + +echo "$DATE $RUN" > $LOCK +trap "rm -f $LOCK" ERR + +dst_place=${build_dir}/clone-mysql-$clone-$DATE + +if [ "$do_clone" ] +then + rm -rf $dst_place + bk clone $src_clone $dst_place +fi + +if [ "$build" ] +then + cd $dst_place + rm -rf $run_dir/* + aclocal; autoheader; autoconf; automake + (cd innobase; aclocal; autoheader; autoconf; automake) + (cd bdb/dist; sh s_all) + eval $configure --prefix=$run_dir + make + make install +fi + +### +# check script version +# +script=$run_dir/mysql-test/ndb/ndb-autotest.sh +if [ -x $script ] +then + $script --version > /tmp/version.$$ +else + echo $VERSION > /tmp/version.$$ +fi +match=`grep -c "$VERSION" /tmp/version.$$` +rm -f /tmp/version.$$ +if [ $match -eq 0 ] +then + echo "Incorrect script version...restarting" + cp $run_dir/mysql-test/ndb/ndb-autotest.sh /tmp/at.$$.sh + rm -rf $run_dir $dst_place + sh /tmp/at.$$.sh $save_args + exit +fi + +# Check that all interesting files are present +test_dir=$run_dir/mysql-test/ndb +atrt=$test_dir/atrt +html=$test_dir/make-html-reports.sh +PATH=$test_dir:$PATH +export PATH + +filter(){ + neg=$1 + shift + while [ $# -gt 0 ] + do + if [ `grep -c $1 $neg` -eq 0 ] ; then echo $1; fi + shift + done +} + +### +# check ndb_cpcc fail hosts +# +ndb_cpcc $hosts | awk '{ if($1=="Failed"){ print;}}' > /tmp/failed.$DATE +filter /tmp/failed.$DATE $hosts > /tmp/hosts.$DATE +hosts=`cat /tmp/hosts.$DATE` + +if [ "$deploy" ] +then + (cd / && tar cfz /tmp/build.$DATE.tgz $run_dir ) + for i in $hosts + do + ok=0 + scp /tmp/build.$DATE.tgz $i:/tmp/build.$DATE.$$.tgz && \ + ssh $i "rm -rf /space/autotest/*" && \ + ssh $i "cd / && tar xfz /tmp/build.$DATE.$$.tgz" && \ + ssh $i "rm /tmp/build.$DATE.$$.tgz" && ok=1 + if [ $ok -eq 0 ] + then + echo "$i failed during scp/ssh, excluding" + echo $i >> /tmp/failed.$DATE + fi + done +fi +rm -f /tmp/build.$DATE.tgz + +### +# handle scp failed hosts +# +filter /tmp/failed.$DATE $hosts > /tmp/hosts.$DATE +hosts=`cat /tmp/hosts.$DATE` +cat /tmp/failed.$DATE > /tmp/filter_hosts.$$ + +### +# functions for running atrt +# +choose(){ + SRC=$1 + TMP1=/tmp/choose.$$ + TMP2=/tmp/choose.$$.$$ + shift + + cp $SRC $TMP1 + i=1 + while [ $# -gt 0 ] + do + sed -e s,"CHOOSE_host$i",$1,g < $TMP1 > $TMP2 + mv $TMP2 $TMP1 + shift + i=`expr $i + 1` + done + cat $TMP1 + rm -f $TMP1 +} +start(){ + rm -rf report.txt result* log.txt + $atrt -v -v -r -R --log-file=log.txt --testcase-file=$test_dir/$2-tests.txt & + pid=$! + echo $pid > run.pid + wait $pid + rm run.pid + [ -f log.txt ] && mv log.txt $3 + [ -f report.txt ] && mv report.txt $3 + [ "`find . -name 'result*'`" ] && mv result* $3 + cd $3 + sh $html . $1 $DATE + cd .. + p2=`pwd` + cd .. + tar cfz /tmp/res.$$.tgz `basename $p2`/$DATE + scp /tmp/res.$$.tgz $result_host:$result_path + ssh $result_host "cd $result_path && tar xfz res.$$.tgz && rm -f res.$$.tgz" + rm -f /tmp/res.$$.tgz +} + +p=`pwd` +for dir in $RUN +do + echo "Fixing hosts for $dir" + + run_dir=$base_dir/run-$dir-mysql-$clone-$target + res_dir=$base_dir/result-$dir-mysql-$clone-$target/$DATE + + mkdir -p $res_dir + rm -rf $res_dir/* + + count=`grep -c "COMPUTER" $run_dir/1.ndb_mgmd/initconfig.template` + avail_hosts=`filter /tmp/filter_hosts.$$ $hosts` + avail=`echo $avail_hosts | wc -w` + if [ $count -gt $avail ] + then + echo "Not enough hosts" + echo "Needs: $count available: $avail ($avail_hosts)" + break; + fi + + run_hosts=`echo $avail_hosts| awk '{for(i=1;i<='$count';i++)print $i;}'` + choose $run_dir/d.template $run_hosts > $run_dir/d.txt + choose $run_dir/1.ndb_mgmd/initconfig.template $run_hosts > $run_dir/1.ndb_mgmd/config.ini + echo $run_hosts >> /tmp/filter_hosts.$$ + + cd $run_dir + start $dir-mysql-$clone-$target $dir $res_dir & +done +cd $p +rm /tmp/filter_hosts.$$ + +wait + +rm -f $LOCK diff --git a/ndb/test/run-test/run-test.hpp b/ndb/test/run-test/run-test.hpp index 8d00a7b6a55..ff7f916d4ef 100644 --- a/ndb/test/run-test/run-test.hpp +++ b/ndb/test/run-test/run-test.hpp @@ -68,6 +68,7 @@ struct atrt_config { }; struct atrt_testcase { + bool m_report; time_t m_max_time; BaseString m_command; BaseString m_args; diff --git a/ndb/src/mgmclient/CpcClient.cpp b/ndb/test/src/CpcClient.cpp index d407ba65312..1d1b4fcb977 100644 --- a/ndb/src/mgmclient/CpcClient.cpp +++ b/ndb/test/src/CpcClient.cpp @@ -15,9 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> -#include <editline/editline.h> - -#include <netdb.h> #include <NdbOut.hpp> #include <NdbTCP.h> @@ -33,7 +30,7 @@ 0, 0, \ 0, \ (desc), \ - (void *)(value) } + (value) } #define CPC_ARG(name, type, opt, desc) \ { (name), \ @@ -354,17 +351,12 @@ SimpleCpcClient::define_process(Process & p, Properties& reply){ int SimpleCpcClient::list_processes(Vector<Process> &procs, Properties& reply) { - enum Proclist { - Proclist_Start, - Proclist_End, - Proclist_Entry - }; + int start, end, entry; const ParserRow_t list_reply[] = { - CPC_CMD("start processes", Proclist_Start, ""), - - CPC_CMD("end processes", Proclist_End, ""), + CPC_CMD("start processes", &start, ""), + CPC_CMD("end processes", &end, ""), - CPC_CMD("process", Proclist_Entry, ""), + CPC_CMD("process", &entry, ""), CPC_ARG("id", Int, Mandatory, "Id of process."), CPC_ARG("name", String, Mandatory, "Name of process"), CPC_ARG("group", String, Mandatory, "Group of process"), @@ -393,26 +385,29 @@ SimpleCpcClient::list_processes(Vector<Process> &procs, Properties& reply) { bool done = false; while(!done) { const Properties *proc; - enum Proclist p; - cpc_recv(list_reply, &proc, (void **)&p); + void *p; + cpc_recv(list_reply, &proc, &p); - switch(p) { - case Proclist_Start: + if(p == &start) + { /* do nothing */ - break; - case Proclist_End: + } + else if(p == &end) + { done = true; - break; - case Proclist_Entry: + } + else if(p == &entry) + { if(proc != NULL){ Process p; convert(* proc, p); procs.push_back(p); } - break; - default: - /* ignore */ - break; + } + else + { + ndbout_c("internal error: %d", __LINE__); + return -1; } } return 0; diff --git a/ndb/test/src/HugoOperations.cpp b/ndb/test/src/HugoOperations.cpp index e8e2d992345..8e6603ec6ff 100644 --- a/ndb/test/src/HugoOperations.cpp +++ b/ndb/test/src/HugoOperations.cpp @@ -32,6 +32,13 @@ int HugoOperations::startTransaction(Ndb* pNdb){ return NDBT_OK; } +void +HugoOperations::setTransactionId(Uint64 id){ + if (pTrans != NULL){ + pTrans->setTransactionId(id); + } +} + int HugoOperations::closeTransaction(Ndb* pNdb){ if (pTrans != NULL){ @@ -401,6 +408,10 @@ HugoOperations::HugoOperations(const NdbDictionary::Table& _tab): HugoOperations::~HugoOperations(){ deallocRows(); + if (pTrans != NULL){ + pTrans->close(); + pTrans = NULL; + } } diff --git a/ndb/test/src/HugoTransactions.cpp b/ndb/test/src/HugoTransactions.cpp index 456bfffbb77..5d5b2fa99df 100644 --- a/ndb/test/src/HugoTransactions.cpp +++ b/ndb/test/src/HugoTransactions.cpp @@ -29,26 +29,173 @@ HugoTransactions::~HugoTransactions(){ deallocRows(); } - -int HugoTransactions::scanReadCommittedRecords(Ndb* pNdb, +int +HugoTransactions::scanReadRecords(Ndb* pNdb, int records, int abortPercent, - int parallelism){ - return scanReadRecords(pNdb, records, abortPercent, parallelism, true); + int parallelism, + NdbOperation::LockMode lm) +{ + + int retryAttempt = 0; + const int retryMax = 100; + int check, a; + NdbScanOperation *pOp; + + while (true){ + + if (retryAttempt >= retryMax){ + g_err << "ERROR: has retried this operation " << retryAttempt + << " times, failing!" << endl; + return NDBT_FAILED; + } + + pTrans = pNdb->startTransaction(); + if (pTrans == NULL) { + const NdbError err = pNdb->getNdbError(); + + if (err.status == NdbError::TemporaryError){ + ERR(err); + NdbSleep_MilliSleep(50); + retryAttempt++; + continue; + } + ERR(err); + return NDBT_FAILED; + } + + pOp = pTrans->getNdbScanOperation(tab.getName()); + if (pOp == NULL) { + ERR(pTrans->getNdbError()); + closeTransaction(pNdb); + return NDBT_FAILED; + } + + NdbResultSet * rs; + rs = pOp ->readTuples(lm); + + if( rs == 0 ) { + ERR(pTrans->getNdbError()); + closeTransaction(pNdb); + return NDBT_FAILED; + } + + check = pOp->interpret_exit_ok(); + if( check == -1 ) { + ERR(pTrans->getNdbError()); + closeTransaction(pNdb); + return NDBT_FAILED; + } + + for(a = 0; a<tab.getNoOfColumns(); a++){ + if((row.attributeStore(a) = + pOp->getValue(tab.getColumn(a)->getName())) == 0) { + ERR(pTrans->getNdbError()); + closeTransaction(pNdb); + return NDBT_FAILED; + } + } + + check = pTrans->execute(NoCommit); + if( check == -1 ) { + const NdbError err = pTrans->getNdbError(); + if (err.status == NdbError::TemporaryError){ + ERR(err); + closeTransaction(pNdb); + NdbSleep_MilliSleep(50); + retryAttempt++; + continue; + } + ERR(err); + closeTransaction(pNdb); + return NDBT_FAILED; + } + + // Abort after 1-100 or 1-records rows + int ranVal = rand(); + int abortCount = ranVal % (records == 0 ? 100 : records); + bool abortTrans = false; + if (abort > 0){ + // Abort if abortCount is less then abortPercent + if (abortCount < abortPercent) + abortTrans = true; + } + + int eof; + int rows = 0; + while((eof = rs->nextResult(true)) == 0){ + rows++; + if (calc.verifyRowValues(&row) != 0){ + closeTransaction(pNdb); + return NDBT_FAILED; + } + + if (abortCount == rows && abortTrans == true){ + ndbout << "Scan is aborted" << endl; + g_info << "Scan is aborted" << endl; + rs->close(); + if( check == -1 ) { + ERR(pTrans->getNdbError()); + closeTransaction(pNdb); + return NDBT_FAILED; + } + + closeTransaction(pNdb); + return NDBT_OK; + } + } + if (eof == -1) { + const NdbError err = pTrans->getNdbError(); + + if (err.status == NdbError::TemporaryError){ + ERR_INFO(err); + closeTransaction(pNdb); + NdbSleep_MilliSleep(50); + switch (err.code){ + case 488: + case 245: + case 490: + // Too many active scans, no limit on number of retry attempts + break; + default: + retryAttempt++; + } + continue; + } + ERR(err); + closeTransaction(pNdb); + return NDBT_FAILED; + } + + closeTransaction(pNdb); + + g_info << rows << " rows have been read" << endl; + if (records != 0 && rows != records){ + g_err << "Check expected number of records failed" << endl + << " expected=" << records <<", " << endl + << " read=" << rows << endl; + return NDBT_FAILED; + } + + return NDBT_OK; + } + return NDBT_FAILED; } int HugoTransactions::scanReadRecords(Ndb* pNdb, + const NdbDictionary::Index * pIdx, int records, int abortPercent, int parallelism, - bool committed){ + NdbOperation::LockMode lm, + bool sorted) +{ int retryAttempt = 0; const int retryMax = 100; int check, a; - NdbConnection *pTrans; - NdbScanOperation *pOp; + NdbIndexScanOperation *pOp; while (true){ @@ -72,27 +219,26 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, return NDBT_FAILED; } - pOp = pTrans->getNdbScanOperation(tab.getName()); + pOp = pTrans->getNdbIndexScanOperation(pIdx->getName(), tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } NdbResultSet * rs; - rs = pOp ->readTuples(committed ? NdbScanOperation::LM_CommittedRead : - NdbScanOperation::LM_Read); + rs = pOp ->readTuples(lm, 0, parallelism, sorted); if( rs == 0 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->interpret_exit_ok(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -100,7 +246,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, if((row.attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == 0) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -110,13 +256,13 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, const NdbError err = pTrans->getNdbError(); if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -135,7 +281,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, while((eof = rs->nextResult(true)) == 0){ rows++; if (calc.verifyRowValues(&row) != 0){ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -145,11 +291,11 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, rs->close(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_OK; } } @@ -158,7 +304,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR_INFO(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); switch (err.code){ case 488: @@ -172,17 +318,17 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); g_info << rows << " rows have been read" << endl; if (records != 0 && rows != records){ g_err << "Check expected number of records failed" << endl - << " expected=" << records <<", " << endl - << " read=" << rows << endl; + << " expected=" << records <<", " << endl + << " read=" << rows << endl; return NDBT_FAILED; } @@ -196,9 +342,9 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, int HugoTransactions::scanUpdateRecords(Ndb* pNdb, - int records, - int abortPercent, - int parallelism){ + int records, + int abortPercent, + int parallelism){ if(m_defaultScanUpdateMethod == 1){ return scanUpdateRecords1(pNdb, records, abortPercent, parallelism); } else if(m_defaultScanUpdateMethod == 2){ @@ -221,7 +367,6 @@ HugoTransactions::scanUpdateRecords1(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a; - NdbConnection *pTrans; NdbOperation *pOp; @@ -250,21 +395,21 @@ HugoTransactions::scanUpdateRecords1(Ndb* pNdb, pOp = pTrans->getNdbOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->openScanExclusive(parallelism); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->interpret_exit_ok(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -272,7 +417,7 @@ HugoTransactions::scanUpdateRecords1(Ndb* pNdb, for(a=0; a<tab.getNoOfColumns(); a++){ if((row.attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == NULL){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -282,13 +427,13 @@ HugoTransactions::scanUpdateRecords1(Ndb* pNdb, const NdbError err = pTrans->getNdbError(); if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -316,11 +461,11 @@ HugoTransactions::scanUpdateRecords1(Ndb* pNdb, check = pTrans->stopScan(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_OK; } int res = takeOverAndUpdateRecord(pNdb, pOp); @@ -329,7 +474,7 @@ HugoTransactions::scanUpdateRecords1(Ndb* pNdb, continue; } if (res != 0){ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return res; } @@ -353,18 +498,18 @@ HugoTransactions::scanUpdateRecords1(Ndb* pNdb, continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } if(eof == -2){ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); g_info << rows << " rows have been updated" << endl; return NDBT_OK; @@ -388,7 +533,6 @@ HugoTransactions::scanUpdateRecords2(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a; - NdbConnection *pTrans; NdbOperation *pOp; @@ -417,21 +561,21 @@ HugoTransactions::scanUpdateRecords2(Ndb* pNdb, pOp = pTrans->getNdbOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->openScanExclusive(parallelism); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->interpret_exit_ok(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -439,7 +583,7 @@ HugoTransactions::scanUpdateRecords2(Ndb* pNdb, for(a=0; a<tab.getNoOfColumns(); a++){ if((row.attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == NULL){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -449,13 +593,13 @@ HugoTransactions::scanUpdateRecords2(Ndb* pNdb, const NdbError err = pTrans->getNdbError(); if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -471,7 +615,6 @@ HugoTransactions::scanUpdateRecords2(Ndb* pNdb, int eof; int rows = 0; - NdbConnection* pUpTrans; while((eof = pTrans->nextScanResult(true)) == 0){ pUpTrans = pNdb->startTransaction(); @@ -491,7 +634,7 @@ HugoTransactions::scanUpdateRecords2(Ndb* pNdb, rows++; if (addRowToUpdate(pNdb, pUpTrans, pOp) != 0){ pNdb->closeTransaction(pUpTrans); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } while((eof = pTrans->nextScanResult(false)) == 0); @@ -502,12 +645,12 @@ HugoTransactions::scanUpdateRecords2(Ndb* pNdb, check = pTrans->stopScan(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); pNdb->closeTransaction(pUpTrans); return NDBT_FAILED; } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); pNdb->closeTransaction(pUpTrans); return NDBT_OK; } @@ -517,7 +660,7 @@ HugoTransactions::scanUpdateRecords2(Ndb* pNdb, const NdbError err = pUpTrans->getNdbError(); ERR(err); pNdb->closeTransaction(pUpTrans); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } pNdb->closeTransaction(pUpTrans); @@ -527,17 +670,17 @@ HugoTransactions::scanUpdateRecords2(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); g_info << rows << " rows have been updated" << endl; return NDBT_OK; @@ -554,12 +697,11 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a; - NdbConnection *pTrans; NdbScanOperation *pOp; while (true){ - restart: +restart: if (retryAttempt++ >= retryMax){ g_info << "ERROR: has retried this operation " << retryAttempt << " times, failing!" << endl; @@ -580,14 +722,14 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, pOp = pTrans->getNdbScanOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } NdbResultSet *rs = pOp->readTuplesExclusive(parallelism); if( rs == 0 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -595,7 +737,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, for(a=0; a<tab.getNoOfColumns(); a++){ if((row.attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == NULL){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -604,7 +746,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, if( check == -1 ) { const NdbError err = pTrans->getNdbError(); ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); if (err.status == NdbError::TemporaryError){ NdbSleep_MilliSleep(50); continue; @@ -629,7 +771,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, NdbOperation* pUp = rs->updateTuple(); if(pUp == 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } const int updates = calc.getUpdatesValue(&row) + 1; @@ -638,7 +780,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == false){ if(setValueForAttr(pUp, a, r, updates ) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -647,7 +789,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, if (rows == abortCount && abortTrans == true){ g_info << "Scan is aborted" << endl; // This scan should be aborted - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_OK; } } while((check = rs->nextResult(false)) == 0); @@ -659,7 +801,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, const NdbError err = pTrans->getNdbError(); if( check == -1 ) { - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); ERR(err); if (err.status == NdbError::TemporaryError){ NdbSleep_MilliSleep(50); @@ -671,7 +813,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, const NdbError err = pTrans->getNdbError(); if( check == -1 ) { - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); ERR(err); if (err.status == NdbError::TemporaryError){ NdbSleep_MilliSleep(50); @@ -680,7 +822,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, return NDBT_FAILED; } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); g_info << rows << " rows have been updated" << endl; return NDBT_OK; @@ -698,7 +840,6 @@ HugoTransactions::loadTable(Ndb* pNdb, int check, a; int retryAttempt = 0; int retryMax = 5; - NdbConnection *pTrans; NdbOperation *pOp; bool first_batch = true; @@ -751,14 +892,14 @@ HugoTransactions::loadTable(Ndb* pNdb, pOp = pTrans->getNdbOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->insertTuple(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -766,7 +907,7 @@ HugoTransactions::loadTable(Ndb* pNdb, for (a = 0; a<tab.getNoOfColumns(); a++){ if(setValueForAttr(pOp, a, c+b, 0 ) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -784,7 +925,7 @@ HugoTransactions::loadTable(Ndb* pNdb, } if(check == -1 ) { const NdbError err = pTrans->getNdbError(); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); pTrans= 0; switch(err.status){ case NdbError::Success: @@ -826,7 +967,7 @@ HugoTransactions::loadTable(Ndb* pNdb, } else{ if (closeTrans) { - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); pTrans= 0; } } @@ -844,7 +985,6 @@ HugoTransactions::fillTable(Ndb* pNdb, int check, a, b; int retryAttempt = 0; int retryMax = 5; - NdbConnection *pTrans; NdbOperation *pOp; g_info << "|- Inserting records..." << endl; @@ -877,14 +1017,14 @@ HugoTransactions::fillTable(Ndb* pNdb, pOp = pTrans->getNdbOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->insertTuple(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -892,7 +1032,7 @@ HugoTransactions::fillTable(Ndb* pNdb, for (a = 0; a<tab.getNoOfColumns(); a++){ if(setValueForAttr(pOp, a, c+b, 0 ) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -902,7 +1042,7 @@ HugoTransactions::fillTable(Ndb* pNdb, check = pTrans->execute( Commit, CommitAsMuchAsPossible ); if(check == -1 ) { const NdbError err = pTrans->getNdbError(); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); switch(err.status){ case NdbError::Success: @@ -954,7 +1094,7 @@ HugoTransactions::fillTable(Ndb* pNdb, } } else{ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); } // Step to next record @@ -1236,7 +1376,6 @@ HugoTransactions::pkReadRecords(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a; - NdbConnection *pTrans; NdbOperation *pOp; if (batchsize == 0) { @@ -1271,7 +1410,7 @@ HugoTransactions::pkReadRecords(Ndb* pNdb, pOp = pTrans->getNdbOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1293,7 +1432,7 @@ HugoTransactions::pkReadRecords(Ndb* pNdb, if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1302,7 +1441,7 @@ HugoTransactions::pkReadRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pOp, a, r+b) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1313,7 +1452,7 @@ HugoTransactions::pkReadRecords(Ndb* pNdb, if((rows[b]->attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == 0) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1326,7 +1465,7 @@ HugoTransactions::pkReadRecords(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; @@ -1339,13 +1478,13 @@ HugoTransactions::pkReadRecords(Ndb* pNdb, default: ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } else{ for (int b=0; (b<batchsize) && (r+b<records); b++){ if (calc.verifyRowValues(rows[b]) != 0){ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } reads++; @@ -1353,7 +1492,7 @@ HugoTransactions::pkReadRecords(Ndb* pNdb, } } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); } deallocRows(); @@ -1373,7 +1512,6 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a, b; - NdbConnection *pTrans; NdbOperation *pOp; allocRows(batch); @@ -1408,14 +1546,14 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, pOp = pTrans->getNdbOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->readTupleExclusive(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1424,7 +1562,7 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pOp, a, r+b) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1435,7 +1573,7 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, if((rows[b]->attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == 0) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1447,19 +1585,19 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } for(b = 0; b<batch && (b+r)<records; b++){ if (calc.verifyRowValues(rows[b]) != 0){ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1469,14 +1607,14 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, pUpdOp = pTrans->getNdbOperation(tab.getName()); if (pUpdOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pUpdOp->updateTuple(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1484,7 +1622,7 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pUpdOp, a, r+b) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1494,7 +1632,7 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == false){ if(setValueForAttr(pUpdOp, a, r+b, updates ) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1507,14 +1645,14 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); ndbout << "r = " << r << endl; - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } else{ @@ -1522,7 +1660,7 @@ HugoTransactions::pkUpdateRecords(Ndb* pNdb, } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); r += batch; // Read next record } @@ -1541,7 +1679,6 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a; - NdbConnection *pTrans; while (r < records){ @@ -1568,14 +1705,14 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, NdbOperation* pOp = pTrans->getNdbOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->readTupleExclusive(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1584,7 +1721,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pOp, a, r) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1596,7 +1733,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, if((row.attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == 0) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1608,13 +1745,13 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1624,14 +1761,14 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, pUpdOp = pTrans->getNdbOperation(tab.getName()); if (pUpdOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pUpdOp->interpretedUpdateTuple(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1640,7 +1777,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pUpdOp, a, r) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1657,7 +1794,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, check = pUpdOp->incValue(attr->getName(), valToIncWith); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1669,7 +1806,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, (calc.isUpdateCol(a) == false)){ if(setValueForAttr(pUpdOp, a, r, updates ) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1683,14 +1820,14 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); ndbout << "r = " << r << endl; - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } else{ @@ -1698,7 +1835,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); r++; // Read next record @@ -1720,7 +1857,6 @@ HugoTransactions::pkDelRecords(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a; - NdbConnection *pTrans; NdbOperation *pOp; g_info << "|- Deleting records..." << endl; @@ -1752,14 +1888,14 @@ HugoTransactions::pkDelRecords(Ndb* pNdb, pOp = pTrans->getNdbOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->deleteTuple(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1768,7 +1904,7 @@ HugoTransactions::pkDelRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pOp, a, r) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1780,7 +1916,7 @@ HugoTransactions::pkDelRecords(Ndb* pNdb, switch(err.status){ case NdbError::TemporaryError: ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; @@ -1799,20 +1935,20 @@ HugoTransactions::pkDelRecords(Ndb* pNdb, } } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; break; default: ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } else { deleted++; } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); r++; // Read next record @@ -1835,7 +1971,6 @@ HugoTransactions::lockRecords(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a, b; - NdbConnection *pTrans; NdbOperation *pOp; // Calculate how many records to lock in each batch @@ -1875,14 +2010,14 @@ HugoTransactions::lockRecords(Ndb* pNdb, pOp = pTrans->getNdbOperation(tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->readTupleExclusive(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -1891,7 +2026,7 @@ HugoTransactions::lockRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pOp, a, r+b) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1902,7 +2037,7 @@ HugoTransactions::lockRecords(Ndb* pNdb, if((rows[b]->attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == 0) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1918,18 +2053,18 @@ HugoTransactions::lockRecords(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } for (int b=0; (b<lockBatch) && (r+b<records); b++){ if (calc.verifyRowValues(rows[b]) != 0){ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -1944,26 +2079,26 @@ HugoTransactions::lockRecords(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } else{ for (int b=0; (b<lockBatch) && (r<records); b++){ if (calc.verifyRowValues(rows[b]) != 0){ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } r++; // Read next record } } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); } @@ -1982,7 +2117,6 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a; - NdbConnection *pTrans; NdbOperation *pOp; NdbIndexScanOperation *sOp; NdbResultSet * rs; @@ -2030,7 +2164,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, pOp = pTrans->getNdbIndexOperation(idxName, tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->readTuple(); @@ -2038,7 +2172,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, pOp = sOp = pTrans->getNdbIndexScanOperation(idxName, tab.getName()); if (sOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -2048,7 +2182,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -2057,7 +2191,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pOp, a, r+b) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -2068,7 +2202,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, if((rows[b]->attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == 0) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -2081,7 +2215,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, if (err.status == NdbError::TemporaryError){ ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); NdbSleep_MilliSleep(50); retryAttempt++; continue; @@ -2094,13 +2228,13 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, default: ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } else{ for (int b=0; (b<batchsize) && (r+b<records); b++){ if (calc.verifyRowValues(rows[b]) != 0){ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } reads++; @@ -2109,11 +2243,11 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, if(ordered && rs->nextResult(true) == 0){ ndbout << "Error when comparing records " << " - index op next_result to many" << endl; - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); } deallocRows(); g_info << reads << " records read" << endl; @@ -2133,7 +2267,6 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, int retryAttempt = 0; const int retryMax = 100; int check, a, b; - NdbConnection *pTrans; NdbOperation *pOp; NdbScanOperation * sOp; NdbResultSet * rs; @@ -2174,21 +2307,21 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, pOp = pTrans->getNdbIndexOperation(idxName, tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } check = pOp->readTupleExclusive(); if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } else { pOp = sOp = pTrans->getNdbIndexScanOperation(idxName, tab.getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -2201,7 +2334,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pOp, a, r+b) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -2212,7 +2345,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, if((rows[b]->attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == 0) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -2223,7 +2356,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, if( check == -1 ) { const NdbError err = pTrans->getNdbError(); ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); if (err.status == NdbError::TemporaryError){ NdbSleep_MilliSleep(50); @@ -2235,13 +2368,13 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, if(ordered && check != 0){ g_err << "Row: " << r << " not found!!" << endl; - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } for(b = 0; b<batchsize && (b+r)<records; b++){ if (calc.verifyRowValues(rows[b]) != 0){ - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -2257,13 +2390,13 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, if (pUpdOp == NULL) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } if( check == -1 ) { ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } @@ -2272,7 +2405,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == true){ if(equalForAttr(pUpdOp, a, r+b) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -2283,7 +2416,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, if (tab.getColumn(a)->getPrimaryKey() == false){ if(setValueForAttr(pUpdOp, a, r+b, updates ) != 0){ ERR(pTrans->getNdbError()); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); return NDBT_FAILED; } } @@ -2294,7 +2427,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, if( check == -1 ) { const NdbError err = pTrans->getNdbError(); ERR(err); - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); if (err.status == NdbError::TemporaryError){ NdbSleep_MilliSleep(50); @@ -2307,7 +2440,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, updated += batchsize; } - pNdb->closeTransaction(pTrans); + closeTransaction(pNdb); r+= batchsize; // Read next record } diff --git a/ndb/test/src/Makefile.am b/ndb/test/src/Makefile.am index a513086dc33..289633b060a 100644 --- a/ndb/test/src/Makefile.am +++ b/ndb/test/src/Makefile.am @@ -9,7 +9,8 @@ libNDBT_a_SOURCES = \ HugoAsynchTransactions.cpp UtilTransactions.cpp \ NdbRestarter.cpp NdbRestarts.cpp NDBT_Output.cpp \ NdbBackup.cpp NdbConfig.cpp NdbGrep.cpp NDBT_Table.cpp \ - NdbSchemaCon.cpp NdbSchemaOp.cpp + NdbSchemaCon.cpp NdbSchemaOp.cpp getarg.c \ + CpcClient.cpp INCLUDES_LOC = -I$(top_srcdir)/ndb/src/common/mgmcommon -I$(top_srcdir)/ndb/include/mgmcommon -I$(top_srcdir)/ndb/include/kernel -I$(top_srcdir)/ndb/src/mgmapi @@ -18,3 +19,17 @@ include $(top_srcdir)/ndb/config/type_ndbapitest.mk.am # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: libNDBT.dsp + +libNDBT.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-lib.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-lib.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ $(noinst_LIBRARIES) + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(libNDBT_a_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LIB diff --git a/ndb/test/src/Makefile_old b/ndb/test/src/Makefile_old deleted file mode 100644 index 2738ce1aba2..00000000000 --- a/ndb/test/src/Makefile_old +++ /dev/null @@ -1,33 +0,0 @@ -include .defs.mk - -TYPE := ndbapitest - -ARCHIVE_TARGET := NDBT - -SOURCES = NDBT_ReturnCodes.cpp \ - NDBT_Error.cpp NDBT_Tables.cpp NDBT_ResultRow.cpp \ - NDBT_Test.cpp HugoCalculator.cpp \ - HugoOperations.cpp HugoTransactions.cpp \ - HugoAsynchTransactions.cpp UtilTransactions.cpp \ - NdbRestarter.cpp NdbRestarts.cpp NDBT_Output.cpp \ - NdbBackup.cpp NdbConfig.cpp NdbGrep.cpp NDBT_Table.cpp - -SOURCES.c = - -CFLAGS_NdbRestarter.cpp := -I$(call fixpath,$(NDB_TOP)/src/common/mgmcommon) -CFLAGS_NdbConfig.cpp := -I$(call fixpath,$(NDB_TOP)/include/mgmcommon) \ - -I$(call fixpath,$(NDB_TOP)/src/mgmapi) -CFLAGS_NdbRestarts.cpp := -I$(call fixpath,$(NDB_TOP)/include/kernel) -CFLAGS_NdbBackup.cpp := -I$(call fixpath,$(NDB_TOP)/include/mgmcommon) \ - -I$(call fixpath,$(NDB_TOP)/src/mgmapi) \ - -I$(call fixpath,$(NDB_TOP)/include/kernel) -CFLAGS_NdbGrep.cpp += -I$(call fixpath,$(NDB_TOP)/include/kernel) -I$(call fixpath,$(NDB_TOP)/include/mgmcommon) - -include $(NDB_TOP)/Epilogue.mk - - - - - - - diff --git a/ndb/test/src/NDBT_Test.cpp b/ndb/test/src/NDBT_Test.cpp index 367223f8c98..600a5443f40 100644 --- a/ndb/test/src/NDBT_Test.cpp +++ b/ndb/test/src/NDBT_Test.cpp @@ -327,13 +327,17 @@ NDBT_Finalizer::NDBT_Finalizer(NDBT_TestCase* ptest, NDBT_TestCase::NDBT_TestCase(NDBT_TestSuite* psuite, const char* pname, const char* pcomment) : - name(pname) , - comment(pcomment), - suite(psuite){ + name(strdup(pname)) , + comment(strdup(pcomment)), + suite(psuite) +{ + _name.assign(pname); + _comment.assign(pcomment); + name= _name.c_str(); + comment= _comment.c_str(); assert(suite != NULL); } - NDBT_TestCaseImpl1::NDBT_TestCaseImpl1(NDBT_TestSuite* psuite, const char* pname, const char* pcomment) : @@ -475,7 +479,6 @@ void * runStep_C(void * s) { runStep(s); - NdbThread_Exit(0); return NULL; } @@ -519,6 +522,7 @@ void NDBT_TestCaseImpl1::waitSteps(){ NdbThread_WaitFor(threads[i], &status); NdbThread_Destroy(&threads[i]); } + threads.clear(); } @@ -839,9 +843,9 @@ void NDBT_TestSuite::execute(Ndb* ndb, const NdbDictionary::Table* pTab, continue; } pTab2 = pDict->getTable(pTab->getName()); - } else { + } else if(!pTab2) { pTab2 = pTab; - } + } ctx = new NDBT_Context(); ctx->setTab(pTab2); diff --git a/ndb/test/src/NdbBackup.cpp b/ndb/test/src/NdbBackup.cpp index 1ce48d495a5..5e22468692e 100644 --- a/ndb/test/src/NdbBackup.cpp +++ b/ndb/test/src/NdbBackup.cpp @@ -46,7 +46,8 @@ NdbBackup::start(unsigned int & _backup_id){ ndb_mgm_reply reply; reply.return_code = 0; - if (ndb_mgm_start_backup(handle, + if (ndb_mgm_start_backup(handle, + 2, // wait until completed &_backup_id, &reply) == -1) { g_err << "Could not start backup " << endl; @@ -69,28 +70,19 @@ NdbBackup::getBackupDataDirForNode(int _node_id){ /** * Fetch configuration from management server */ - LocalConfig lc; - if (!lc.init(0,0)) { - abort(); - } - ConfigRetriever cr(lc, 0, NODE_TYPE_API); - ndb_mgm_configuration * p = 0; + ndb_mgm_configuration *p; + if (connect()) + return NULL; - BaseString tmp; tmp.assfmt("%s:%d", host.c_str(), port); - NdbMgmHandle handle = ndb_mgm_create_handle(); - if(handle == 0 || ndb_mgm_connect(handle, tmp.c_str()) != 0 || - (p = ndb_mgm_get_configuration(handle, 0)) == 0){ - - const char * s = 0; - if(p == 0 && handle != 0){ - s = ndb_mgm_get_latest_error_msg(handle); - if(s == 0) - s = "No error given!"; + if ((p = ndb_mgm_get_configuration(handle, 0)) == 0) + { + const char * s= ndb_mgm_get_latest_error_msg(handle); + if(s == 0) + s = "No error given!"; - ndbout << "Could not fetch configuration" << endl; - ndbout << s << endl; - return NULL; - } + ndbout << "Could not fetch configuration" << endl; + ndbout << s << endl; + return NULL; } /** @@ -155,13 +147,14 @@ NdbBackup::execRestore(bool _restore_data, ndbout << "scp res: " << res << endl; - BaseString::snprintf(buf, 255, "%sndb_restore -c \"host=%s\" -n %d -b %d %s %s .", + BaseString::snprintf(buf, 255, "%sndb_restore -c \"%s:%d\" -n %d -b %d %s %s .", #if 1 "", #else "valgrind --leak-check=yes -v " #endif - addr.c_str(), + ndb_mgm_get_connected_host(handle), + ndb_mgm_get_connected_port(handle), _node_id, _backup_id, _restore_data?"-r":"", diff --git a/ndb/test/src/NdbRestarter.cpp b/ndb/test/src/NdbRestarter.cpp index 4d6d3ddc001..91c0963feae 100644 --- a/ndb/test/src/NdbRestarter.cpp +++ b/ndb/test/src/NdbRestarter.cpp @@ -18,7 +18,6 @@ #include <NdbOut.hpp> #include <NdbSleep.h> #include <NdbTick.h> -#include <LocalConfig.hpp> #include <mgmapi_debug.h> #include <NDBT_Output.hpp> #include <random.h> @@ -33,42 +32,11 @@ NdbRestarter::NdbRestarter(const char* _addr): connected(false), - port(-1), handle(NULL), m_config(0) { if (_addr == NULL){ - LocalConfig lcfg; - if(!lcfg.init()){ - lcfg.printError(); - lcfg.printUsage(); - g_err << "NdbRestarter - Error parsing local config file" << endl; - return; - } - - if (lcfg.ids.size() == 0){ - g_err << "NdbRestarter - No management servers configured in local config file" << endl; - return; - } - - for (int i = 0; i<lcfg.ids.size(); i++){ - MgmtSrvrId * m = &lcfg.ids[i]; - - switch(m->type){ - case MgmId_TCP: - char buf[255]; - snprintf(buf, 255, "%s:%d", m->name.c_str(), m->port); - addr.assign(buf); - host.assign(m->name.c_str()); - port = m->port; - return; - break; - case MgmId_File: - break; - default: - break; - } - } + addr.assign(""); } else { addr.assign(_addr); } @@ -391,13 +359,22 @@ NdbRestarter::isConnected(){ int NdbRestarter::connect(){ + disconnect(); handle = ndb_mgm_create_handle(); if (handle == NULL){ g_err << "handle == NULL" << endl; return -1; } g_info << "Connecting to mgmsrv at " << addr.c_str() << endl; - if (ndb_mgm_connect(handle, addr.c_str()) == -1) { + if (ndb_mgm_set_connectstring(handle,addr.c_str())) + { + MGMERR(handle); + g_err << "Connection to " << addr.c_str() << " failed" << endl; + return -1; + } + + if (ndb_mgm_connect(handle, 0, 0, 0) == -1) + { MGMERR(handle); g_err << "Connection to " << addr.c_str() << " failed" << endl; return -1; diff --git a/ndb/test/src/NdbRestarts.cpp b/ndb/test/src/NdbRestarts.cpp index b649a60d98b..607e48c4126 100644 --- a/ndb/test/src/NdbRestarts.cpp +++ b/ndb/test/src/NdbRestarts.cpp @@ -445,7 +445,7 @@ int twoNodeFailure(NdbRestarter& _restarter, << ") secs " << endl; NdbSleep_SecSleep(seconds); - randomId = (random() % _restarter.getNumDbNodes()); + randomId = (rand() % _restarter.getNumDbNodes()); nodeId = _restarter.getDbNodeId(randomId); g_info << _restart->m_name << ": node = "<< nodeId << endl; diff --git a/ndb/test/src/UtilTransactions.cpp b/ndb/test/src/UtilTransactions.cpp index c0e6effd244..869f7fc76cb 100644 --- a/ndb/test/src/UtilTransactions.cpp +++ b/ndb/test/src/UtilTransactions.cpp @@ -619,7 +619,7 @@ UtilTransactions::addRowToInsert(Ndb* pNdb, int UtilTransactions::scanReadRecords(Ndb* pNdb, int parallelism, - bool exclusive, + NdbOperation::LockMode lm, int records, int noAttribs, int *attrib_list, @@ -669,10 +669,7 @@ UtilTransactions::scanReadRecords(Ndb* pNdb, return NDBT_FAILED; } - NdbResultSet * rs = pOp->readTuples(exclusive ? - NdbScanOperation::LM_Exclusive : - NdbScanOperation::LM_Read, - 0, parallelism); + NdbResultSet * rs = pOp->readTuples(lm, 0, parallelism); if( rs == 0 ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); @@ -761,7 +758,7 @@ int UtilTransactions::selectCount(Ndb* pNdb, int parallelism, int* count_rows, - ScanLock lock, + NdbOperation::LockMode lm, NdbConnection* pTrans){ int retryAttempt = 0; @@ -785,19 +782,7 @@ UtilTransactions::selectCount(Ndb* pNdb, return NDBT_FAILED; } - NdbResultSet * rs; - switch(lock){ - case SL_ReadHold: - rs = pOp->readTuples(NdbScanOperation::LM_Read); - break; - case SL_Exclusive: - rs = pOp->readTuples(NdbScanOperation::LM_Exclusive); - break; - case SL_Read: - default: - rs = pOp->readTuples(NdbScanOperation::LM_CommittedRead); - } - + NdbResultSet * rs = pOp->readTuples(lm); if( rs == 0) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); diff --git a/ndb/src/common/util/getarg.c b/ndb/test/src/getarg.c index 99b2840a5a6..5b67eb6343d 100644 --- a/ndb/src/common/util/getarg.c +++ b/ndb/test/src/getarg.c @@ -35,16 +35,35 @@ #include <ndb_global.h> #include "getarg.h" - -#define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag) +#include <basestring_vsnprintf.h> #ifndef HAVE_STRLCPY -extern size_t strlcpy (char *dst, const char *src, size_t dst_sz); -#endif /* !HAVE_STRLCPY */ - +static size_t +strlcpy (char *dst, const char *src, size_t dst_sz) +{ + size_t n; + char *p; + for (p = dst, n = 0; + n + 1 < dst_sz && *src != '\0'; + ++p, ++src, ++n) + *p = *src; + *p = '\0'; + if (*src == '\0') + return n; + else + return n + strlen (src); +} +#endif #ifndef HAVE_STRLCAT -extern size_t strlcat (char *dst, const char *src, size_t dst_sz); -#endif /* !HAVE_STRLCAT */ +static size_t +strlcat (char *dst, const char *src, size_t dst_sz) +{ + size_t len = strlen(dst); + return len + strlcpy (dst + len, src, dst_sz - len); +} +#endif + +#define ISFLAG(X) ((X).type == arg_flag || (X).type == arg_negative_flag) #ifndef max #define max(a, b) (a) > (b) ? (a) : (b) @@ -275,7 +294,7 @@ arg_printusage (struct getargs *args, col += fprintf(stderr, " %s", buf); } if (args[i].short_name) { - snprintf(buf, sizeof(buf), "[-%c", args[i].short_name); + basestring_snprintf(buf, sizeof(buf), "[-%c", args[i].short_name); len += 2; len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf), 0, 0, &args[i]); diff --git a/ndb/test/tools/Makefile.am b/ndb/test/tools/Makefile.am index 8d94c21b721..a6a013bb263 100644 --- a/ndb/test/tools/Makefile.am +++ b/ndb/test/tools/Makefile.am @@ -20,12 +20,12 @@ copy_tab_SOURCES = copy_tab.cpp create_index_SOURCES = create_index.cpp ndb_cpcc_SOURCES = cpcc.cpp -INCLUDES_LOC = -I$(top_srcdir)/ndb/src/mgmclient - include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapitest.mk.am -ndb_cpcc_LDADD = $(LDADD) $(top_builddir)/ndb/src/mgmclient/CpcClient.o +ndb_cpcc_LDADD = $(LDADD) # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: diff --git a/ndb/test/tools/Makefile_old b/ndb/test/tools/Makefile_old deleted file mode 100644 index b8e90ae207f..00000000000 --- a/ndb/test/tools/Makefile_old +++ /dev/null @@ -1,9 +0,0 @@ -include .defs.mk - -DIRS := hugoCalculator hugoFill hugoLoad hugoLockRecords \ - hugoPkDelete hugoPkRead hugoPkReadRecord hugoPkUpdate \ - hugoScanRead hugoScanUpdate restart waiter - -include $(NDB_TOP)/Epilogue.mk - -_bins_ndbapi : _libs_src diff --git a/ndb/test/tools/create_index.cpp b/ndb/test/tools/create_index.cpp index 75a657522f6..6e4c5377f4a 100644 --- a/ndb/test/tools/create_index.cpp +++ b/ndb/test/tools/create_index.cpp @@ -30,7 +30,7 @@ main(int argc, const char** argv){ const char* _dbname = "TEST_DB"; int _help = 0; - int _ordered, _pk; + int _ordered = 0, _pk = 1; struct getargs args[] = { { "database", 'd', arg_string, &_dbname, "dbname", diff --git a/ndb/test/tools/hugoScanRead.cpp b/ndb/test/tools/hugoScanRead.cpp index cdfdcea4654..42180207a8a 100644 --- a/ndb/test/tools/hugoScanRead.cpp +++ b/ndb/test/tools/hugoScanRead.cpp @@ -35,13 +35,17 @@ int main(int argc, const char** argv){ int _parallelism = 1; const char* _tabname = NULL; int _help = 0; - + int lock = NdbOperation::LM_Read; + int sorted = 0; + struct getargs args[] = { { "aborts", 'a', arg_integer, &_abort, "percent of transactions that are aborted", "abort%" }, { "loops", 'l', arg_integer, &_loops, "number of times to run this program(0=infinite loop)", "loops" }, { "parallelism", 'p', arg_integer, &_parallelism, "parallelism(1-240)", "para" }, { "records", 'r', arg_integer, &_records, "Number of records", "recs" }, - { "usage", '?', arg_flag, &_help, "Print help", "" } + { "usage", '?', arg_flag, &_help, "Print help", "" }, + { "lock", 'm', arg_integer, &lock, "lock mode", "" }, + { "sorted", 's', arg_flag, &sorted, "sorted", "" } }; int num_args = sizeof(args) / sizeof(args[0]); int optind = 0; @@ -73,16 +77,48 @@ int main(int argc, const char** argv){ ndbout << " Table " << _tabname << " does not exist!" << endl; return NDBT_ProgramExit(NDBT_WRONGARGS); } + + const NdbDictionary::Index * pIdx = 0; + if(optind+1 < argc) + { + pIdx = MyNdb.getDictionary()->getIndex(argv[optind+1], _tabname); + if(!pIdx) + ndbout << " Index " << argv[optind+1] << " not found" << endl; + else + if(pIdx->getType() != NdbDictionary::Index::UniqueOrderedIndex && + pIdx->getType() != NdbDictionary::Index::OrderedIndex) + { + ndbout << " Index " << argv[optind+1] << " is not scannable" << endl; + pIdx = 0; + } + } HugoTransactions hugoTrans(*pTab); int i = 0; while (i<_loops || _loops==0) { ndbout << i << ": "; - if(hugoTrans.scanReadRecords(&MyNdb, - 0, - _abort, - _parallelism) != 0){ - return NDBT_ProgramExit(NDBT_FAILED); + if(!pIdx) + { + if(hugoTrans.scanReadRecords(&MyNdb, + 0, + _abort, + _parallelism, + (NdbOperation::LockMode)lock) != 0) + { + return NDBT_ProgramExit(NDBT_FAILED); + } + } + else + { + if(hugoTrans.scanReadRecords(&MyNdb, pIdx, + 0, + _abort, + _parallelism, + (NdbOperation::LockMode)lock, + sorted) != 0) + { + return NDBT_ProgramExit(NDBT_FAILED); + } } i++; } diff --git a/ndb/test/tools/old_dirs/waiter/Makefile_old b/ndb/test/tools/old_dirs/waiter/Makefile_old deleted file mode 100644 index da2c9daff00..00000000000 --- a/ndb/test/tools/old_dirs/waiter/Makefile_old +++ /dev/null @@ -1,11 +0,0 @@ -include .defs.mk - -TYPE := ndbapitest - -BIN_TARGET := waiter - -# Source files of non-templated classes (.C files) -SOURCES = waiter.cpp - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/test/tools/transproxy.cpp b/ndb/test/tools/transproxy.cpp index 88267801172..28a621fa584 100644 --- a/ndb/test/tools/transproxy.cpp +++ b/ndb/test/tools/transproxy.cpp @@ -291,7 +291,6 @@ extern "C" void* copyrun_C(void* copy) { ((Copy*) copy)->run(); - NdbThread_Exit(0); return 0; } @@ -322,7 +321,6 @@ extern "C" void* connrun_C(void* conn) { ((Conn*) conn)->run(); - NdbThread_Exit(0); return 0; } diff --git a/ndb/tools/Makefile.am b/ndb/tools/Makefile.am index 64625f69ea2..c350fb0a141 100644 --- a/ndb/tools/Makefile.am +++ b/ndb/tools/Makefile.am @@ -1,5 +1,6 @@ ndbtools_PROGRAMS = \ + ndb_test_platform \ ndb_waiter \ ndb_drop_table \ ndb_delete_all \ @@ -7,22 +8,34 @@ ndbtools_PROGRAMS = \ ndb_drop_index \ ndb_show_tables \ ndb_select_all \ - ndb_select_count + ndb_select_count \ + ndb_restore -tools_common_sources = ../test/src/NDBT_ReturnCodes.cpp ../test/src/NDBT_Table.cpp ../test/src/NDBT_Output.cpp +tools_common_sources = ../test/src/NDBT_ReturnCodes.cpp \ + ../test/src/NDBT_Table.cpp \ + ../test/src/NDBT_Output.cpp +ndb_test_platform_SOURCES = ndb_test_platform.cpp ndb_waiter_SOURCES = waiter.cpp $(tools_common_sources) ndb_delete_all_SOURCES = delete_all.cpp $(tools_common_sources) ndb_desc_SOURCES = desc.cpp $(tools_common_sources) ndb_drop_index_SOURCES = drop_index.cpp $(tools_common_sources) ndb_drop_table_SOURCES = drop_tab.cpp $(tools_common_sources) ndb_show_tables_SOURCES = listTables.cpp $(tools_common_sources) -ndb_select_all_SOURCES = select_all.cpp ../test/src/NDBT_ResultRow.cpp $(tools_common_sources) +ndb_select_all_SOURCES = select_all.cpp \ + ../test/src/NDBT_ResultRow.cpp \ + $(tools_common_sources) ndb_select_count_SOURCES = select_count.cpp $(tools_common_sources) +ndb_restore_SOURCES = restore/restore_main.cpp \ + restore/consumer.cpp \ + restore/consumer_restore.cpp \ + restore/consumer_printer.cpp \ + restore/Restore.cpp include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_ndbapitools.mk.am +ndb_test_platform_LDFLAGS = @ndb_bin_am_ldflags@ ndb_waiter_LDFLAGS = @ndb_bin_am_ldflags@ ndb_drop_table_LDFLAGS = @ndb_bin_am_ldflags@ ndb_delete_all_LDFLAGS = @ndb_bin_am_ldflags@ @@ -31,6 +44,113 @@ ndb_drop_index_LDFLAGS = @ndb_bin_am_ldflags@ ndb_show_tables_LDFLAGS = @ndb_bin_am_ldflags@ ndb_select_all_LDFLAGS = @ndb_bin_am_ldflags@ ndb_select_count_LDFLAGS = @ndb_bin_am_ldflags@ +ndb_restore_LDFLAGS = @ndb_bin_am_ldflags@ # Don't update the files from bitkeeper %::SCCS/s.% + +windoze-dsp: \ + ndb_waiter.dsp \ + ndb_drop_table.dsp \ + ndb_delete_all.dsp \ + ndb_desc.dsp \ + ndb_drop_index.dsp \ + ndb_show_tables.dsp \ + ndb_select_all.dsp \ + ndb_select_count.dsp + +ndb_waiter.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ ndb_waiter + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_waiter_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +ndb_drop_table.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ ndb_drop_table + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_drop_table_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +ndb_delete_all.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ ndb_delete_all + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_delete_all_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +ndb_desc.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ ndb_desc + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_desc_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +ndb_drop_index.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ ndb_drop_index + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_drop_index_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +ndb_show_tables.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ ndb_show_tables + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_show_tables_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +ndb_select_all.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ ndb_select_all + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_select_all_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) + +ndb_select_count.dsp: Makefile \ + $(top_srcdir)/ndb/config/win-prg.am \ + $(top_srcdir)/ndb/config/win-name \ + $(top_srcdir)/ndb/config/win-includes \ + $(top_srcdir)/ndb/config/win-sources \ + $(top_srcdir)/ndb/config/win-libraries + cat $(top_srcdir)/ndb/config/win-prg.am > $@ + @$(top_srcdir)/ndb/config/win-name $@ ndb_select_count + @$(top_srcdir)/ndb/config/win-includes $@ $(INCLUDES) + @$(top_srcdir)/ndb/config/win-sources $@ $(ndb_select_count_SOURCES) + @$(top_srcdir)/ndb/config/win-libraries $@ LINK $(LDADD) diff --git a/ndb/tools/Makefile_old b/ndb/tools/Makefile_old deleted file mode 100644 index b9dc6883e18..00000000000 --- a/ndb/tools/Makefile_old +++ /dev/null @@ -1,12 +0,0 @@ -include .defs.mk - -BIN_DIRS = select_all select_count desc list_tables \ - drop_tab delete_all copy_tab \ - create_index drop_index verify_index cpcc - -ifneq ($(NDB_ODBC),N) -BIN_DIRS += ndbsql -endif - -include $(NDB_TOP)/Epilogue.mk - diff --git a/ndb/tools/delete_all.cpp b/ndb/tools/delete_all.cpp index aa5798376ae..21e0c2ac089 100644 --- a/ndb/tools/delete_all.cpp +++ b/ndb/tools/delete_all.cpp @@ -15,41 +15,52 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> +#include <ndb_opts.h> #include <NdbOut.hpp> #include <NdbApi.hpp> #include <NdbSleep.h> #include <NDBT.hpp> -#include <getarg.h> - static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240); -int main(int argc, const char** argv){ - ndb_init(); +NDB_STD_OPTS_VARS; - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _help = 0; - - struct getargs args[] = { - { "usage", '?', arg_flag, &_help, "Print help", "" }, - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"} - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* _dbname = "TEST_DB"; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void usage() +{ char desc[] = "tabname\n"\ "This program will delete all records in the specified table using scan delete.\n"; - - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help) { - arg_printusage(args, num_args, argv[0], desc); + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_delete_all.trace"); +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "mysql_cluster",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); - } - _tabname = argv[optind]; + Ndb::setConnectString(opt_connect_str); // Connect to Ndb Ndb MyNdb(_dbname); @@ -64,13 +75,12 @@ int main(int argc, const char** argv){ // Check if table exists in db int res = NDBT_OK; - for(int i = optind; i<argc; i++){ + for(int i = 0; i<argc; i++){ const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]); if(pTab == NULL){ - ndbout << " Table " << _tabname << " does not exist!" << endl; + ndbout << " Table " << argv[i] << " does not exist!" << endl; return NDBT_ProgramExit(NDBT_WRONGARGS); } - ndbout << "Deleting all from " << argv[i] << "..."; if(clear_table(&MyNdb, pTab) == NDBT_FAILED){ res = NDBT_FAILED; diff --git a/ndb/tools/desc.cpp b/ndb/tools/desc.cpp index 9eed1485a6d..4287a771694 100644 --- a/ndb/tools/desc.cpp +++ b/ndb/tools/desc.cpp @@ -14,40 +14,53 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <getarg.h> +#include <ndb_global.h> +#include <ndb_opts.h> #include <NDBT.hpp> #include <NdbApi.hpp> +NDB_STD_OPTS_VARS; - - -int main(int argc, const char** argv){ - ndb_init(); - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _unqualified = 0; - int _help = 0; - - struct getargs args[] = { - { "unqualified", 'u', arg_flag, &_unqualified, "unqualified", - "Use unqualified table names"}, - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* _dbname = "TEST_DB"; +static int _unqualified = 0; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "unqualified", 'u', "Use unqualified table names", + (gptr*) &_unqualified, (gptr*) &_unqualified, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void usage() +{ char desc[] = "tabname\n"\ "This program list all properties of table(s) in NDB Cluster.\n"\ " ex: desc T1 T2 T4\n"; - - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL ||_help) { - arg_printusage(args, num_args, argv[0], desc); + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_desc.trace"); +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "mysql_cluster",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); - } - _tabname = argv[optind]; + + Ndb::setConnectString(opt_connect_str); Ndb* pMyNdb; pMyNdb = new Ndb(_dbname); @@ -60,7 +73,7 @@ int main(int argc, const char** argv){ ndbout << endl; NdbDictionary::Dictionary * dict = pMyNdb->getDictionary(); - for (int i = optind; i < argc; i++) { + for (int i = 0; i < argc; i++) { NDBT_Table* pTab = (NDBT_Table*)dict->getTable(argv[i]); if (pTab != 0){ ndbout << (* pTab) << endl; diff --git a/ndb/tools/drop_index.cpp b/ndb/tools/drop_index.cpp index 70c29461c23..2fcba41bd11 100644 --- a/ndb/tools/drop_index.cpp +++ b/ndb/tools/drop_index.cpp @@ -15,38 +15,53 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> +#include <ndb_opts.h> #include <NdbOut.hpp> #include <NdbApi.hpp> #include <NDBT.hpp> -#include <getarg.h> +NDB_STD_OPTS_VARS; -int main(int argc, const char** argv){ - ndb_init(); - - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _help = 0; - - struct getargs args[] = { - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* _dbname = "TEST_DB"; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void usage() +{ char desc[] = "<indexname>+\n"\ "This program will drop index(es) in Ndb\n"; + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_drop_index.trace"); +} - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help){ - arg_printusage(args, num_args, argv[0], desc); +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "mysql_cluster",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + if (argc < 1) { + usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } - _tabname = argv[optind]; + Ndb::setConnectString(opt_connect_str); // Connect to Ndb Ndb MyNdb(_dbname); if(MyNdb.init() != 0){ @@ -58,7 +73,7 @@ int main(int argc, const char** argv){ ndbout << "Waiting for ndb to become ready..." << endl; int res = 0; - for(int i = optind; i<argc; i++){ + for(int i = 0; i<argc; i++){ ndbout << "Dropping index " << argv[i] << "..."; int tmp; if((tmp = MyNdb.getDictionary()->dropIndex(argv[i], 0)) != 0){ diff --git a/ndb/tools/drop_tab.cpp b/ndb/tools/drop_tab.cpp index 15c229cb0fb..091db5cc4b7 100644 --- a/ndb/tools/drop_tab.cpp +++ b/ndb/tools/drop_tab.cpp @@ -15,43 +15,53 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> +#include <ndb_opts.h> #include <NdbOut.hpp> #include <NdbApi.hpp> #include <NDBT.hpp> -#include <getarg.h> +NDB_STD_OPTS_VARS; -int main(int argc, const char** argv){ - ndb_init(); - - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - const char* _connectstr = NULL; - int _help = 0; - - struct getargs args[] = { - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "connstr", 'c', arg_string, &_connectstr, "connect string", - "How to connect to NDB"}, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* _dbname = "TEST_DB"; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void usage() +{ char desc[] = "tabname\n"\ "This program will drop one table in Ndb\n"; + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_drop_table.trace"); +} - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help){ - arg_printusage(args, num_args, argv[0], desc); +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "mysql_cluster",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + if (argc < 1) { + usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } - _tabname = argv[optind]; - - if (_connectstr) - Ndb::setConnectString(_connectstr); + + Ndb::setConnectString(opt_connect_str); Ndb MyNdb(_dbname); if(MyNdb.init() != 0){ ERR(MyNdb.getNdbError()); @@ -62,7 +72,7 @@ int main(int argc, const char** argv){ ndbout << "Waiting for ndb to become ready..." << endl; int res = 0; - for(int i = optind; i<argc; i++){ + for(int i = 0; i<argc; i++){ ndbout << "Dropping table " << argv[i] << "..."; int tmp; if((tmp = MyNdb.getDictionary()->dropTable(argv[i])) != 0){ diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp index 4fc5bcd7f21..064ec299ef9 100644 --- a/ndb/tools/listTables.cpp +++ b/ndb/tools/listTables.cpp @@ -22,7 +22,7 @@ */ #include <ndb_global.h> -#include <getarg.h> +#include <ndb_opts.h> #include <NdbApi.hpp> #include <NDBT.hpp> @@ -161,63 +161,65 @@ list(const char * tabname, } } -#ifndef DBUG_OFF -const char *debug_option= 0; -#endif +NDB_STD_OPTS_VARS; -int main(int argc, const char** argv){ - ndb_init(); - int _loops = 1; - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _type = 0; - int _help = 0; - const char* _connect_str = NULL; - - struct getargs args[] = { - { "loops", 'l', arg_integer, &_loops, "loops", - "Number of times to run(default = 1)" }, - { "unqualified", 'u', arg_flag, &_unqualified, "unqualified", - "Use unqualified table names"}, - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "type", 't', arg_integer, &_type, "type", - "Type of objects to show, see NdbDictionary.hpp for numbers(default = 0)" }, - { "connect-string", 'c', arg_string, &_connect_str, - "Set connect string for connecting to ndb_mgmd. <constr>=\"host=<hostname:port>[;nodeid=<id>]\". Overides specifying entries in NDB_CONNECTSTRING and config file", - "<constr>" }, -#ifndef DBUG_OFF - { "debug", 0, arg_string, &debug_option, - "Specify debug options e.g. d:t:i:o,out.trace", "options" }, -#endif - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +static const char* _dbname = "TEST_DB"; +static int _loops; +static int _type; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_show_tables"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "loops", 'l', "loops", + (gptr*) &_loops, (gptr*) &_loops, 0, + GET_INT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0 }, + { "type", 't', "type", + (gptr*) &_type, (gptr*) &_type, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "unqualified", 'u', "Use unqualified table names", + (gptr*) &_unqualified, (gptr*) &_unqualified, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void usage() +{ char desc[] = "tabname\n"\ "This program list all system objects in NDB Cluster.\n"\ "Type of objects to display can be limited with -t option\n"\ - " ex: list_tables -t 2 would show all UserTables\n"\ + " ex: ndb_show_tables -t 2 would show all UserTables\n"\ "To show all indexes for a table write table name as final argument\n"\ - " ex: list_tables T1\n"; - - if(getarg(args, num_args, argc, argv, &optind) || _help) { - arg_printusage(args, num_args, argv[0], desc); + " ex: ndb_show_tables T1\n"; + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_show_tables.trace"); +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char* _tabname; + const char *load_default_groups[]= { "mysql_cluster",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); - } - _tabname = argv[optind]; - -#ifndef DBUG_OFF - if (debug_option) - DBUG_PUSH(debug_option); -#endif + _tabname = argv[0]; - ndb_cluster_connection = new Ndb_cluster_connection(_connect_str); + ndb_cluster_connection = new Ndb_cluster_connection(opt_connect_str); + if (ndb_cluster_connection->connect(12,5,1)) + fatal("unable to connect"); ndb = new Ndb(ndb_cluster_connection, _dbname); if (ndb->init() != 0) fatal("init"); - ndb_cluster_connection->connect(); if (ndb->waitUntilReady(30) < 0) fatal("waitUntilReady"); dic = ndb->getDictionary(); diff --git a/ndb/tools/ndb_test_platform.cpp b/ndb/tools/ndb_test_platform.cpp new file mode 100644 index 00000000000..72dd146dacd --- /dev/null +++ b/ndb/tools/ndb_test_platform.cpp @@ -0,0 +1,95 @@ +/* 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 <my_sys.h> +#include <BaseString.hpp> + +/* + * Test BaseString::snprintf + */ + +static +int test_snprintf(const char * fmt, int buf_sz, int result) +{ + int ret; + char buf[100]; + ret = BaseString::snprintf(buf, buf_sz, fmt); + + if(ret < 0) + { + printf("BaseString::snprint returns %d with size=%d and strlen(fmt)=%d\n", + ret, buf_sz, strlen(fmt)); + return -1; + } + + if(ret+1 == buf_sz) + { + printf("BaseString::snprint truncates returns %d with size=%d and strlen(fmt)=%d\n", + ret, buf_sz, strlen(fmt)); + return -1; + } + + if(ret != result) + { + printf("BaseString::snprint returns incorrect value: returned=%d != expected=%d\n", + ret, result); + return -1; + } + + for(ret = 0; ret+1 < buf_sz && ret < result; ret++) + { + if(buf[ret] != fmt[ret]) + { + printf("BaseString::snprint Incorrect value in output buffer: " + "size=%d returned=expected=%d at pos=%d result=%d != expected=%d\n", + buf_sz, result, ret, buf[ret], fmt[ret]); + return -1; + } + } + return 0; +} + +int +main(void) +{ + /* + * Test BaseString::snprintf + */ + + if(test_snprintf("test", 1, 4)) + return -1; + + if(test_snprintf("test", 0, 4)) + return -1; + + if(test_snprintf("test", 100, 4)) + return -1; + + /* + * Test UintPtr + */ + + if (sizeof(UintPtr) != sizeof(Uint32*)) + { + printf("sizeof(UintPtr)=%d != sizeof(Uint32*)=%d\n", + sizeof(UintPtr), sizeof(Uint32*)); + return -1; + } + + return 0; +} diff --git a/ndb/src/kernel/blocks/backup/restore/Restore.cpp b/ndb/tools/restore/Restore.cpp index fb3bde6bdef..fa616ee8fee 100644 --- a/ndb/src/kernel/blocks/backup/restore/Restore.cpp +++ b/ndb/tools/restore/Restore.cpp @@ -15,7 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "Restore.hpp" -#include "BackupFormat.hpp" #include <NdbTCP.h> #include <OutputStream.hpp> #include <Bitmask.hpp> @@ -25,9 +24,6 @@ #include <SimpleProperties.hpp> #include <signaldata/DictTabInfo.hpp> -// from src/ndbapi -#include <NdbDictionaryImpl.hpp> - Uint16 Twiddle16(Uint16 in); // Byte shift 16-bit data Uint32 Twiddle32(Uint32 in); // Byte shift 32-bit data Uint64 Twiddle64(Uint64 in); // Byte shift 64-bit data @@ -196,14 +192,15 @@ RestoreMetaData::readGCPEntry() { return true; } -TableS::TableS(NdbTableImpl* tableImpl) +TableS::TableS(Uint32 version, NdbTableImpl* tableImpl) : m_dictTable(tableImpl) { m_dictTable = tableImpl; m_noOfNullable = m_nullBitmaskSize = 0; m_auto_val_id= ~(Uint32)0; m_max_auto_val= 0; - + backupVersion = version; + for (int i = 0; i < tableImpl->getNoOfColumns(); i++) createAttr(tableImpl->getColumn(i)); } @@ -230,11 +227,10 @@ RestoreMetaData::parseTableDescriptor(const Uint32 * data, Uint32 len) debug << "parseTableInfo " << tableImpl->getName() << " done" << endl; - TableS * table = new TableS(tableImpl); + TableS * table = new TableS(m_fileHeader.NdbVersion, tableImpl); if(table == NULL) { return false; } - table->setBackupVersion(m_fileHeader.NdbVersion); debug << "Parsed table id " << table->getTableId() << endl; debug << "Parsed table #attr " << table->getNoOfAttributes() << endl; @@ -264,16 +260,16 @@ TupleS & TupleS::operator=(const TupleS& tuple) memcpy(allAttrData, tuple.allAttrData, getNoOfAttributes()*sizeof(AttributeData)); return *this; -}; +} int TupleS::getNoOfAttributes() const { if (m_currentTable == 0) return 0; return m_currentTable->getNoOfAttributes(); -}; +} TableS * TupleS::getTable() const { return m_currentTable; -}; +} const AttributeDesc * TupleS::getDesc(int i) const { return m_currentTable->allAttributesDesc[i]; @@ -281,7 +277,7 @@ const AttributeDesc * TupleS::getDesc(int i) const { AttributeData * TupleS::getData(int i) const{ return &(allAttrData[i]); -}; +} bool TupleS::prepareRecord(TableS & tab){ @@ -703,12 +699,12 @@ void TableS::createAttr(NdbDictionary::Column *column) if (d->m_column->getAutoIncrement()) m_auto_val_id= d->attrId; - if(d->m_column->getPrimaryKey() /* && not variable */) + if(d->m_column->getPrimaryKey() && backupVersion <= MAKE_VERSION(4,1,7)) { m_fixedKeys.push_back(d); return; } - + if(!d->m_column->getNullable()) { m_fixedAttribs.push_back(d); diff --git a/ndb/src/kernel/blocks/backup/restore/Restore.hpp b/ndb/tools/restore/Restore.hpp index 0ec1ab852e9..d7f6e3b7799 100644 --- a/ndb/src/kernel/blocks/backup/restore/Restore.hpp +++ b/ndb/tools/restore/Restore.hpp @@ -19,7 +19,8 @@ #include <ndb_global.h> #include <NdbOut.hpp> -#include <BackupFormat.hpp> +#include "../src/kernel/blocks/backup/BackupFormat.hpp" +#include "../src/ndbapi/NdbDictionaryImpl.hpp" #include <NdbApi.hpp> #include <ndb_version.h> @@ -139,7 +140,7 @@ class TableS { public: class NdbDictionary::Table* m_dictTable; - TableS (class NdbTableImpl* dictTable); + TableS (Uint32 version, class NdbTableImpl* dictTable); ~TableS(); Uint32 getTableId() const { @@ -186,28 +187,33 @@ public: }; void update_max_auto_val(const char *data, int size) { - Uint64 val= 0; + union { + Uint8 u8; + Uint16 u16; + Uint32 u32; + } val; + Uint64 v; switch(size){ - case 8: - val= *(Uint8*)data; - break; - case 16: - val= *(Uint16*)data; - break; - case 24: - val= (0xffffff)&*(Uint32*)data; + case 64: + memcpy(&v,data,8); break; case 32: - val= *(Uint32*)data; + memcpy(&val.u32,data,4); + v= val.u32; break; - case 64: - val= *(Uint64*)data; + case 16: + memcpy(&val.u16,data,2); + v= val.u16; + break; + case 8: + memcpy(&val.u8,data,1); + v= val.u8; break; default: return; }; - if(val > m_max_auto_val) - m_max_auto_val= val; + if(v > m_max_auto_val) + m_max_auto_val= v; }; /** * Get attribute descriptor diff --git a/ndb/src/kernel/blocks/backup/restore/consumer.cpp b/ndb/tools/restore/consumer.cpp index e94c31b2666..ecbdbbf8f4e 100644 --- a/ndb/src/kernel/blocks/backup/restore/consumer.cpp +++ b/ndb/tools/restore/consumer.cpp @@ -44,9 +44,12 @@ BackupConsumer::create_table_string(const TableS & table, case NdbDictionary::Column::Float: pos += sprintf(buf+pos, "%s", "float"); break; - case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Olddecimal: pos += sprintf(buf+pos, "%s", "decimal"); break; + case NdbDictionary::Column::Olddecimalunsigned: + pos += sprintf(buf+pos, "%s", "decimal unsigned"); + break; case NdbDictionary::Column::Char: pos += sprintf(buf+pos, "%s", "char"); break; @@ -71,7 +74,10 @@ BackupConsumer::create_table_string(const TableS & table, case NdbDictionary::Column::Datetime: pos += sprintf(buf+pos, "%s", "datetime"); break; - case NdbDictionary::Column::Timespec: + case NdbDictionary::Column::Date: + pos += sprintf(buf+pos, "%s", "date"); + break; + case NdbDictionary::Column::Time: pos += sprintf(buf+pos, "%s", "time"); break; case NdbDictionary::Column::Undefined: diff --git a/ndb/src/kernel/blocks/backup/restore/consumer.hpp b/ndb/tools/restore/consumer.hpp index 692c814159f..692c814159f 100644 --- a/ndb/src/kernel/blocks/backup/restore/consumer.hpp +++ b/ndb/tools/restore/consumer.hpp diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_printer.cpp b/ndb/tools/restore/consumer_printer.cpp index 0aa5b521d29..0aa5b521d29 100644 --- a/ndb/src/kernel/blocks/backup/restore/consumer_printer.cpp +++ b/ndb/tools/restore/consumer_printer.cpp diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_printer.hpp b/ndb/tools/restore/consumer_printer.hpp index 7cbc924e364..7cbc924e364 100644 --- a/ndb/src/kernel/blocks/backup/restore/consumer_printer.hpp +++ b/ndb/tools/restore/consumer_printer.hpp diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp index a35d9d22c65..fbe96cb2a71 100644 --- a/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp +++ b/ndb/tools/restore/consumer_restore.cpp @@ -16,7 +16,6 @@ #include "consumer_restore.hpp" #include <NdbSleep.h> -#include <NdbDictionaryImpl.hpp> extern FilteredNdbOut err; extern FilteredNdbOut info; @@ -53,19 +52,10 @@ BackupRestore::init() return false; } - m_tuples = new TupleS[m_parallelism]; - - if (m_tuples == 0) - { - err << "Failed to allocate tuples" << endl; - return false; - } - m_free_callback= m_callback; for (Uint32 i= 0; i < m_parallelism; i++) { m_callback[i].restore= this; m_callback[i].connection= 0; - m_callback[i].tup= &m_tuples[i]; if (i > 0) m_callback[i-1].next= &(m_callback[i]); } @@ -87,12 +77,6 @@ void BackupRestore::release() delete [] m_callback; m_callback= 0; } - - if (m_tuples) - { - delete [] m_tuples; - m_tuples= 0; - } } BackupRestore::~BackupRestore() @@ -119,14 +103,21 @@ BackupRestore::get_table(const NdbDictionary::Table* tab){ m_cache.m_old_table = tab; int cnt, id1, id2; - char buf[256]; - if((cnt = sscanf(tab->getName(), "%[^/]/%[^/]/NDB$BLOB_%d_%d", buf, buf, &id1, &id2)) == 4){ - BaseString::snprintf(buf, sizeof(buf), "NDB$BLOB_%d_%d", m_new_tables[id1]->getTableId(), id2); - m_cache.m_new_table = m_ndb->getDictionary()->getTable(buf); + char db[256], schema[256]; + if((cnt = sscanf(tab->getName(), "%[^/]/%[^/]/NDB$BLOB_%d_%d", + db, schema, &id1, &id2)) == 4){ + m_ndb->setDatabaseName(db); + m_ndb->setSchemaName(schema); + + BaseString::snprintf(db, sizeof(db), "NDB$BLOB_%d_%d", + m_new_tables[id1]->getTableId(), id2); + + m_cache.m_new_table = m_ndb->getDictionary()->getTable(db); + } else { m_cache.m_new_table = m_new_tables[tab->getTableId()]; } - + assert(m_cache.m_new_table); return m_cache.m_new_table; } @@ -267,22 +258,24 @@ void BackupRestore::tuple(const TupleS & tup) if (!m_restore) return; + while (m_free_callback == 0) + { + assert(m_transactions == m_parallelism); + // send-poll all transactions + // close transaction is done in callback + m_ndb->sendPollNdb(3000, 1); + } + restore_callback_t * cb = m_free_callback; - + if (cb == 0) assert(false); - + m_free_callback = cb->next; cb->retries = 0; - *(cb->tup) = tup; // must do copy! + cb->tup = tup; // must do copy! tuple_a(cb); - if (m_free_callback == 0) - { - // send-poll all transactions - // close transaction is done in callback - m_ndb->sendPollNdb(3000, 1); - } } void BackupRestore::tuple_a(restore_callback_t *cb) @@ -304,7 +297,7 @@ void BackupRestore::tuple_a(restore_callback_t *cb) exitHandler(); } // if - const TupleS &tup = *(cb->tup); + const TupleS &tup = cb->tup; const NdbDictionary::Table * table = get_table(tup.getTable()->m_dictTable); NdbOperation * op = cb->connection->getNdbOperation(table); @@ -373,7 +366,9 @@ void BackupRestore::tuple_a(restore_callback_t *cb) m_transactions++; return; } - err << "Unable to recover from errors. Exiting..." << endl; + err << "Retried transaction " << cb->retries << " times.\nLast error" + << m_ndb->getNdbError(cb->error_code) << endl + << "...Unable to recover from errors. Exiting..." << endl; exitHandler(); } @@ -417,16 +412,21 @@ bool BackupRestore::errorHandler(restore_callback_t *cb) NdbError error= cb->connection->getNdbError(); m_ndb->closeTransaction(cb->connection); cb->connection= 0; + + Uint32 sleepTime = 100 + cb->retries * 300; + cb->retries++; + cb->error_code = error.code; + switch(error.status) { case NdbError::Success: - return false; - // ERROR! - break; - + return false; + // ERROR! + break; + case NdbError::TemporaryError: - NdbSleep_MilliSleep(10); + NdbSleep_MilliSleep(sleepTime); return true; // RETRY break; @@ -439,15 +439,6 @@ bool BackupRestore::errorHandler(restore_callback_t *cb) default: case NdbError::PermanentError: - switch (error.code) - { - case 499: - case 250: - NdbSleep_MilliSleep(10); - return true; //temp errors? - default: - break; - } //ERROR err << error << endl; return false; @@ -469,13 +460,10 @@ BackupRestore::tuple_free() if (!m_restore) return; - if (m_transactions > 0) { - // Send all transactions to NDB - m_ndb->sendPreparedTransactions(0); - - // Poll all transactions - while (m_transactions > 0) - m_ndb->pollNdb(3000, m_transactions); + // Poll all transactions + while (m_transactions) + { + m_ndb->sendPollNdb(3000); } } diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restore.hpp b/ndb/tools/restore/consumer_restore.hpp index 59e2734ea1f..df219cd4412 100644 --- a/ndb/src/kernel/blocks/backup/restore/consumer_restore.hpp +++ b/ndb/tools/restore/consumer_restore.hpp @@ -21,9 +21,10 @@ struct restore_callback_t { class BackupRestore *restore; - class TupleS *tup; + class TupleS tup; class NdbConnection *connection; int retries; + int error_code; restore_callback_t *next; }; @@ -39,7 +40,6 @@ public: m_restore_meta = false; m_parallelism = parallelism; m_callback = 0; - m_tuples = 0; m_free_callback = 0; m_transactions = 0; m_cache.m_old_table = 0; @@ -68,9 +68,8 @@ public: Uint32 m_dataCount; Uint32 m_parallelism; - Uint32 m_transactions; + volatile Uint32 m_transactions; - TupleS *m_tuples; restore_callback_t *m_callback; restore_callback_t *m_free_callback; diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restorem.cpp b/ndb/tools/restore/consumer_restorem.cpp index 6a9ec07148a..6a9ec07148a 100644 --- a/ndb/src/kernel/blocks/backup/restore/consumer_restorem.cpp +++ b/ndb/tools/restore/consumer_restorem.cpp diff --git a/ndb/src/kernel/blocks/backup/restore/main.cpp b/ndb/tools/restore/restore_main.cpp index f7b1479cc93..84f9511fe2f 100644 --- a/ndb/src/kernel/blocks/backup/restore/main.cpp +++ b/ndb/tools/restore/restore_main.cpp @@ -14,7 +14,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <getarg.h> +#include <ndb_global.h> +#include <ndb_opts.h> #include <Vector.hpp> #include <ndb_limits.h> #include <NdbTCP.h> @@ -35,80 +36,107 @@ static Vector<class BackupConsumer *> g_consumers; static const char* ga_backupPath = "." DIR_SEPARATOR; -static const char* ga_connect_NDB = NULL; +NDB_STD_OPTS_VARS; /** * print and restore flags */ static bool ga_restore = false; static bool ga_print = false; +static int _print = 0; +static int _print_meta = 0; +static int _print_data = 0; +static int _print_log = 0; +static int _restore_data = 0; +static int _restore_meta = 0; + +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_restore"), + { "connect", 'c', "same as --connect-string", + (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "nodeid", 'n', "Backup files from node with id", + (gptr*) &ga_nodeId, (gptr*) &ga_nodeId, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "backupid", 'b', "Backup id", + (gptr*) &ga_backupId, (gptr*) &ga_backupId, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "restore_data", 'r', + "Restore table data/logs into NDB Cluster using NDBAPI", + (gptr*) &_restore_data, (gptr*) &_restore_data, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "restore_meta", 'm', + "Restore meta data into NDB Cluster using NDBAPI", + (gptr*) &_restore_meta, (gptr*) &_restore_meta, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "parallelism", 'p', + "No of parallel transactions during restore of data." + "(parallelism can be 1 to 1024)", + (gptr*) &ga_nParallelism, (gptr*) &ga_nParallelism, 0, + GET_INT, REQUIRED_ARG, 128, 1, 1024, 0, 1, 0 }, + { "print", 256, "Print data and log to stdout", + (gptr*) &_print, (gptr*) &_print, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "print_data", 257, "Print data to stdout", + (gptr*) &_print_data, (gptr*) &_print_data, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "print_meta", 258, "Print meta data to stdout", + (gptr*) &_print_meta, (gptr*) &_print_meta, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "print_log", 259, "Print log to stdout", + (gptr*) &_print_log, (gptr*) &_print_log, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "dont_ignore_systab_0", 'f', + "Experimental. Do not ignore system table during restore.", + (gptr*) &ga_dont_ignore_systab_0, (gptr*) &ga_dont_ignore_systab_0, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; + +static void short_usage_sub(void) +{ + printf("Usage: %s [OPTIONS] [<path to backup files>]\n", my_progname); +} +static void usage() +{ + short_usage_sub(); + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_restore.trace"); + switch (optid) { + case 'n': + if (ga_nodeId == 0) + { + printf("Error in --nodeid,-n setting, see --help\n"); + exit(1); + } + break; + case 'b': + if (ga_backupId == 0) + { + printf("Error in --backupid,-b setting, see --help\n"); + exit(1); + } + break; + } + return 0; +} bool -readArguments(const int argc, const char** argv) +readArguments(int *pargc, char*** pargv) { - - int _print = 0; - int _print_meta = 0; - int _print_data = 0; - int _print_log = 0; - int _restore_data = 0; - int _restore_meta = 0; - - - struct getargs args[] = - { - { "connect", 'c', arg_string, &ga_connect_NDB, - "NDB Cluster connection", "\"nodeid=<api id>;host=<hostname:port>\""}, - { "nodeid", 'n', arg_integer, &ga_nodeId, - "Backup files from node", "db node id"}, - { "backupid", 'b',arg_integer, &ga_backupId, "Backup id", "backup id"}, - { "print", '\0', arg_flag, &_print, - "Print data and log to stdout", "print data and log"}, - { "print_data", '\0', arg_flag, &_print_data, - "Print data to stdout", "print data"}, - { "print_meta", '\0', arg_flag, &_print_meta, - "Print meta data to stdout", "print meta data"}, - { "print_log", '\0', arg_flag, &_print_log, - "Print log to stdout", "print log"}, - { "restore_data", 'r', arg_flag, &_restore_data, - "Restore table data/logs into NDB Cluster using NDBAPI", - "Restore table data/log"}, - { "restore_meta", 'm', arg_flag, &_restore_meta, - "Restore meta data into NDB Cluster using NDBAPI", "Restore meta data"}, - { "parallelism", 'p', arg_integer, &ga_nParallelism, - "No of parallel transactions during restore of data." - "(parallelism can be 1 to 1024)", - "Parallelism"}, -#ifdef USE_MYSQL - { "use_mysql", '\0', arg_flag, &use_mysql, - "Restore meta data via mysql. Systab will be ignored. Data is restored " - "using NDBAPI.", "use mysql"}, - { "user", '\0', arg_string, &ga_user, "MySQL user", "Default: root"}, - { "password", '\0', arg_string, &ga_password, "MySQL user's password", - "Default: \"\" "}, - { "host", '\0', arg_string, &ga_host, "Hostname of MySQL server", - "Default: localhost"}, - { "socket", '\0', arg_string, &ga_socket, "Path to MySQL server socket file", - "Default: /tmp/mysql.sock"}, - { "port", '\0', arg_integer, &ga_port, "Port number of MySQL server", - "Default: 3306"}, -#endif - { "dont_ignore_systab_0", 'f', arg_flag, &ga_dont_ignore_systab_0, - "Experimental. Do not ignore system table during restore.", - "dont_ignore_systab_0"} - - }; - - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; - - if (getarg(args, num_args, argc, argv, &optind) || - ga_nodeId == 0 || - ga_backupId == 0 || - ga_nParallelism < 1 || - ga_nParallelism >1024) + const char *load_default_groups[]= { "mysql_cluster","ndb_restore",0 }; + load_defaults("my",load_default_groups,pargc,pargv); + if (handle_options(pargc, pargv, my_long_options, get_one_option)) { - arg_printusage(args, num_args, argv[0], "<path to backup files>\n"); - return false; + exit(1); } BackupPrinter* printer = new BackupPrinter(); @@ -122,10 +150,6 @@ readArguments(const int argc, const char** argv) return false; } - /** - * Got segmentation fault when using the printer's attributes directly - * in getargs... Do not have the time to found out why... this is faster... - */ if (_print) { ga_print = true; @@ -169,15 +193,14 @@ readArguments(const int argc, const char** argv) g_consumers.push_back(c); } // Set backup file path - if (argv[optind] != NULL) + if (*pargv[0] != NULL) { - ga_backupPath = argv[optind]; + ga_backupPath = *pargv[0]; } return true; } - void clearConsumers() { @@ -204,19 +227,16 @@ free_data_callback() } int -main(int argc, const char** argv) +main(int argc, char** argv) { - ndb_init(); - if (!readArguments(argc, argv)) + NDB_INIT(argv[0]); + + if (!readArguments(&argc, &argv)) { return -1; } - if (ga_connect_NDB != NULL) - { - // Use connection string - Ndb::setConnectString(ga_connect_NDB); - } + Ndb::setConnectString(opt_connect_str); /** * we must always load meta data, even if we will only print it to stdout @@ -227,11 +247,18 @@ main(int argc, const char** argv) ndbout << "Failed to read " << metaData.getFilename() << endl << endl; return -1; } + + const BackupFormat::FileHeader & tmp = metaData.getFileHeader(); + const Uint32 version = tmp.NdbVersion; + + ndbout << "Ndb version in backup files: " + << getVersionString(version, 0) << endl; + /** * check wheater we can restore the backup (right version). */ int res = metaData.loadContent(); - + if (res == 0) { ndbout_c("Restore: Failed to load content"); @@ -323,7 +350,8 @@ main(int argc, const char** argv) if (res < 0) { - err << "Restore: An error occured while restoring data. Exiting... res=" << res << endl; + err << "Restore: An error occured while restoring data. Exiting... " + << "res=" << res << endl; return -1; } @@ -349,7 +377,8 @@ main(int argc, const char** argv) } if (res < 0) { - err << "Restore: An restoring the data log. Exiting... res=" << res << endl; + err << "Restore: An restoring the data log. Exiting... res=" + << res << endl; return -1; } logIter.validateFooter(); //not implemented diff --git a/ndb/tools/select_all.cpp b/ndb/tools/select_all.cpp index 9f8108d9f32..23fd2290349 100644 --- a/ndb/tools/select_all.cpp +++ b/ndb/tools/select_all.cpp @@ -16,6 +16,7 @@ #include <ndb_global.h> +#include <ndb_opts.h> #include <NdbOut.hpp> @@ -23,13 +24,8 @@ #include <NdbMain.h> #include <NDBT.hpp> #include <NdbSleep.h> -#include <getarg.h> #include <NdbScanFilter.hpp> -#ifndef DBUG_OFF -const char *debug_option= 0; -#endif - int scanReadRecords(Ndb*, const NdbDictionary::Table*, const NdbDictionary::Index*, @@ -40,39 +36,41 @@ int scanReadRecords(Ndb*, char delim, bool orderby); -int main(int argc, const char** argv){ - ndb_init(); - int _parallelism = 240; - const char* _delimiter = "\t"; - int _header = true; - int _useHexFormat = false; - const char* _tabname = NULL; - const char* _dbname = "TEST_DB"; - int _help = 0; - int _lock = 0; - int _order = 0; - - struct getargs args[] = { - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "parallelism", 'p', arg_integer, &_parallelism, "parallelism", - "parallelism" }, - { "header", 'h', arg_flag, &_header, "Print header", "header" }, - { "useHexFormat", 'x', arg_flag, &_useHexFormat, - "Output numbers in hexadecimal format", "useHexFormat" }, - { "delimiter", 'd', arg_string, &_delimiter, "Column delimiter", - "delimiter" }, -#ifndef DBUG_OFF - { "debug", 0, arg_string, &debug_option, - "Specify debug options e.g. d:t:i:o,out.trace", "options" }, -#endif - { "usage", '?', arg_flag, &_help, "Print help", "" }, - { "lock", 'l', arg_integer, &_lock, - "Read(0), Read-hold(1), Exclusive(2)", "lock"}, - { "order", 'o', arg_flag, &_order, "Sort resultset according to index", ""} - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +NDB_STD_OPTS_VARS; + +static const char* _dbname = "TEST_DB"; +static const char* _delimiter = "\t"; +static int _unqualified, _header, _parallelism, _useHexFormat, _lock, + _order; + +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "parallelism", 'p', "parallelism", + (gptr*) &_parallelism, (gptr*) &_parallelism, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)", + (gptr*) &_lock, (gptr*) &_lock, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "order", 'o', "Sort resultset according to index", + (gptr*) &_order, (gptr*) &_order, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "header", 'h', "Print header", + (gptr*) &_header, (gptr*) &_header, 0, + GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, + { "useHexFormat", 'x', "Output numbers in hexadecimal format", + (gptr*) &_useHexFormat, (gptr*) &_useHexFormat, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "delimiter", 'D', "Column delimiter", + (gptr*) &_delimiter, (gptr*) &_delimiter, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void usage() +{ char desc[] = "tabname\n"\ "This program reads all records from one table in NDB Cluster\n"\ @@ -80,19 +78,32 @@ int main(int argc, const char** argv){ "(It only print error messages if it encounters a permanent error.)\n"\ "It can also be used to dump the content of a table to file \n"\ " ex: select_all --no-header --delimiter=';' T4 > T4.data\n"; - - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help) { - arg_printusage(args, num_args, argv[0], desc); + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_select_all.trace"); +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "mysql_cluster",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + const char* _tabname; + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + if ((_tabname = argv[0]) == 0) { + usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } - _tabname = argv[optind]; - -#ifndef DBUG_OFF - if (debug_option) - DBUG_PUSH(debug_option); -#endif + Ndb::setConnectString(opt_connect_str); // Connect to Ndb Ndb MyNdb(_dbname); @@ -108,14 +119,19 @@ int main(int argc, const char** argv){ // Check if table exists in db const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname); const NdbDictionary::Index * pIdx = 0; - if(optind+1 < argc){ - pIdx = MyNdb.getDictionary()->getIndex(argv[optind+1], _tabname); + if(argc > 1){ + pIdx = MyNdb.getDictionary()->getIndex(argv[1], _tabname); } if(pTab == NULL){ ndbout << " Table " << _tabname << " does not exist!" << endl; return NDBT_ProgramExit(NDBT_WRONGARGS); } + + if(argc > 1 && pIdx == 0) + { + ndbout << " Index " << argv[1] << " does not exists" << endl; + } if(_order && pIdx == NULL){ ndbout << " Order flag given without an index" << endl; diff --git a/ndb/tools/select_count.cpp b/ndb/tools/select_count.cpp index 6650421e637..a9a3e71da67 100644 --- a/ndb/tools/select_count.cpp +++ b/ndb/tools/select_count.cpp @@ -16,6 +16,7 @@ #include <ndb_global.h> +#include <ndb_opts.h> #include <NdbOut.hpp> @@ -23,7 +24,6 @@ #include <NdbMain.h> #include <NDBT.hpp> #include <NdbSleep.h> -#include <getarg.h> #include <UtilTransactions.hpp> static int @@ -32,34 +32,55 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, int* count_rows, UtilTransactions::ScanLock lock); -int main(int argc, const char** argv){ - ndb_init(); - const char* _dbname = "TEST_DB"; - int _parallelism = 240; - int _help = 0; - int _lock = 0; - - struct getargs args[] = { - { "database", 'd', arg_string, &_dbname, "dbname", - "Name of database table is in"}, - { "parallelism", 's', arg_integer, &_parallelism, "parallelism", "parallelism" }, - { "usage", '?', arg_flag, &_help, "Print help", "" }, - { "lock", 'l', arg_integer, &_lock, - "Read(0), Read-hold(1), Exclusive(2)", "lock"} - - }; - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; +NDB_STD_OPTS_VARS; + +static const char* _dbname = "TEST_DB"; +static int _parallelism = 240; +static int _lock = 0; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "database", 'd', "Name of database table is in", + (gptr*) &_dbname, (gptr*) &_dbname, 0, + GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { "parallelism", 'p', "parallelism", + (gptr*) &_parallelism, (gptr*) &_parallelism, 0, + GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 }, + { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)", + (gptr*) &_lock, (gptr*) &_lock, 0, + GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; +static void usage() +{ char desc[] = "tabname1 ... tabnameN\n"\ "This program will count the number of records in tables\n"; - - if(getarg(args, num_args, argc, argv, &optind) || - argv[optind] == NULL || _help) { - arg_printusage(args, num_args, argv[0], desc); + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_select_count.trace"); +} + +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "mysql_cluster",0 }; + load_defaults("my",load_default_groups,&argc,&argv); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) + return NDBT_ProgramExit(NDBT_WRONGARGS); + if (argc < 1) { + usage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } + Ndb::setConnectString(opt_connect_str); // Connect to Ndb Ndb MyNdb(_dbname); @@ -72,7 +93,7 @@ int main(int argc, const char** argv){ while(MyNdb.waitUntilReady() != 0) ndbout << "Waiting for ndb to become ready..." << endl; - for(int i = optind; i<argc; i++){ + for(int i = 0; i<argc; i++){ // Check if table exists in db const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]); if(pTab == NULL){ diff --git a/ndb/tools/waiter.cpp b/ndb/tools/waiter.cpp index c01a3f9192e..cc6a21428c8 100644 --- a/ndb/tools/waiter.cpp +++ b/ndb/tools/waiter.cpp @@ -16,88 +16,89 @@ #include <ndb_global.h> +#include <ndb_opts.h> + #include <mgmapi.h> #include <NdbMain.h> #include <NdbOut.hpp> #include <NdbSleep.h> -#include <getarg.h> #include <kernel/ndb_limits.h> -#include "../include/mgmcommon/LocalConfig.hpp" #include <NDBT.hpp> int -waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, unsigned int _timeout); +waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, + unsigned int _timeout); + +enum ndb_waiter_options { + OPT_WAIT_STATUS_NOT_STARTED = NDB_STD_OPTIONS_LAST +}; +NDB_STD_OPTS_VARS; + +static int _no_contact = 0; +static int _not_started = 0; +static int _timeout = 120; +static struct my_option my_long_options[] = +{ + NDB_STD_OPTS("ndb_desc"), + { "no-contact", 'n', "Wait for cluster no contact", + (gptr*) &_no_contact, (gptr*) &_no_contact, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "not-started", OPT_WAIT_STATUS_NOT_STARTED, "Wait for cluster not started", + (gptr*) &_not_started, (gptr*) &_not_started, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, + { "timeout", 't', "Timeout to wait", + (gptr*) &_timeout, (gptr*) &_timeout, 0, + GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 0 }, + { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} +}; + +static void usage() +{ + ndb_std_print_version(); + my_print_help(my_long_options); + my_print_variables(my_long_options); +} -int main(int argc, const char** argv){ - ndb_init(); +static my_bool +get_one_option(int optid, const struct my_option *opt __attribute__((unused)), + char *argument) +{ + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_drop_table.trace"); +} +int main(int argc, char** argv){ + NDB_INIT(argv[0]); + const char *load_default_groups[]= { "mysql_cluster",0 }; + load_defaults("my",load_default_groups,&argc,&argv); const char* _hostName = NULL; - int _no_contact = 0; - int _help = 0; - int _timeout = 120; - - struct getargs args[] = { - { "timeout", 0, arg_integer, &_timeout, "Timeout to wait", "#" }, - { "no-contact", 0, arg_flag, &_no_contact, "Wait for cluster no contact", "" }, - { "usage", '?', arg_flag, &_help, "Print help", "" } - }; - - int num_args = sizeof(args) / sizeof(args[0]); - int optind = 0; - char desc[] = - "hostname:port\n"\ - "This program will connect to the mgmsrv of a NDB cluster.\n"\ - "It will then wait for all nodes to be started\n"; - - if(getarg(args, num_args, argc, argv, &optind) || _help) { - arg_printusage(args, num_args, argv[0], desc); + int ho_error; + if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) return NDBT_ProgramExit(NDBT_WRONGARGS); - } char buf[255]; - _hostName = argv[optind]; - - if (_hostName == NULL){ - LocalConfig lcfg; - if(!lcfg.init()) - { - lcfg.printError(); - lcfg.printUsage(); - g_err << "Error parsing local config file" << endl; - return NDBT_ProgramExit(NDBT_FAILED); - } + _hostName = argv[0]; - for (unsigned i = 0; i<lcfg.ids.size();i++) - { - MgmtSrvrId * m = &lcfg.ids[i]; - - switch(m->type){ - case MgmId_TCP: - snprintf(buf, 255, "%s:%d", m->name.c_str(), m->port); - _hostName = buf; - break; - case MgmId_File: - break; - default: - break; - } - if (_hostName != NULL) - break; - } - if (_hostName == NULL) - { - g_err << "No management servers configured in local config file" << endl; - return NDBT_ProgramExit(NDBT_FAILED); - } + if (_hostName == 0) + _hostName= opt_connect_str; + + enum ndb_mgm_node_status wait_status; + if (_no_contact) + { + wait_status= NDB_MGM_NODE_STATUS_NO_CONTACT; + } + else if (_not_started) + { + wait_status= NDB_MGM_NODE_STATUS_NOT_STARTED; + } + else + { + wait_status= NDB_MGM_NODE_STATUS_STARTED; } - if (_no_contact) { - if (waitClusterStatus(_hostName, NDB_MGM_NODE_STATUS_NO_CONTACT, _timeout) != 0) - return NDBT_ProgramExit(NDBT_FAILED); - } else if (waitClusterStatus(_hostName, NDB_MGM_NODE_STATUS_STARTED, _timeout) != 0) + if (waitClusterStatus(_hostName, wait_status, _timeout) != 0) return NDBT_ProgramExit(NDBT_FAILED); - return NDBT_ProgramExit(NDBT_OK); } @@ -183,13 +184,19 @@ waitClusterStatus(const char* _addr, int _nodes[MAX_NDB_NODES]; int _num_nodes = 0; - handle = ndb_mgm_create_handle(); + handle = ndb_mgm_create_handle(); if (handle == NULL){ g_err << "handle == NULL" << endl; return -1; } g_info << "Connecting to mgmsrv at " << _addr << endl; - if (ndb_mgm_connect(handle, _addr) == -1) { + if (ndb_mgm_set_connectstring(handle, _addr)) + { + MGMERR(handle); + g_err << "Connectstring " << _addr << " invalid" << endl; + return -1; + } + if (ndb_mgm_connect(handle,0,0,1)) { MGMERR(handle); g_err << "Connection to " << _addr << " failed" << endl; return -1; |