diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2005-01-28 00:47:41 +0100 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2005-01-28 00:47:41 +0100 |
commit | cca25e4d4903fbe1df3cd7251d9519c9c9fa376d (patch) | |
tree | 64b7118181c1242daeb2b9816bb749c9f50a9cf2 | |
parent | 1c49d54894aec778efa3fef6da5ae992f21b8d1d (diff) | |
parent | df7bb879cdbbf61e4c879cc6f13126a0be69dff7 (diff) | |
download | mariadb-git-cca25e4d4903fbe1df3cd7251d9519c9c9fa376d.tar.gz |
Merge
ndb/include/Makefile.am:
Auto merged
ndb/include/mgmapi/mgmapi_config_parameters.h:
Auto merged
ndb/src/common/mgmcommon/IPCConfig.cpp:
Auto merged
ndb/src/common/transporter/TransporterRegistry.cpp:
Auto merged
ndb/src/kernel/vm/Configuration.cpp:
Auto merged
ndb/src/mgmsrv/ConfigInfo.cpp:
Auto merged
ndb/tools/delete_all.cpp:
Auto merged
ndb/tools/desc.cpp:
Auto merged
ndb/tools/drop_index.cpp:
Auto merged
ndb/tools/drop_tab.cpp:
Auto merged
ndb/tools/listTables.cpp:
Auto merged
ndb/tools/restore/restore_main.cpp:
Auto merged
ndb/tools/select_all.cpp:
Auto merged
ndb/tools/select_count.cpp:
Auto merged
ndb/tools/waiter.cpp:
Auto merged
ndb/include/util/ndb_opts.h:
SCCS merged
ndb/src/mgmsrv/main.cpp:
resolved merge conflict
-rw-r--r-- | ndb/include/Makefile.am | 1 | ||||
-rw-r--r-- | ndb/include/mgmapi/mgmapi_config_parameters.h | 1 | ||||
-rw-r--r-- | ndb/include/ndbapi/ndb_opt_defaults.h | 27 | ||||
-rw-r--r-- | ndb/include/transporter/TransporterDefinitions.hpp | 1 | ||||
-rw-r--r-- | ndb/include/util/ndb_opts.h | 59 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/IPCConfig.cpp | 11 | ||||
-rw-r--r-- | ndb/src/common/portlib/NdbThread.c | 19 | ||||
-rw-r--r-- | ndb/src/common/transporter/SHM_Transporter.cpp | 8 | ||||
-rw-r--r-- | ndb/src/common/transporter/TransporterRegistry.cpp | 74 | ||||
-rw-r--r-- | ndb/src/cw/cpcd/main.cpp | 5 | ||||
-rw-r--r-- | ndb/src/kernel/vm/Configuration.cpp | 23 | ||||
-rw-r--r-- | ndb/src/mgmclient/main.cpp | 23 | ||||
-rw-r--r-- | ndb/src/mgmsrv/ConfigInfo.cpp | 42 | ||||
-rw-r--r-- | ndb/src/mgmsrv/main.cpp | 30 | ||||
-rw-r--r-- | ndb/tools/delete_all.cpp | 23 | ||||
-rw-r--r-- | ndb/tools/desc.cpp | 25 | ||||
-rw-r--r-- | ndb/tools/drop_index.cpp | 23 | ||||
-rw-r--r-- | ndb/tools/drop_tab.cpp | 23 | ||||
-rw-r--r-- | ndb/tools/listTables.cpp | 27 | ||||
-rw-r--r-- | ndb/tools/restore/restore_main.cpp | 20 | ||||
-rw-r--r-- | ndb/tools/select_all.cpp | 23 | ||||
-rw-r--r-- | ndb/tools/select_count.cpp | 23 | ||||
-rw-r--r-- | ndb/tools/waiter.cpp | 25 |
23 files changed, 234 insertions, 302 deletions
diff --git a/ndb/include/Makefile.am b/ndb/include/Makefile.am index 56d9bbf01fb..10f297492e9 100644 --- a/ndb/include/Makefile.am +++ b/ndb/include/Makefile.am @@ -9,6 +9,7 @@ ndb_version.h ndbapiinclude_HEADERS = \ ndbapi/ndbapi_limits.h \ +ndbapi/ndb_opt_defaults.h \ ndbapi/Ndb.hpp \ ndbapi/NdbApi.hpp \ ndbapi/NdbTransaction.hpp \ diff --git a/ndb/include/mgmapi/mgmapi_config_parameters.h b/ndb/include/mgmapi/mgmapi_config_parameters.h index 62fa24d3c04..68b63d78fa8 100644 --- a/ndb/include/mgmapi/mgmapi_config_parameters.h +++ b/ndb/include/mgmapi/mgmapi_config_parameters.h @@ -121,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/ndbapi/ndb_opt_defaults.h b/ndb/include/ndbapi/ndb_opt_defaults.h new file mode 100644 index 00000000000..63b673ed60d --- /dev/null +++ b/ndb/include/ndbapi/ndb_opt_defaults.h @@ -0,0 +1,27 @@ +/* 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_OPT_DEFAULTS_H +#define NDB_OPT_DEFAULTS_H + +#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 + +#endif diff --git a/ndb/include/transporter/TransporterDefinitions.hpp b/ndb/include/transporter/TransporterDefinitions.hpp index 4ff6b2073eb..d4763ba4c37 100644 --- a/ndb/include/transporter/TransporterDefinitions.hpp +++ b/ndb/include/transporter/TransporterDefinitions.hpp @@ -77,6 +77,7 @@ struct SHM_TransporterConfiguration { Uint32 shmKey; Uint32 shmSize; + int signum; }; /** diff --git a/ndb/include/util/ndb_opts.h b/ndb/include/util/ndb_opts.h index 9151aee6cf2..aa7a02f58ae 100644 --- a/ndb/include/util/ndb_opts.h +++ b/ndb/include/util/ndb_opts.h @@ -22,24 +22,16 @@ #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_shm;\ my_bool opt_ndb_optimized_node_selection -#define NDB_STD_OPTS_OPTIONS \ -OPT_NDB_SHM= 256,\ -OPT_NDB_OPTIMIZED_NODE_SELECTION +my_bool opt_ndb_shm; #define OPT_NDB_CONNECTSTRING 'c' -#if defined(NOT_ENOUGH_TESTED) && defined(NDB_SHM_TRANSPORTER) && MYSQL_VERSION_ID >= 50000 -#define OPT_NDB_SHM_DEFAULT 1 -#else -#define OPT_NDB_SHM_DEFAULT 0 -#endif - #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 }, \ @@ -75,4 +67,51 @@ OPT_NDB_OPTIMIZED_NODE_SELECTION #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/common/mgmcommon/IPCConfig.cpp b/ndb/src/common/mgmcommon/IPCConfig.cpp index dd78e1dbfbd..e25aeee8813 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,7 +383,12 @@ 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; diff --git a/ndb/src/common/portlib/NdbThread.c b/ndb/src/common/portlib/NdbThread.c index 8cd6c306514..d05fca7aeed 100644 --- a/ndb/src/common/portlib/NdbThread.c +++ b/ndb/src/common/portlib/NdbThread.c @@ -24,6 +24,10 @@ /*#define USE_PTHREAD_EXTRAS*/ +#ifdef NDB_SHM_TRANSPORTER +int g_ndb_shm_signum= 0; +#endif + struct NdbThread { pthread_t thread; @@ -35,16 +39,21 @@ struct NdbThread static void* ndb_thread_wrapper(void* _ss){ + DBUG_ENTER("ndb_thread_wrapper"); void * ret; struct NdbThread * ss = (struct NdbThread *)_ss; #ifdef NDB_SHM_TRANSPORTER - sigset_t mask; - sigemptyset(&mask); - sigaddset(&mask, SIGUSR1); - pthread_sigmask(SIG_BLOCK, &mask, 0); + if (g_ndb_shm_signum) + { + DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum)); + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, g_ndb_shm_signum); + pthread_sigmask(SIG_BLOCK, &mask, 0); + } #endif ret= (* ss->func)(ss->object); - return ret; + DBUG_RETURN(ret); } diff --git a/ndb/src/common/transporter/SHM_Transporter.cpp b/ndb/src/common/transporter/SHM_Transporter.cpp index f0cbf822e53..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, @@ -62,7 +64,9 @@ SHM_Transporter::~SHM_Transporter(){ bool SHM_Transporter::initTransporter(){ - return true; + if (g_ndb_shm_signum) + return true; + return false; } void @@ -355,6 +359,6 @@ SHM_Transporter::doSend() if(m_last_signal) { m_last_signal = 0; - kill(m_remote_pid, SIGUSR1); + kill(m_remote_pid, g_ndb_shm_signum); } } diff --git a/ndb/src/common/transporter/TransporterRegistry.cpp b/ndb/src/common/transporter/TransporterRegistry.cpp index 215b2a05f63..7b0f2d7247b 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" @@ -152,22 +153,13 @@ TransporterRegistry::disconnectAll(){ bool TransporterRegistry::init(NodeId nodeId) { + DBUG_ENTER("TransporterRegistry::init"); nodeIdSpecified = true; localNodeId = nodeId; DEBUG("TransporterRegistry started node: " << localNodeId); -#ifdef NDB_SHM_TRANSPORTER - /** - * Make sure to block SIGUSR1 - * TransporterRegistry::init is run from "main" thread - */ - sigset_t mask; - sigemptyset(&mask); - sigaddset(&mask, SIGUSR1); - pthread_sigmask(SIG_BLOCK, &mask, 0); -#endif -return true; + DBUG_RETURN(true); } bool @@ -406,6 +398,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); @@ -414,6 +407,22 @@ 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; @@ -443,9 +452,9 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { nTransporters++; nSHMTransporters++; - return true; + DBUG_RETURN(true); #else - return false; + DBUG_RETURN(false); #endif } @@ -1337,6 +1346,7 @@ shm_sig_handler(int signo) void TransporterRegistry::startReceiving() { + DBUG_ENTER("TransporterRegistry::startReceiving"); #ifdef NDB_OSE_TRANSPORTER if(theOSEReceiver != NULL){ theOSEReceiver->createPhantom(); @@ -1355,26 +1365,34 @@ TransporterRegistry::startReceiving() #ifdef NDB_SHM_TRANSPORTER m_shm_own_pid = getpid(); - struct sigaction sa; - sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, SIGUSR1); - 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(SIGUSR1, &sa, 0)) == -1 && errno == EINTR); - if(ret != 0) + if (g_ndb_shm_signum) { - g_eventLogger.error("Failed to install signal handler for SHM transporter" - " errno: %d (%s)", errno, + 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)); + strerror(errno) #else - ""); + "" #endif + ); + } } -#endif +#endif // NDB_SHM_TRANSPORTER + DBUG_VOID_RETURN; } void diff --git a/ndb/src/cw/cpcd/main.cpp b/ndb/src/cw/cpcd/main.cpp index 300b51d7b5a..25632f132e9 100644 --- a/ndb/src/cw/cpcd/main.cpp +++ b/ndb/src/cw/cpcd/main.cpp @@ -15,7 +15,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> /* Needed for mkdir(2) */ -#include <ndb_opts.h> +#include <my_sys.h> +#include <my_getopt.h> +#include <mysql_version.h> +#include <ndb_version.h> #include "CPCD.hpp" #include "APIService.hpp" diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 4ad7050ce63..f35a5859ff8 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -47,8 +47,7 @@ extern "C" { extern EventLogger g_eventLogger; enum ndbd_options { - NDB_STD_OPTS_OPTIONS, - OPT_INITIAL, + OPT_INITIAL = NDB_STD_OPTIONS_LAST, OPT_NODAEMON }; @@ -82,14 +81,10 @@ static void short_usage_sub(void) { printf("Usage: %s [OPTIONS]\n", my_progname); } -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { short_usage_sub(); - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -97,18 +92,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndbd.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, + argument ? argument : "d:t:O,/tmp/ndbd.trace"); } bool diff --git a/ndb/src/mgmclient/main.cpp b/ndb/src/mgmclient/main.cpp index 9417c03805f..73f0bad86c0 100644 --- a/ndb/src/mgmclient/main.cpp +++ b/ndb/src/mgmclient/main.cpp @@ -56,9 +56,6 @@ handler(int sig){ } } -enum ndb_mgm_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char default_prompt[]= "ndb_mgm> "; @@ -83,14 +80,10 @@ static void short_usage_sub(void) { printf("Usage: %s [OPTIONS] [hostname [port]]\n", my_progname); } -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { short_usage_sub(); - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -98,18 +91,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgm.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_mgm.trace"); } static int diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index ed49a551b09..a9c53f606e2 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -15,6 +15,7 @@ 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" @@ -1766,6 +1767,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { 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", @@ -3190,18 +3203,27 @@ bool fixShmKey(InitConfigFileParser::Context & ctx, const char *) { DBUG_ENTER("fixShmKey"); - 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)) { - DBUG_RETURN(true); + Uint32 signum; + if(!ctx.m_currentSection->get("Signum", &signum)) + { + signum= OPT_NDB_SHM_SIGNUM_DEFAULT; + ctx.m_currentSection->put("Signum", signum); + DBUG_PRINT("info",("Added Signum=%u", 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)); + } } - - 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); } diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index 482bc2e89cc..67975f8539d 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -134,8 +134,7 @@ extern EventLogger g_eventLogger; extern int global_mgmt_server_check; enum ndb_mgmd_options { - NDB_STD_OPTS_OPTIONS, - OPT_INTERACTIVE, + OPT_INTERACTIVE = NDB_STD_OPTIONS_LAST, OPT_NO_NODEID_CHECKS, OPT_NO_DAEMON }; @@ -169,14 +168,10 @@ static void short_usage_sub(void) { printf("Usage: %s [OPTIONS]\n", my_progname); } -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { short_usage_sub(); - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -184,25 +179,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgmd.trace"); - break; - case 'V': - print_version(); - exit(0); - case OPT_NDB_SHM: -#ifndef NDB_SHM_TRANSPORTER - printf("Warning: binary not compiled with shared memory support,\n" - "use configure option --with-ndb-shm to enable support.\n" - "Tcp connections will now be used instead\n"); - opt_ndb_shm= 0; -#endif - break; - case '?': - usage(); - exit(0); - } + ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_mgmd.trace"); return 0; } diff --git a/ndb/tools/delete_all.cpp b/ndb/tools/delete_all.cpp index 38a9cdd9354..4a153208c65 100644 --- a/ndb/tools/delete_all.cpp +++ b/ndb/tools/delete_all.cpp @@ -24,9 +24,6 @@ static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240); -enum ndb_delete_all { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -38,16 +35,12 @@ static struct my_option my_long_options[] = 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 print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "tabname\n"\ "This program will delete all records in the specified table using scan delete.\n"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -55,18 +48,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_delete_all.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_delete_all.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/desc.cpp b/ndb/tools/desc.cpp index b18f97a05b1..3bfa332ea79 100644 --- a/ndb/tools/desc.cpp +++ b/ndb/tools/desc.cpp @@ -19,9 +19,6 @@ #include <NDBT.hpp> #include <NdbApi.hpp> -enum ndb_desc_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -37,17 +34,13 @@ static struct my_option my_long_options[] = 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 print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} 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"; - print_version(); + " ex: desc T1 T2 T4\n"; + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -55,18 +48,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_desc.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_desc.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/drop_index.cpp b/ndb/tools/drop_index.cpp index 47baee0b66f..90528a2a5a4 100644 --- a/ndb/tools/drop_index.cpp +++ b/ndb/tools/drop_index.cpp @@ -21,9 +21,6 @@ #include <NdbApi.hpp> #include <NDBT.hpp> -enum ndb_drop_index_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -35,16 +32,12 @@ static struct my_option my_long_options[] = 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 print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "<indexname>+\n"\ "This program will drop index(es) in Ndb\n"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -52,18 +45,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_index.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_drop_index.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/drop_tab.cpp b/ndb/tools/drop_tab.cpp index 6d128321994..a0a5262bace 100644 --- a/ndb/tools/drop_tab.cpp +++ b/ndb/tools/drop_tab.cpp @@ -21,9 +21,6 @@ #include <NdbApi.hpp> #include <NDBT.hpp> -enum ndb_drop_table_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -35,16 +32,12 @@ static struct my_option my_long_options[] = 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 print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "tabname\n"\ "This program will drop one table in Ndb\n"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -52,18 +45,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_table.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_drop_table.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp index e018bd6d9a5..a49fbde596e 100644 --- a/ndb/tools/listTables.cpp +++ b/ndb/tools/listTables.cpp @@ -161,9 +161,6 @@ list(const char * tabname, } } -enum ndb_show_tables_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -186,20 +183,16 @@ static struct my_option my_long_options[] = 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 print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} 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"; - print_version(); + " ex: ndb_show_tables T1\n"; + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -207,18 +200,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_show_tables.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_show_tables.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/restore/restore_main.cpp b/ndb/tools/restore/restore_main.cpp index 528a9634658..326020d7118 100644 --- a/ndb/tools/restore/restore_main.cpp +++ b/ndb/tools/restore/restore_main.cpp @@ -36,9 +36,6 @@ static Vector<class BackupConsumer *> g_consumers; static const char* ga_backupPath = "." DIR_SEPARATOR; -enum ndb_restore_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; /** @@ -101,14 +98,10 @@ static void short_usage_sub(void) { printf("Usage: %s [OPTIONS] [<path to backup files>]\n", my_progname); } -static void print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { short_usage_sub(); - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -116,13 +109,9 @@ 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 '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_restore.trace"); - break; - case 'V': - print_version(); - exit(0); case 'n': if (ga_nodeId == 0) { @@ -137,9 +126,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), exit(1); } break; - case '?': - usage(); - exit(0); } return 0; } diff --git a/ndb/tools/select_all.cpp b/ndb/tools/select_all.cpp index ecb7db91060..a3d07e3938b 100644 --- a/ndb/tools/select_all.cpp +++ b/ndb/tools/select_all.cpp @@ -36,9 +36,6 @@ int scanReadRecords(Ndb*, bool orderby, bool descending); -enum ndb_select_all_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -75,10 +72,6 @@ static struct my_option my_long_options[] = 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 print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = @@ -88,7 +81,7 @@ static void usage() "(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"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -96,18 +89,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_select_all.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_select_all.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/select_count.cpp b/ndb/tools/select_count.cpp index f2b78de4b37..41e66c8b367 100644 --- a/ndb/tools/select_count.cpp +++ b/ndb/tools/select_count.cpp @@ -32,9 +32,6 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, int* count_rows, NdbOperation::LockMode lock); -enum ndb_select_count_options { - NDB_STD_OPTS_OPTIONS -}; NDB_STD_OPTS_VARS; static const char* _dbname = "TEST_DB"; @@ -54,16 +51,12 @@ static struct my_option my_long_options[] = 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 print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} static void usage() { char desc[] = "tabname1 ... tabnameN\n"\ "This program will count the number of records in tables\n"; - print_version(); + ndb_std_print_version(); my_print_help(my_long_options); my_print_variables(my_long_options); } @@ -71,18 +64,8 @@ static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_select_count.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_select_count.trace"); } int main(int argc, char** argv){ diff --git a/ndb/tools/waiter.cpp b/ndb/tools/waiter.cpp index dfdb11524e3..cc6a21428c8 100644 --- a/ndb/tools/waiter.cpp +++ b/ndb/tools/waiter.cpp @@ -31,8 +31,7 @@ waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, unsigned int _timeout); enum ndb_waiter_options { - NDB_STD_OPTS_OPTIONS, - OPT_WAIT_STATUS_NOT_STARTED + OPT_WAIT_STATUS_NOT_STARTED = NDB_STD_OPTIONS_LAST }; NDB_STD_OPTS_VARS; @@ -53,32 +52,20 @@ static struct my_option my_long_options[] = 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 print_version() -{ - printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); -} + static void usage() { - print_version(); + 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) { - switch (optid) { - case '#': - DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_drop_table.trace"); - break; - case 'V': - print_version(); - exit(0); - case '?': - usage(); - exit(0); - } - return 0; + return ndb_std_get_one_option(optid, opt, argument ? argument : + "d:t:O,/tmp/ndb_drop_table.trace"); } int main(int argc, char** argv){ |