Bug#8167 signal usage clash between mysql server and ndb shared memory

    added shared memory config parameter, signum for use in signalling
    added global variable for holdign signum to be used for shared memory connection
    only fiddle with signals if it is set
    simplified common ndb client option handling
parent 42531336
...@@ -8,6 +8,7 @@ ndb_version.h ...@@ -8,6 +8,7 @@ ndb_version.h
ndbapiinclude_HEADERS = \ ndbapiinclude_HEADERS = \
ndbapi/ndbapi_limits.h \ ndbapi/ndbapi_limits.h \
ndbapi/ndb_opt_defaults.h \
ndbapi/Ndb.hpp \ ndbapi/Ndb.hpp \
ndbapi/NdbApi.hpp \ ndbapi/NdbApi.hpp \
ndbapi/NdbConnection.hpp \ ndbapi/NdbConnection.hpp \
......
...@@ -121,6 +121,7 @@ ...@@ -121,6 +121,7 @@
#define CFG_SHM_CHECKSUM 501 #define CFG_SHM_CHECKSUM 501
#define CFG_SHM_KEY 502 #define CFG_SHM_KEY 502
#define CFG_SHM_BUFFER_MEM 503 #define CFG_SHM_BUFFER_MEM 503
#define CFG_SHM_SIGNUM 504
#define CFG_SCI_HOST1_ID_0 550 #define CFG_SCI_HOST1_ID_0 550
#define CFG_SCI_HOST1_ID_1 551 #define CFG_SCI_HOST1_ID_1 551
......
/* 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
...@@ -77,6 +77,7 @@ struct SHM_TransporterConfiguration { ...@@ -77,6 +77,7 @@ struct SHM_TransporterConfiguration {
Uint32 shmKey; Uint32 shmKey;
Uint32 shmSize; Uint32 shmSize;
int signum;
}; };
/** /**
......
...@@ -22,24 +22,16 @@ ...@@ -22,24 +22,16 @@
#include <my_getopt.h> #include <my_getopt.h>
#include <mysql_version.h> #include <mysql_version.h>
#include <ndb_version.h> #include <ndb_version.h>
#include <ndb_opt_defaults.h>
#define NDB_STD_OPTS_VARS \ #define NDB_STD_OPTS_VARS \
const char *opt_connect_str= 0;\ const char *opt_connect_str= 0;\
my_bool opt_ndb_shm;\
my_bool opt_ndb_optimized_node_selection my_bool opt_ndb_optimized_node_selection
#define NDB_STD_OPTS_OPTIONS \ my_bool opt_ndb_shm;
OPT_NDB_SHM= 256,\
OPT_NDB_OPTIMIZED_NODE_SELECTION
#define OPT_NDB_CONNECTSTRING 'c' #define OPT_NDB_CONNECTSTRING 'c'
#if 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 \ #define NDB_STD_OPTS_COMMON \
{ "usage", '?', "Display this help and exit.", \ { "usage", '?', "Display this help and exit.", \
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \
...@@ -75,4 +67,51 @@ OPT_NDB_OPTIMIZED_NODE_SELECTION ...@@ -75,4 +67,51 @@ OPT_NDB_OPTIMIZED_NODE_SELECTION
#define NDB_STD_OPTS(prog_name) NDB_STD_OPTS_COMMON #define NDB_STD_OPTS(prog_name) NDB_STD_OPTS_COMMON
#endif #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 */ #endif /*_NDB_OPTS_H */
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 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 <NdbOut.hpp>
#include <NdbHost.h> #include <NdbHost.h>
...@@ -381,6 +383,11 @@ IPCConfig::configureTransporters(Uint32 nodeId, ...@@ -381,6 +383,11 @@ IPCConfig::configureTransporters(Uint32 nodeId,
if(iter.get(CFG_SHM_KEY, &conf.shmKey)) break; if(iter.get(CFG_SHM_KEY, &conf.shmKey)) break;
if(iter.get(CFG_SHM_BUFFER_MEM, &conf.shmSize)) 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.port= server_port;
conf.localHostName = localHostName; conf.localHostName = localHostName;
......
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
/*#define USE_PTHREAD_EXTRAS*/ /*#define USE_PTHREAD_EXTRAS*/
#ifdef NDB_SHM_TRANSPORTER
int g_ndb_shm_signum= 0;
#endif
struct NdbThread struct NdbThread
{ {
pthread_t thread; pthread_t thread;
...@@ -35,16 +39,21 @@ struct NdbThread ...@@ -35,16 +39,21 @@ struct NdbThread
static static
void* void*
ndb_thread_wrapper(void* _ss){ ndb_thread_wrapper(void* _ss){
DBUG_ENTER("ndb_thread_wrapper");
void * ret; void * ret;
struct NdbThread * ss = (struct NdbThread *)_ss; struct NdbThread * ss = (struct NdbThread *)_ss;
#ifdef NDB_SHM_TRANSPORTER #ifdef NDB_SHM_TRANSPORTER
if (g_ndb_shm_signum)
{
DBUG_PRINT("info",("Block signum %d",g_ndb_shm_signum));
sigset_t mask; sigset_t mask;
sigemptyset(&mask); sigemptyset(&mask);
sigaddset(&mask, SIGUSR1); sigaddset(&mask, g_ndb_shm_signum);
pthread_sigmask(SIG_BLOCK, &mask, 0); pthread_sigmask(SIG_BLOCK, &mask, 0);
}
#endif #endif
ret= (* ss->func)(ss->object); ret= (* ss->func)(ss->object);
return ret; DBUG_RETURN(ret);
} }
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <InputStream.hpp> #include <InputStream.hpp>
#include <OutputStream.hpp> #include <OutputStream.hpp>
extern int g_ndb_shm_signum;
SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg, SHM_Transporter::SHM_Transporter(TransporterRegistry &t_reg,
const char *lHostName, const char *lHostName,
const char *rHostName, const char *rHostName,
...@@ -62,7 +64,9 @@ SHM_Transporter::~SHM_Transporter(){ ...@@ -62,7 +64,9 @@ SHM_Transporter::~SHM_Transporter(){
bool bool
SHM_Transporter::initTransporter(){ SHM_Transporter::initTransporter(){
if (g_ndb_shm_signum)
return true; return true;
return false;
} }
void void
...@@ -355,6 +359,6 @@ SHM_Transporter::doSend() ...@@ -355,6 +359,6 @@ SHM_Transporter::doSend()
if(m_last_signal) if(m_last_signal)
{ {
m_last_signal = 0; m_last_signal = 0;
kill(m_remote_pid, SIGUSR1); kill(m_remote_pid, g_ndb_shm_signum);
} }
} }
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#ifdef NDB_SHM_TRANSPORTER #ifdef NDB_SHM_TRANSPORTER
#include "SHM_Transporter.hpp" #include "SHM_Transporter.hpp"
extern int g_ndb_shm_signum;
#endif #endif
#include "TransporterCallback.hpp" #include "TransporterCallback.hpp"
...@@ -148,22 +149,13 @@ TransporterRegistry::disconnectAll(){ ...@@ -148,22 +149,13 @@ TransporterRegistry::disconnectAll(){
bool bool
TransporterRegistry::init(NodeId nodeId) { TransporterRegistry::init(NodeId nodeId) {
DBUG_ENTER("TransporterRegistry::init");
nodeIdSpecified = true; nodeIdSpecified = true;
localNodeId = nodeId; localNodeId = nodeId;
DEBUG("TransporterRegistry started node: " << localNodeId); DEBUG("TransporterRegistry started node: " << localNodeId);
#ifdef NDB_SHM_TRANSPORTER DBUG_RETURN(true);
/**
* 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;
} }
bool bool
...@@ -402,6 +394,7 @@ TransporterRegistry::createTransporter(SCI_TransporterConfiguration *config) { ...@@ -402,6 +394,7 @@ TransporterRegistry::createTransporter(SCI_TransporterConfiguration *config) {
bool bool
TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) {
DBUG_ENTER("TransporterRegistry::createTransporter SHM");
#ifdef NDB_SHM_TRANSPORTER #ifdef NDB_SHM_TRANSPORTER
if(!nodeIdSpecified){ if(!nodeIdSpecified){
init(config->localNodeId); init(config->localNodeId);
...@@ -410,6 +403,22 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { ...@@ -410,6 +403,22 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) {
if(config->localNodeId != localNodeId) if(config->localNodeId != localNodeId)
return false; 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) if(theTransporters[config->remoteNodeId] != NULL)
return false; return false;
...@@ -439,9 +448,9 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) { ...@@ -439,9 +448,9 @@ TransporterRegistry::createTransporter(SHM_TransporterConfiguration *config) {
nTransporters++; nTransporters++;
nSHMTransporters++; nSHMTransporters++;
return true; DBUG_RETURN(true);
#else #else
return false; DBUG_RETURN(false);
#endif #endif
} }
...@@ -1311,6 +1320,7 @@ shm_sig_handler(int signo) ...@@ -1311,6 +1320,7 @@ shm_sig_handler(int signo)
void void
TransporterRegistry::startReceiving() TransporterRegistry::startReceiving()
{ {
DBUG_ENTER("TransporterRegistry::startReceiving");
#ifdef NDB_OSE_TRANSPORTER #ifdef NDB_OSE_TRANSPORTER
if(theOSEReceiver != NULL){ if(theOSEReceiver != NULL){
theOSEReceiver->createPhantom(); theOSEReceiver->createPhantom();
...@@ -1329,26 +1339,34 @@ TransporterRegistry::startReceiving() ...@@ -1329,26 +1339,34 @@ TransporterRegistry::startReceiving()
#ifdef NDB_SHM_TRANSPORTER #ifdef NDB_SHM_TRANSPORTER
m_shm_own_pid = getpid(); 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; struct sigaction sa;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sigaddset(&sa.sa_mask, SIGUSR1); sigaddset(&sa.sa_mask, g_ndb_shm_signum);
pthread_sigmask(SIG_UNBLOCK, &sa.sa_mask, 0); pthread_sigmask(SIG_UNBLOCK, &sa.sa_mask, 0);
sa.sa_handler = shm_sig_handler; sa.sa_handler = shm_sig_handler;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = 0; sa.sa_flags = 0;
int ret; int ret;
while((ret = sigaction(SIGUSR1, &sa, 0)) == -1 && errno == EINTR); while((ret = sigaction(g_ndb_shm_signum, &sa, 0)) == -1 && errno == EINTR);
if(ret != 0) if(ret != 0)
{ {
g_eventLogger.error("Failed to install signal handler for SHM transporter" DBUG_PRINT("error",("Install failed"));
" errno: %d (%s)", errno, g_eventLogger.error("Failed to install signal handler for"
" SHM transporter errno: %d (%s)", errno,
#ifdef HAVE_STRERROR #ifdef HAVE_STRERROR
strerror(errno)); strerror(errno)
#else #else
""); ""
#endif #endif
);
} }
#endif }
#endif // NDB_SHM_TRANSPORTER
DBUG_VOID_RETURN;
} }
void void
......
...@@ -15,7 +15,10 @@ ...@@ -15,7 +15,10 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h> /* Needed for mkdir(2) */ #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 "CPCD.hpp"
#include "APIService.hpp" #include "APIService.hpp"
......
...@@ -47,8 +47,7 @@ extern "C" { ...@@ -47,8 +47,7 @@ extern "C" {
extern EventLogger g_eventLogger; extern EventLogger g_eventLogger;
enum ndbd_options { enum ndbd_options {
NDB_STD_OPTS_OPTIONS, OPT_INITIAL = NDB_STD_OPTIONS_LAST,
OPT_INITIAL,
OPT_NODAEMON OPT_NODAEMON
}; };
...@@ -82,14 +81,10 @@ static void short_usage_sub(void) ...@@ -82,14 +81,10 @@ static void short_usage_sub(void)
{ {
printf("Usage: %s [OPTIONS]\n", my_progname); 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() static void usage()
{ {
short_usage_sub(); short_usage_sub();
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -97,18 +92,8 @@ static my_bool ...@@ -97,18 +92,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt,
case '#': argument ? argument : "d:t:O,/tmp/ndbd.trace");
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndbd.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
} }
bool bool
......
...@@ -56,9 +56,6 @@ handler(int sig){ ...@@ -56,9 +56,6 @@ handler(int sig){
} }
} }
enum ndb_mgm_options {
NDB_STD_OPTS_OPTIONS
};
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
static const char default_prompt[]= "ndb_mgm> "; static const char default_prompt[]= "ndb_mgm> ";
...@@ -83,14 +80,10 @@ static void short_usage_sub(void) ...@@ -83,14 +80,10 @@ static void short_usage_sub(void)
{ {
printf("Usage: %s [OPTIONS] [hostname [port]]\n", my_progname); 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() static void usage()
{ {
short_usage_sub(); short_usage_sub();
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -98,18 +91,8 @@ static my_bool ...@@ -98,18 +91,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_mgm.trace");
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgm.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
} }
static int static int
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h> #include <ndb_global.h>
#include <ndb_opt_defaults.h>
#include <NdbTCP.h> #include <NdbTCP.h>
#include "ConfigInfo.hpp" #include "ConfigInfo.hpp"
...@@ -1753,6 +1754,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -1753,6 +1754,18 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
"0", "0",
STR_VALUE(MAX_INT_RNIL) }, 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, CFG_CONNECTION_NODE_1,
"NodeId1", "NodeId1",
...@@ -3178,18 +3191,27 @@ bool ...@@ -3178,18 +3191,27 @@ bool
fixShmKey(InitConfigFileParser::Context & ctx, const char *) fixShmKey(InitConfigFileParser::Context & ctx, const char *)
{ {
DBUG_ENTER("fixShmKey"); DBUG_ENTER("fixShmKey");
{
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; Uint32 id1= 0, id2= 0, key= 0;
require(ctx.m_currentSection->get("NodeId1", &id1)); require(ctx.m_currentSection->get("NodeId1", &id1));
require(ctx.m_currentSection->get("NodeId2", &id2)); require(ctx.m_currentSection->get("NodeId2", &id2));
if(ctx.m_currentSection->get("ShmKey", &key)) if(!ctx.m_currentSection->get("ShmKey", &key))
{ {
DBUG_RETURN(true);
}
require(ctx.m_userProperties.get("ShmUniqueId", &key)); require(ctx.m_userProperties.get("ShmUniqueId", &key));
key= key << 16 | (id1 > id2 ? id1 << 8 | id2 : id2 << 8 | id1); key= key << 16 | (id1 > id2 ? id1 << 8 | id2 : id2 << 8 | id1);
ctx.m_currentSection->put("ShmKey", key); ctx.m_currentSection->put("ShmKey", key);
DBUG_PRINT("info",("Added ShmKey=0x%x", key)); DBUG_PRINT("info",("Added ShmKey=0x%x", key));
}
}
DBUG_RETURN(true); DBUG_RETURN(true);
} }
......
...@@ -91,8 +91,7 @@ extern EventLogger g_eventLogger; ...@@ -91,8 +91,7 @@ extern EventLogger g_eventLogger;
extern int global_mgmt_server_check; extern int global_mgmt_server_check;
enum ndb_mgmd_options { enum ndb_mgmd_options {
NDB_STD_OPTS_OPTIONS, OPT_INTERACTIVE = NDB_STD_OPTIONS_LAST,
OPT_INTERACTIVE,
OPT_NO_NODEID_CHECKS, OPT_NO_NODEID_CHECKS,
OPT_NO_DAEMON OPT_NO_DAEMON
}; };
...@@ -139,14 +138,10 @@ static void short_usage_sub(void) ...@@ -139,14 +138,10 @@ static void short_usage_sub(void)
{ {
printf("Usage: %s [OPTIONS]\n", my_progname); 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() static void usage()
{ {
short_usage_sub(); short_usage_sub();
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -154,30 +149,15 @@ static my_bool ...@@ -154,30 +149,15 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_mgmd.trace");
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_mgmd.trace");
break;
case 'V':
print_version();
exit(0);
#if NDB_VERSION_MAJOR <= 4 #if NDB_VERSION_MAJOR <= 4
switch (optid) {
case 'c': case 'c':
printf("Warning: -c will be removed in 5.0, use -f instead\n"); printf("Warning: -c will be removed in 5.0, use -f instead\n");
break; break;
#endif
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);
} }
#endif
return 0; return 0;
} }
......
...@@ -24,9 +24,6 @@ ...@@ -24,9 +24,6 @@
static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240); 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; NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB"; static const char* _dbname = "TEST_DB";
...@@ -38,16 +35,12 @@ static struct my_option my_long_options[] = ...@@ -38,16 +35,12 @@ static struct my_option my_long_options[] =
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 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} { 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() static void usage()
{ {
char desc[] = char desc[] =
"tabname\n"\ "tabname\n"\
"This program will delete all records in the specified table using scan delete.\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_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -55,18 +48,8 @@ static my_bool ...@@ -55,18 +48,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_delete_all.trace");
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;
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
......
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
#include <NDBT.hpp> #include <NDBT.hpp>
#include <NdbApi.hpp> #include <NdbApi.hpp>
enum ndb_desc_options {
NDB_STD_OPTS_OPTIONS
};
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB"; static const char* _dbname = "TEST_DB";
...@@ -37,17 +34,13 @@ static struct my_option my_long_options[] = ...@@ -37,17 +34,13 @@ static struct my_option my_long_options[] =
GET_BOOL, NO_ARG, 0, 0, 0, 0, 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} { 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() static void usage()
{ {
char desc[] = char desc[] =
"tabname\n"\ "tabname\n"\
"This program list all properties of table(s) in NDB Cluster.\n"\ "This program list all properties of table(s) in NDB Cluster.\n"\
" ex: desc T1 T2 T4\n"; " ex: desc T1 T2 T4\n";
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -55,18 +48,8 @@ static my_bool ...@@ -55,18 +48,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_desc.trace");
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_desc.trace");
break;
case 'V':
print_version();
exit(0);
case '?':
usage();
exit(0);
}
return 0;
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
......
...@@ -21,9 +21,6 @@ ...@@ -21,9 +21,6 @@
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NDBT.hpp> #include <NDBT.hpp>
enum ndb_drop_index_options {
NDB_STD_OPTS_OPTIONS
};
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB"; static const char* _dbname = "TEST_DB";
...@@ -35,16 +32,12 @@ static struct my_option my_long_options[] = ...@@ -35,16 +32,12 @@ static struct my_option my_long_options[] =
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 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} { 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() static void usage()
{ {
char desc[] = char desc[] =
"<indexname>+\n"\ "<indexname>+\n"\
"This program will drop index(es) in Ndb\n"; "This program will drop index(es) in Ndb\n";
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -52,18 +45,8 @@ static my_bool ...@@ -52,18 +45,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_drop_index.trace");
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;
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
......
...@@ -21,9 +21,6 @@ ...@@ -21,9 +21,6 @@
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <NDBT.hpp> #include <NDBT.hpp>
enum ndb_drop_table_options {
NDB_STD_OPTS_OPTIONS
};
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB"; static const char* _dbname = "TEST_DB";
...@@ -35,16 +32,12 @@ static struct my_option my_long_options[] = ...@@ -35,16 +32,12 @@ static struct my_option my_long_options[] =
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 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} { 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() static void usage()
{ {
char desc[] = char desc[] =
"tabname\n"\ "tabname\n"\
"This program will drop one table in Ndb\n"; "This program will drop one table in Ndb\n";
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -52,18 +45,8 @@ static my_bool ...@@ -52,18 +45,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_drop_table.trace");
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;
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
......
...@@ -161,9 +161,6 @@ list(const char * tabname, ...@@ -161,9 +161,6 @@ list(const char * tabname,
} }
} }
enum ndb_show_tables_options {
NDB_STD_OPTS_OPTIONS
};
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB"; static const char* _dbname = "TEST_DB";
...@@ -186,20 +183,16 @@ static struct my_option my_long_options[] = ...@@ -186,20 +183,16 @@ static struct my_option my_long_options[] =
GET_BOOL, NO_ARG, 0, 0, 0, 0, 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} { 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() static void usage()
{ {
char desc[] = char desc[] =
"tabname\n"\ "tabname\n"\
"This program list all system objects in NDB Cluster.\n"\ "This program list all system objects in NDB Cluster.\n"\
"Type of objects to display can be limited with -t option\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"\ "To show all indexes for a table write table name as final argument\n"\
" ex: list_tables T1\n"; " ex: ndb_show_tables T1\n";
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -207,18 +200,8 @@ static my_bool ...@@ -207,18 +200,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_show_tables.trace");
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;
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
......
...@@ -36,9 +36,6 @@ static Vector<class BackupConsumer *> g_consumers; ...@@ -36,9 +36,6 @@ static Vector<class BackupConsumer *> g_consumers;
static const char* ga_backupPath = "." DIR_SEPARATOR; static const char* ga_backupPath = "." DIR_SEPARATOR;
enum ndb_restore_options {
NDB_STD_OPTS_OPTIONS
};
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
/** /**
...@@ -101,14 +98,10 @@ static void short_usage_sub(void) ...@@ -101,14 +98,10 @@ static void short_usage_sub(void)
{ {
printf("Usage: %s [OPTIONS] [<path to backup files>]\n", my_progname); 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() static void usage()
{ {
short_usage_sub(); short_usage_sub();
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -116,13 +109,9 @@ static my_bool ...@@ -116,13 +109,9 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
ndb_std_get_one_option(optid, opt, argument ? argument :
"d:t:O,/tmp/ndb_restore.trace");
switch (optid) { switch (optid) {
case '#':
DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_restore.trace");
break;
case 'V':
print_version();
exit(0);
case 'n': case 'n':
if (ga_nodeId == 0) if (ga_nodeId == 0)
{ {
...@@ -137,9 +126,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -137,9 +126,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
exit(1); exit(1);
} }
break; break;
case '?':
usage();
exit(0);
} }
return 0; return 0;
} }
......
...@@ -36,9 +36,6 @@ int scanReadRecords(Ndb*, ...@@ -36,9 +36,6 @@ int scanReadRecords(Ndb*,
char delim, char delim,
bool orderby); bool orderby);
enum ndb_select_all_options {
NDB_STD_OPTS_OPTIONS
};
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB"; static const char* _dbname = "TEST_DB";
...@@ -72,10 +69,6 @@ static struct my_option my_long_options[] = ...@@ -72,10 +69,6 @@ static struct my_option my_long_options[] =
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 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} { 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() static void usage()
{ {
char desc[] = char desc[] =
...@@ -85,7 +78,7 @@ static void usage() ...@@ -85,7 +78,7 @@ static void usage()
"(It only print error messages if it encounters a permanent error.)\n"\ "(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"\ "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"; " ex: select_all --no-header --delimiter=';' T4 > T4.data\n";
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -93,18 +86,8 @@ static my_bool ...@@ -93,18 +86,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_select_all.trace");
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;
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
......
...@@ -32,9 +32,6 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, ...@@ -32,9 +32,6 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab,
int* count_rows, int* count_rows,
UtilTransactions::ScanLock lock); UtilTransactions::ScanLock lock);
enum ndb_select_count_options {
NDB_STD_OPTS_OPTIONS
};
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB"; static const char* _dbname = "TEST_DB";
...@@ -54,16 +51,12 @@ static struct my_option my_long_options[] = ...@@ -54,16 +51,12 @@ static struct my_option my_long_options[] =
GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 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} { 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() static void usage()
{ {
char desc[] = char desc[] =
"tabname1 ... tabnameN\n"\ "tabname1 ... tabnameN\n"\
"This program will count the number of records in tables\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_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
...@@ -71,18 +64,8 @@ static my_bool ...@@ -71,18 +64,8 @@ static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_select_count.trace");
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;
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
......
...@@ -31,8 +31,7 @@ waitClusterStatus(const char* _addr, ndb_mgm_node_status _status, ...@@ -31,8 +31,7 @@ waitClusterStatus(const char* _addr, ndb_mgm_node_status _status,
unsigned int _timeout); unsigned int _timeout);
enum ndb_waiter_options { enum ndb_waiter_options {
NDB_STD_OPTS_OPTIONS, OPT_WAIT_STATUS_NOT_STARTED = NDB_STD_OPTIONS_LAST
OPT_WAIT_STATUS_NOT_STARTED
}; };
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
...@@ -53,32 +52,20 @@ static struct my_option my_long_options[] = ...@@ -53,32 +52,20 @@ static struct my_option my_long_options[] =
GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 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} { 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() static void usage()
{ {
print_version(); ndb_std_print_version();
my_print_help(my_long_options); my_print_help(my_long_options);
my_print_variables(my_long_options); my_print_variables(my_long_options);
} }
static my_bool static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument)
{ {
switch (optid) { return ndb_std_get_one_option(optid, opt, argument ? argument :
case '#': "d:t:O,/tmp/ndb_drop_table.trace");
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;
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment