Commit 905db498 authored by unknown's avatar unknown

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1

into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1-clean

parents bd6634ad 3d3ad211
...@@ -78,15 +78,15 @@ public: ...@@ -78,15 +78,15 @@ public:
STATIC_CONST( SignalLength = 3 ); STATIC_CONST( SignalLength = 3 );
enum ErrorCode { enum ErrorCode {
Undefined = 200, Undefined = 1340,
FailedToAllocateBuffers = 202, FailedToAllocateBuffers = 1342,
FailedToSetupFsBuffers = 203, FailedToSetupFsBuffers = 1343,
FailedToAllocateTables = 204, FailedToAllocateTables = 1344,
FailedInsertFileHeader = 205, FailedInsertFileHeader = 1345,
FailedInsertTableList = 206, FailedInsertTableList = 1346,
FailedAllocateTableMem = 207, FailedAllocateTableMem = 1347,
FailedToAllocateFileRecord = 208, FailedToAllocateFileRecord = 1348,
FailedToAllocateAttributeRecord = 209 FailedToAllocateAttributeRecord = 1349
}; };
private: private:
Uint32 backupId; Uint32 backupId;
......
...@@ -119,12 +119,13 @@ public: ...@@ -119,12 +119,13 @@ public:
private: private:
enum ErrorCodes { enum ErrorCodes {
Undefined = 100, Undefined = 1300,
IAmNotMaster = 101, IAmNotMaster = 1301,
OutOfBackupRecord = 102, OutOfBackupRecord = 1302,
OutOfResources = 103, OutOfResources = 1303,
SequenceFailure = 104, SequenceFailure = 1304,
BackupDefinitionNotImplemented = 105 BackupDefinitionNotImplemented = 1305,
CannotBackupDiskless = 1306
}; };
Uint32 senderData; Uint32 senderData;
Uint32 errorCode; Uint32 errorCode;
...@@ -232,13 +233,13 @@ public: ...@@ -232,13 +233,13 @@ public:
STATIC_CONST( SignalLength = 3 ); STATIC_CONST( SignalLength = 3 );
enum RequestType { enum RequestType {
ClientAbort = 1, ClientAbort = 1321,
BackupComplete = 2, BackupComplete = 1322,
BackupFailure = 3, // General backup failure coordinator -> slave BackupFailure = 1323, // General backup failure coordinator -> slave
LogBufferFull = 4, // slave -> coordinator LogBufferFull = 1324, // slave -> coordinator
FileOrScanError = 5, // slave -> coordinator FileOrScanError = 1325, // slave -> coordinator
BackupFailureDueToNodeFail = 6, // slave -> slave BackupFailureDueToNodeFail = 1326, // slave -> slave
OkToClean = 7 // master -> slave OkToClean = 1327 // master -> slave
}; };
private: private:
Uint32 requestType; Uint32 requestType;
......
...@@ -46,7 +46,8 @@ typedef enum ...@@ -46,7 +46,8 @@ typedef enum
ndberror_cl_internal_error = 12, ndberror_cl_internal_error = 12,
ndberror_cl_function_not_implemented = 13, ndberror_cl_function_not_implemented = 13,
ndberror_cl_unknown_error_code = 14, ndberror_cl_unknown_error_code = 14,
ndberror_cl_node_shutdown = 15 ndberror_cl_node_shutdown = 15,
ndberror_cl_configuration = 16
} ndberror_classification_enum; } ndberror_classification_enum;
......
...@@ -863,6 +863,13 @@ Backup::execBACKUP_REQ(Signal* signal) ...@@ -863,6 +863,13 @@ Backup::execBACKUP_REQ(Signal* signal)
sendBackupRef(senderRef, signal, senderData, BackupRef::IAmNotMaster); sendBackupRef(senderRef, signal, senderData, BackupRef::IAmNotMaster);
return; return;
}//if }//if
if (m_diskless)
{
sendBackupRef(senderRef, signal, senderData,
BackupRef::CannotBackupDiskless);
return;
}
if(dataLen32 != 0) { if(dataLen32 != 0) {
jam(); jam();
......
...@@ -526,6 +526,7 @@ public: ...@@ -526,6 +526,7 @@ public:
NdbNodeBitmask c_aliveNodes; NdbNodeBitmask c_aliveNodes;
DLList<BackupRecord> c_backups; DLList<BackupRecord> c_backups;
Config c_defaults; Config c_defaults;
Uint32 m_diskless;
STATIC_CONST(NO_OF_PAGES_META_FILE = 2); STATIC_CONST(NO_OF_PAGES_META_FILE = 2);
......
...@@ -42,6 +42,7 @@ Backup::Backup(const Configuration & conf) : ...@@ -42,6 +42,7 @@ Backup::Backup(const Configuration & conf) :
ndbrequire(p != 0); ndbrequire(p != 0);
Uint32 noBackups = 0, noTables = 0, noAttribs = 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); 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_DB_NO_ATTRIBUTES, &noAttribs)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_ATTRIBUTES, &noAttribs));
......
...@@ -54,10 +54,11 @@ class CommandInterpreter { ...@@ -54,10 +54,11 @@ class CommandInterpreter {
* *
* @return true until quit/bye/exit has been typed * @return true until quit/bye/exit has been typed
*/ */
int execute(const char *_line, int _try_reconnect=-1); int execute(const char *_line, int _try_reconnect=-1, int *error= 0);
private: private:
void printError(); void printError();
int execute_impl(const char *_line);
/** /**
* Analyse the command line, after the first token. * Analyse the command line, after the first token.
...@@ -121,7 +122,7 @@ class CommandInterpreter { ...@@ -121,7 +122,7 @@ class CommandInterpreter {
void executeStatus(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 executeEventReporting(int processId, const char* parameters, bool all);
void executeDumpState(int processId, const char* parameters, bool all); void executeDumpState(int processId, const char* parameters, bool all);
void executeStartBackup(char * parameters); int executeStartBackup(char * parameters);
void executeAbortBackup(char * parameters); void executeAbortBackup(char * parameters);
void executeRep(char* parameters); void executeRep(char* parameters);
...@@ -156,6 +157,7 @@ class CommandInterpreter { ...@@ -156,6 +157,7 @@ class CommandInterpreter {
bool connected; bool connected;
int m_verbose; int m_verbose;
int try_reconnect; int try_reconnect;
int m_error;
#ifdef HAVE_GLOBAL_REPLICATION #ifdef HAVE_GLOBAL_REPLICATION
NdbRepHandle m_repserver; NdbRepHandle m_repserver;
const char *rep_host; const char *rep_host;
...@@ -179,9 +181,9 @@ Ndb_mgmclient::~Ndb_mgmclient() ...@@ -179,9 +181,9 @@ Ndb_mgmclient::~Ndb_mgmclient()
{ {
delete m_cmd; delete m_cmd;
} }
int Ndb_mgmclient::execute(const char *_line, int _try_reconnect) int Ndb_mgmclient::execute(const char *_line, int _try_reconnect, int *error)
{ {
return m_cmd->execute(_line,_try_reconnect); return m_cmd->execute(_line,_try_reconnect,error);
} }
int int
Ndb_mgmclient::disconnect() Ndb_mgmclient::disconnect()
...@@ -227,7 +229,7 @@ extern "C" { ...@@ -227,7 +229,7 @@ extern "C" {
#include <util/InputStream.hpp> #include <util/InputStream.hpp>
#include <util/OutputStream.hpp> #include <util/OutputStream.hpp>
int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect) int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect, int *error)
{ {
if (argc <= 0) if (argc <= 0)
return 0; return 0;
...@@ -236,7 +238,7 @@ int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect) ...@@ -236,7 +238,7 @@ int Ndb_mgmclient::execute(int argc, char** argv, int _try_reconnect)
{ {
_line.appfmt(" %s", argv[i]); _line.appfmt(" %s", argv[i]);
} }
return m_cmd->execute(_line.c_str(),_try_reconnect); return m_cmd->execute(_line.c_str(),_try_reconnect, error);
} }
/***************************************************************************** /*****************************************************************************
...@@ -277,7 +279,7 @@ static const char* helpText = ...@@ -277,7 +279,7 @@ static const char* helpText =
"REP CONNECT <host:port> Connect to REP server on host:port\n" "REP CONNECT <host:port> Connect to REP server on host:port\n"
#endif #endif
"PURGE STALE SESSIONS Reset reserved nodeid's in the mgmt server\n" "PURGE STALE SESSIONS Reset reserved nodeid's in the mgmt server\n"
"CONNECT Connect to management server (reconnect if already connected)\n" "CONNECT [<connectstring>] Connect to management server (reconnect if already connected)\n"
"QUIT Quit management client\n" "QUIT Quit management client\n"
; ;
...@@ -469,13 +471,24 @@ CommandInterpreter::disconnect() ...@@ -469,13 +471,24 @@ CommandInterpreter::disconnect()
//***************************************************************************** //*****************************************************************************
int int
CommandInterpreter::execute(const char *_line, int _try_reconnect) CommandInterpreter::execute(const char *_line, int _try_reconnect,
int *error)
{ {
DBUG_ENTER("CommandInterpreter::execute");
DBUG_PRINT("info",("line=\"%s\"",_line));
if (_try_reconnect >= 0) if (_try_reconnect >= 0)
try_reconnect=_try_reconnect; try_reconnect=_try_reconnect;
int result= execute_impl(_line);
if (error)
*error= m_error;
return result;
}
int
CommandInterpreter::execute_impl(const char *_line)
{
DBUG_ENTER("CommandInterpreter::execute_impl");
DBUG_PRINT("enter",("line=\"%s\"",_line));
m_error= 0;
char * line; char * line;
if(_line == NULL) { if(_line == NULL) {
// ndbout << endl; // ndbout << endl;
...@@ -488,20 +501,16 @@ CommandInterpreter::execute(const char *_line, int _try_reconnect) ...@@ -488,20 +501,16 @@ CommandInterpreter::execute(const char *_line, int _try_reconnect)
DBUG_RETURN(true); DBUG_RETURN(true);
} }
for (unsigned int i = 0; i < strlen(line); ++i) {
line[i] = toupper(line[i]);
}
// if there is anything in the line proceed // if there is anything in the line proceed
char* firstToken = strtok(line, " "); char* firstToken = strtok(line, " ");
char* allAfterFirstToken = strtok(NULL, ""); char* allAfterFirstToken = strtok(NULL, "");
if (strcmp(firstToken, "HELP") == 0 || if (strcasecmp(firstToken, "HELP") == 0 ||
strcmp(firstToken, "?") == 0) { strcasecmp(firstToken, "?") == 0) {
executeHelp(allAfterFirstToken); executeHelp(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if (strcmp(firstToken, "CONNECT") == 0) { else if (strcasecmp(firstToken, "CONNECT") == 0) {
executeConnect(allAfterFirstToken); executeConnect(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
...@@ -509,61 +518,61 @@ CommandInterpreter::execute(const char *_line, int _try_reconnect) ...@@ -509,61 +518,61 @@ CommandInterpreter::execute(const char *_line, int _try_reconnect)
if (!connect()) if (!connect())
DBUG_RETURN(true); DBUG_RETURN(true);
if (strcmp(firstToken, "SHOW") == 0) { if (strcasecmp(firstToken, "SHOW") == 0) {
executeShow(allAfterFirstToken); executeShow(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if (strcmp(firstToken, "SHUTDOWN") == 0) { else if (strcasecmp(firstToken, "SHUTDOWN") == 0) {
executeShutdown(allAfterFirstToken); executeShutdown(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if (strcmp(firstToken, "CLUSTERLOG") == 0){ else if (strcasecmp(firstToken, "CLUSTERLOG") == 0){
executeClusterLog(allAfterFirstToken); executeClusterLog(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if(strcmp(firstToken, "START") == 0 && else if(strcasecmp(firstToken, "START") == 0 &&
allAfterFirstToken != NULL && allAfterFirstToken != NULL &&
strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){
executeStartBackup(allAfterFirstToken); m_error= executeStartBackup(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if(strcmp(firstToken, "ABORT") == 0 && else if(strcasecmp(firstToken, "ABORT") == 0 &&
allAfterFirstToken != NULL && allAfterFirstToken != NULL &&
strncmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){ strncasecmp(allAfterFirstToken, "BACKUP", sizeof("BACKUP") - 1) == 0){
executeAbortBackup(allAfterFirstToken); executeAbortBackup(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if (strcmp(firstToken, "PURGE") == 0) { else if (strcasecmp(firstToken, "PURGE") == 0) {
executePurge(allAfterFirstToken); executePurge(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
#ifdef HAVE_GLOBAL_REPLICATION #ifdef HAVE_GLOBAL_REPLICATION
else if(strcmp(firstToken, "REPLICATION") == 0 || else if(strcasecmp(firstToken, "REPLICATION") == 0 ||
strcmp(firstToken, "REP") == 0) { strcasecmp(firstToken, "REP") == 0) {
executeRep(allAfterFirstToken); executeRep(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
#endif // HAVE_GLOBAL_REPLICATION #endif // HAVE_GLOBAL_REPLICATION
else if(strcmp(firstToken, "ENTER") == 0 && else if(strcasecmp(firstToken, "ENTER") == 0 &&
allAfterFirstToken != NULL && allAfterFirstToken != NULL &&
strncmp(allAfterFirstToken, "SINGLE USER MODE ", strncasecmp(allAfterFirstToken, "SINGLE USER MODE ",
sizeof("SINGLE USER MODE") - 1) == 0){ sizeof("SINGLE USER MODE") - 1) == 0){
executeEnterSingleUser(allAfterFirstToken); executeEnterSingleUser(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if(strcmp(firstToken, "EXIT") == 0 && else if(strcasecmp(firstToken, "EXIT") == 0 &&
allAfterFirstToken != NULL && allAfterFirstToken != NULL &&
strncmp(allAfterFirstToken, "SINGLE USER MODE ", strncasecmp(allAfterFirstToken, "SINGLE USER MODE ",
sizeof("SINGLE USER MODE") - 1) == 0){ sizeof("SINGLE USER MODE") - 1) == 0){
executeExitSingleUser(allAfterFirstToken); executeExitSingleUser(allAfterFirstToken);
DBUG_RETURN(true); DBUG_RETURN(true);
} }
else if (strcmp(firstToken, "ALL") == 0) { else if (strcasecmp(firstToken, "ALL") == 0) {
analyseAfterFirstToken(-1, allAfterFirstToken); analyseAfterFirstToken(-1, allAfterFirstToken);
} }
else if((strcmp(firstToken, "QUIT") == 0 || else if((strcasecmp(firstToken, "QUIT") == 0 ||
strcmp(firstToken, "EXIT") == 0 || strcasecmp(firstToken, "EXIT") == 0 ||
strcmp(firstToken, "BYE") == 0) && strcasecmp(firstToken, "BYE") == 0) &&
allAfterFirstToken == NULL){ allAfterFirstToken == NULL){
DBUG_RETURN(false); DBUG_RETURN(false);
} else { } else {
...@@ -573,12 +582,12 @@ CommandInterpreter::execute(const char *_line, int _try_reconnect) ...@@ -573,12 +582,12 @@ CommandInterpreter::execute(const char *_line, int _try_reconnect)
int nodeId; int nodeId;
if (! convert(firstToken, nodeId)) { if (! convert(firstToken, nodeId)) {
ndbout << "Invalid command: " << line << endl; ndbout << "Invalid command: " << _line << endl;
ndbout << "Type HELP for help." << endl << endl; ndbout << "Type HELP for help." << endl << endl;
DBUG_RETURN(true); DBUG_RETURN(true);
} }
if (nodeId < 0) { if (nodeId <= 0) {
ndbout << "Invalid node ID: " << firstToken << "." << endl; ndbout << "Invalid node ID: " << firstToken << "." << endl;
DBUG_RETURN(true); DBUG_RETURN(true);
} }
...@@ -639,7 +648,7 @@ CommandInterpreter::analyseAfterFirstToken(int processId, ...@@ -639,7 +648,7 @@ CommandInterpreter::analyseAfterFirstToken(int processId,
ExecuteFunction fun = 0; ExecuteFunction fun = 0;
const char * command = 0; const char * command = 0;
for(int i = 0; i<tmpSize; i++){ 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; fun = commands[i].executeFunction;
command = commands[i].command; command = commands[i].command;
break; break;
...@@ -655,7 +664,7 @@ CommandInterpreter::analyseAfterFirstToken(int processId, ...@@ -655,7 +664,7 @@ CommandInterpreter::analyseAfterFirstToken(int processId,
if(processId == -1){ if(processId == -1){
executeForAll(command, fun, allAfterSecondToken); executeForAll(command, fun, allAfterSecondToken);
} else { } else {
if(strcmp(command, "STATUS") != 0) if(strcasecmp(command, "STATUS") != 0)
ndbout_c("Executing %s on node %d.", command, processId); ndbout_c("Executing %s on node %d.", command, processId);
(this->*fun)(processId, allAfterSecondToken, false); (this->*fun)(processId, allAfterSecondToken, false);
ndbout << endl; ndbout << endl;
...@@ -705,10 +714,10 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, ...@@ -705,10 +714,10 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun,
const char * allAfterSecondToken) const char * allAfterSecondToken)
{ {
int nodeId = 0; int nodeId = 0;
if(strcmp(cmd, "STOP") == 0) { if(strcasecmp(cmd, "STOP") == 0) {
ndbout_c("Executing STOP on all nodes."); ndbout_c("Executing STOP on all nodes.");
(this->*fun)(nodeId, allAfterSecondToken, true); (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("Executing RESTART on all nodes.");
ndbout_c("Starting shutdown. This may take a while. Please wait..."); ndbout_c("Starting shutdown. This may take a while. Please wait...");
(this->*fun)(nodeId, allAfterSecondToken, true); (this->*fun)(nodeId, allAfterSecondToken, true);
...@@ -723,7 +732,7 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun, ...@@ -723,7 +732,7 @@ CommandInterpreter::executeForAll(const char * cmd, ExecuteFunction fun,
} }
NdbAutoPtr<char> ap1((char*)cl); NdbAutoPtr<char> ap1((char*)cl);
while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) { while(get_next_nodeid(cl, &nodeId, NDB_MGM_NODE_TYPE_NDB)) {
if(strcmp(cmd, "STATUS") != 0) if(strcasecmp(cmd, "STATUS") != 0)
ndbout_c("Executing %s on node %d.", cmd, nodeId); ndbout_c("Executing %s on node %d.", cmd, nodeId);
(this->*fun)(nodeId, allAfterSecondToken, true); (this->*fun)(nodeId, allAfterSecondToken, true);
ndbout << endl; ndbout << endl;
...@@ -751,7 +760,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog, ...@@ -751,7 +760,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog,
firstTokenAfterLog[i] = toupper(firstTokenAfterLog[i]); firstTokenAfterLog[i] = toupper(firstTokenAfterLog[i]);
} }
if (strcmp(firstTokenAfterLog, "BLOCK") != 0) { if (strcasecmp(firstTokenAfterLog, "BLOCK") != 0) {
ndbout << "Unexpected value: " << firstTokenAfterLog ndbout << "Unexpected value: " << firstTokenAfterLog
<< ". Expected BLOCK." << endl; << ". Expected BLOCK." << endl;
return false; return false;
...@@ -764,7 +773,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog, ...@@ -764,7 +773,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog,
} }
char* secondTokenAfterLog = strtok(allAfterFirstToken, " "); char* secondTokenAfterLog = strtok(allAfterFirstToken, " ");
if (strcmp(secondTokenAfterLog, "=") != 0) { if (strcasecmp(secondTokenAfterLog, "=") != 0) {
ndbout << "Unexpected value: " << secondTokenAfterLog ndbout << "Unexpected value: " << secondTokenAfterLog
<< ". Expected =." << endl; << ". Expected =." << endl;
return false; return false;
...@@ -772,7 +781,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog, ...@@ -772,7 +781,7 @@ CommandInterpreter::parseBlockSpecification(const char* allAfterLog,
char* blockName = strtok(NULL, " "); char* blockName = strtok(NULL, " ");
bool all = false; bool all = false;
if (blockName != NULL && (strcmp(blockName, "ALL") == 0)) { if (blockName != NULL && (strcasecmp(blockName, "ALL") == 0)) {
all = true; all = true;
} }
while (blockName != NULL) { while (blockName != NULL) {
...@@ -823,15 +832,15 @@ CommandInterpreter::executeHelp(char* parameters) ...@@ -823,15 +832,15 @@ CommandInterpreter::executeHelp(char* parameters)
ndbout << "<level> = " << "0 - 15" << endl; ndbout << "<level> = " << "0 - 15" << endl;
ndbout << "<id> = " << "ALL | Any database node id" << endl; ndbout << "<id> = " << "ALL | Any database node id" << endl;
ndbout << endl; ndbout << endl;
} else if (strcmp(parameters, "SHOW") == 0) { } else if (strcasecmp(parameters, "SHOW") == 0) {
ndbout << helpTextShow; ndbout << helpTextShow;
#ifdef HAVE_GLOBAL_REPLICATION #ifdef HAVE_GLOBAL_REPLICATION
} else if (strcmp(parameters, "REPLICATION") == 0 || } else if (strcasecmp(parameters, "REPLICATION") == 0 ||
strcmp(parameters, "REP") == 0) { strcasecmp(parameters, "REP") == 0) {
ndbout << helpTextRep; ndbout << helpTextRep;
#endif // HAVE_GLOBAL_REPLICATION #endif // HAVE_GLOBAL_REPLICATION
#ifdef VM_TRACE // DEBUG ONLY #ifdef VM_TRACE // DEBUG ONLY
} else if (strcmp(parameters, "DEBUG") == 0) { } else if (strcasecmp(parameters, "DEBUG") == 0) {
ndbout << helpTextDebug; ndbout << helpTextDebug;
#endif #endif
} else { } else {
...@@ -939,7 +948,7 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it, ...@@ -939,7 +948,7 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it,
const char *hostname= node_state->connect_address; const char *hostname= node_state->connect_address;
if (hostname == 0 if (hostname == 0
|| strlen(hostname) == 0 || strlen(hostname) == 0
|| strcmp(hostname,"0.0.0.0") == 0) || strcasecmp(hostname,"0.0.0.0") == 0)
ndbout << " "; ndbout << " ";
else else
ndbout << "\t@" << hostname; ndbout << "\t@" << hostname;
...@@ -984,9 +993,9 @@ CommandInterpreter::executePurge(char* parameters) ...@@ -984,9 +993,9 @@ CommandInterpreter::executePurge(char* parameters)
break; break;
char* firstToken = strtok(parameters, " "); char* firstToken = strtok(parameters, " ");
char* nextToken = strtok(NULL, " \0"); char* nextToken = strtok(NULL, " \0");
if (strcmp(firstToken,"STALE") == 0 && if (strcasecmp(firstToken,"STALE") == 0 &&
nextToken && nextToken &&
strcmp(nextToken, "SESSIONS") == 0) { strcasecmp(nextToken, "SESSIONS") == 0) {
command_ok= 1; command_ok= 1;
break; break;
} }
...@@ -1086,17 +1095,17 @@ CommandInterpreter::executeShow(char* parameters) ...@@ -1086,17 +1095,17 @@ CommandInterpreter::executeShow(char* parameters)
print_nodes(state, it, "mysqld", api_nodes, NDB_MGM_NODE_TYPE_API, 0); print_nodes(state, it, "mysqld", api_nodes, NDB_MGM_NODE_TYPE_API, 0);
// ndbout << helpTextShow; // ndbout << helpTextShow;
return; return;
} else if (strcmp(parameters, "PROPERTIES") == 0 || } else if (strcasecmp(parameters, "PROPERTIES") == 0 ||
strcmp(parameters, "PROP") == 0) { strcasecmp(parameters, "PROP") == 0) {
ndbout << "SHOW PROPERTIES is not yet implemented." << endl; ndbout << "SHOW PROPERTIES is not yet implemented." << endl;
// ndbout << "_mgmtSrvr.getConfig()->print();" << endl; /* XXX */ // ndbout << "_mgmtSrvr.getConfig()->print();" << endl; /* XXX */
} else if (strcmp(parameters, "CONFIGURATION") == 0 || } else if (strcasecmp(parameters, "CONFIGURATION") == 0 ||
strcmp(parameters, "CONFIG") == 0){ strcasecmp(parameters, "CONFIG") == 0){
ndbout << "SHOW CONFIGURATION is not yet implemented." << endl; ndbout << "SHOW CONFIGURATION is not yet implemented." << endl;
//nbout << "_mgmtSrvr.getConfig()->printConfigFile();" << endl; /* XXX */ //nbout << "_mgmtSrvr.getConfig()->printConfigFile();" << endl; /* XXX */
} else if (strcmp(parameters, "PARAMETERS") == 0 || } else if (strcasecmp(parameters, "PARAMETERS") == 0 ||
strcmp(parameters, "PARAMS") == 0 || strcasecmp(parameters, "PARAMS") == 0 ||
strcmp(parameters, "PARAM") == 0) { strcasecmp(parameters, "PARAM") == 0) {
ndbout << "SHOW PARAMETERS is not yet implemented." << endl; ndbout << "SHOW PARAMETERS is not yet implemented." << endl;
// ndbout << "_mgmtSrvr.getConfig()->getConfigInfo()->print();" // ndbout << "_mgmtSrvr.getConfig()->getConfigInfo()->print();"
// << endl; /* XXX */ // << endl; /* XXX */
...@@ -1109,6 +1118,14 @@ void ...@@ -1109,6 +1118,14 @@ void
CommandInterpreter::executeConnect(char* parameters) CommandInterpreter::executeConnect(char* parameters)
{ {
disconnect(); disconnect();
if (!emptyString(parameters)) {
if (ndb_mgm_set_connectstring(m_mgmsrv,
BaseString(parameters).trim().c_str()))
{
printError();
return;
}
}
connect(); connect();
} }
...@@ -1132,7 +1149,7 @@ CommandInterpreter::executeClusterLog(char* parameters) ...@@ -1132,7 +1149,7 @@ CommandInterpreter::executeClusterLog(char* parameters)
/******************** /********************
* CLUSTERLOG FILTER * CLUSTERLOG FILTER
********************/ ********************/
if (strcmp(item, "FILTER") == 0) { if (strcasecmp(item, "FILTER") == 0) {
item = strtok_r(NULL, " ", &tmpPtr); item = strtok_r(NULL, " ", &tmpPtr);
if (item == NULL) { if (item == NULL) {
...@@ -1141,21 +1158,21 @@ CommandInterpreter::executeClusterLog(char* parameters) ...@@ -1141,21 +1158,21 @@ CommandInterpreter::executeClusterLog(char* parameters)
while (item != NULL) { while (item != NULL) {
snprintf(name, sizeof(name), item); snprintf(name, sizeof(name), item);
if (strcmp(item, "ALL") == 0) { if (strcasecmp(item, "ALL") == 0) {
severity = NDB_MGM_CLUSTERLOG_ALL; severity = NDB_MGM_CLUSTERLOG_ALL;
} else if (strcmp(item, "ALERT") == 0) { } else if (strcasecmp(item, "ALERT") == 0) {
severity = NDB_MGM_CLUSTERLOG_ALERT; severity = NDB_MGM_CLUSTERLOG_ALERT;
} else if (strcmp(item, "CRITICAL") == 0) { } else if (strcasecmp(item, "CRITICAL") == 0) {
severity = NDB_MGM_CLUSTERLOG_CRITICAL; severity = NDB_MGM_CLUSTERLOG_CRITICAL;
} else if (strcmp(item, "ERROR") == 0) { } else if (strcasecmp(item, "ERROR") == 0) {
severity = NDB_MGM_CLUSTERLOG_ERROR; severity = NDB_MGM_CLUSTERLOG_ERROR;
} else if (strcmp(item, "WARNING") == 0) { } else if (strcasecmp(item, "WARNING") == 0) {
severity = NDB_MGM_CLUSTERLOG_WARNING; severity = NDB_MGM_CLUSTERLOG_WARNING;
} else if (strcmp(item, "INFO") == 0) { } else if (strcasecmp(item, "INFO") == 0) {
severity = NDB_MGM_CLUSTERLOG_INFO; severity = NDB_MGM_CLUSTERLOG_INFO;
} else if (strcmp(item, "DEBUG") == 0) { } else if (strcasecmp(item, "DEBUG") == 0) {
severity = NDB_MGM_CLUSTERLOG_DEBUG; severity = NDB_MGM_CLUSTERLOG_DEBUG;
} else if (strcmp(item, "OFF") == 0) { } else if (strcasecmp(item, "OFF") == 0) {
severity = NDB_MGM_CLUSTERLOG_OFF; severity = NDB_MGM_CLUSTERLOG_OFF;
} else { } else {
isOk = false; isOk = false;
...@@ -1168,17 +1185,17 @@ CommandInterpreter::executeClusterLog(char* parameters) ...@@ -1168,17 +1185,17 @@ CommandInterpreter::executeClusterLog(char* parameters)
ndbout << "Missing argument(s)." << endl; ndbout << "Missing argument(s)." << endl;
} else if (isOk) { } else if (isOk) {
if(ndb_mgm_filter_clusterlog(m_mgmsrv, severity, NULL)) { if(ndb_mgm_filter_clusterlog(m_mgmsrv, severity, NULL)) {
if(strcmp(name, "ALL") == 0 || strcmp(name, "all") == 0) { if(strcasecmp(name, "ALL") == 0) {
ndbout << "All severities levels enabled." << endl; ndbout << "All severities levels enabled." << endl;
} else if(strcmp(name, "OFF") == 0 || strcmp(name, "off") == 0) { } else if(strcasecmp(name, "OFF") == 0) {
ndbout << "Cluster logging enabled." << endl; ndbout << "Cluster logging enabled." << endl;
} else { } else {
ndbout << name << " events disabled." << endl; ndbout << name << " events disabled." << endl;
} }
} else { } else {
if(strcmp(name, "ALL") == 0) { if(strcasecmp(name, "ALL") == 0) {
ndbout << "All severities levels disabled." << endl; ndbout << "All severities levels disabled." << endl;
} else if(strcmp(name, "OFF") == 0) { } else if(strcasecmp(name, "OFF") == 0) {
ndbout << "Cluster logging disabled." << endl; ndbout << "Cluster logging disabled." << endl;
} else { } else {
ndbout << name << " events enabled." << endl; ndbout << name << " events enabled." << endl;
...@@ -1191,7 +1208,7 @@ CommandInterpreter::executeClusterLog(char* parameters) ...@@ -1191,7 +1208,7 @@ CommandInterpreter::executeClusterLog(char* parameters)
/******************** /********************
* CLUSTERLOG INFO * CLUSTERLOG INFO
********************/ ********************/
} else if (strcmp(item, "INFO") == 0) { } else if (strcasecmp(item, "INFO") == 0) {
Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv);
if(enabled == NULL) { if(enabled == NULL) {
ndbout << "Couldn't get status" << endl; ndbout << "Couldn't get status" << endl;
...@@ -1216,7 +1233,7 @@ CommandInterpreter::executeClusterLog(char* parameters) ...@@ -1216,7 +1233,7 @@ CommandInterpreter::executeClusterLog(char* parameters)
/******************** /********************
* CLUSTERLOG OFF * CLUSTERLOG OFF
********************/ ********************/
} else if (strcmp(item, "OFF") == 0) { } else if (strcasecmp(item, "OFF") == 0) {
Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv);
if(enabled == NULL) { if(enabled == NULL) {
ndbout << "Couldn't get status" << endl; ndbout << "Couldn't get status" << endl;
...@@ -1234,7 +1251,7 @@ CommandInterpreter::executeClusterLog(char* parameters) ...@@ -1234,7 +1251,7 @@ CommandInterpreter::executeClusterLog(char* parameters)
/******************** /********************
* CLUSTERLOG ON * CLUSTERLOG ON
********************/ ********************/
} else if (strcmp(item, "ON") == 0) { } else if (strcasecmp(item, "ON") == 0) {
Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv); Uint32 *enabled = ndb_mgm_get_logfilter(m_mgmsrv);
if(enabled == NULL) { if(enabled == NULL) {
ndbout << "Could not get status" << endl; ndbout << "Could not get status" << endl;
...@@ -1358,11 +1375,11 @@ CommandInterpreter::executeRestart(int processId, const char* parameters, ...@@ -1358,11 +1375,11 @@ CommandInterpreter::executeRestart(int processId, const char* parameters,
char * tmpPtr = 0; char * tmpPtr = 0;
char * item = strtok_r(tmpString, " ", &tmpPtr); char * item = strtok_r(tmpString, " ", &tmpPtr);
while(item != NULL){ while(item != NULL){
if(strcmp(item, "-N") == 0) if(strcasecmp(item, "-N") == 0)
nostart = 1; nostart = 1;
if(strcmp(item, "-I") == 0) if(strcasecmp(item, "-I") == 0)
initialstart = 1; initialstart = 1;
if(strcmp(item, "-A") == 0) if(strcasecmp(item, "-A") == 0)
abort = 1; abort = 1;
item = strtok_r(NULL, " ", &tmpPtr); item = strtok_r(NULL, " ", &tmpPtr);
} }
...@@ -1591,7 +1608,7 @@ CommandInterpreter::executeTrace(int /*processId*/, ...@@ -1591,7 +1608,7 @@ CommandInterpreter::executeTrace(int /*processId*/,
int result = _mgmtSrvr.setTraceNo(processId, traceNo); int result = _mgmtSrvr.setTraceNo(processId, traceNo);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
#endif #endif
} }
...@@ -1751,7 +1768,7 @@ CommandInterpreter::executeSet(int /*processId*/, ...@@ -1751,7 +1768,7 @@ CommandInterpreter::executeSet(int /*processId*/,
} }
} }
else { else {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
if (configBackupFileUpdated && configPrimaryFileUpdated) { if (configBackupFileUpdated && configPrimaryFileUpdated) {
ndbout << "The configuration files are however updated and " ndbout << "The configuration files are however updated and "
<< "the value will be used next time the process is restarted." << "the value will be used next time the process is restarted."
...@@ -1786,7 +1803,7 @@ void CommandInterpreter::executeGetStat(int /*processId*/, ...@@ -1786,7 +1803,7 @@ void CommandInterpreter::executeGetStat(int /*processId*/,
MgmtSrvr::Statistics statistics; MgmtSrvr::Statistics statistics;
int result = _mgmtSrvr.getStatistics(processId, statistics); int result = _mgmtSrvr.getStatistics(processId, statistics);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
return; return;
} }
#endif #endif
...@@ -1856,7 +1873,7 @@ CommandInterpreter::executeEventReporting(int processId, ...@@ -1856,7 +1873,7 @@ CommandInterpreter::executeEventReporting(int processId,
/***************************************************************************** /*****************************************************************************
* Backup * Backup
*****************************************************************************/ *****************************************************************************/
void int
CommandInterpreter::executeStartBackup(char* /*parameters*/) CommandInterpreter::executeStartBackup(char* /*parameters*/)
{ {
struct ndb_mgm_reply reply; struct ndb_mgm_reply reply;
...@@ -1869,7 +1886,7 @@ CommandInterpreter::executeStartBackup(char* /*parameters*/) ...@@ -1869,7 +1886,7 @@ CommandInterpreter::executeStartBackup(char* /*parameters*/)
ndbout << "Start of backup failed" << endl; ndbout << "Start of backup failed" << endl;
printError(); printError();
close(fd); close(fd);
return; return result;
} }
char *tmp; char *tmp;
...@@ -1900,6 +1917,7 @@ CommandInterpreter::executeStartBackup(char* /*parameters*/) ...@@ -1900,6 +1917,7 @@ CommandInterpreter::executeStartBackup(char* /*parameters*/)
} while(tmp && tmp[0] != 0); } while(tmp && tmp[0] != 0);
close(fd); close(fd);
return 0;
} }
void void
...@@ -1966,7 +1984,7 @@ CommandInterpreter::executeRep(char* parameters) ...@@ -1966,7 +1984,7 @@ CommandInterpreter::executeRep(char* parameters)
unsigned int repId; unsigned int repId;
if (!strcmp(firstToken, "CONNECT")) { if (!strcasecmp(firstToken, "CONNECT")) {
char * host = strtok(NULL, "\0"); char * host = strtok(NULL, "\0");
for (unsigned int i = 0; i < strlen(host); ++i) { for (unsigned int i = 0; i < strlen(host); ++i) {
host[i] = tolower(host[i]); host[i] = tolower(host[i]);
...@@ -2001,30 +2019,30 @@ CommandInterpreter::executeRep(char* parameters) ...@@ -2001,30 +2019,30 @@ CommandInterpreter::executeRep(char* parameters)
/******** /********
* START * START
********/ ********/
if (!strcmp(firstToken, "START")) { if (!strcasecmp(firstToken, "START")) {
unsigned int req; unsigned int req;
char *startType = strtok(NULL, "\0"); char *startType = strtok(NULL, "\0");
if (startType == NULL) { if (startType == NULL) {
req = GrepReq::START; req = GrepReq::START;
} else if (!strcmp(startType, "SUBSCRIPTION")) { } else if (!strcasecmp(startType, "SUBSCRIPTION")) {
req = GrepReq::START_SUBSCR; req = GrepReq::START_SUBSCR;
} else if (!strcmp(startType, "METALOG")) { } else if (!strcasecmp(startType, "METALOG")) {
req = GrepReq::START_METALOG; req = GrepReq::START_METALOG;
} else if (!strcmp(startType, "METASCAN")) { } else if (!strcasecmp(startType, "METASCAN")) {
req = GrepReq::START_METASCAN; req = GrepReq::START_METASCAN;
} else if (!strcmp(startType, "DATALOG")) { } else if (!strcasecmp(startType, "DATALOG")) {
req = GrepReq::START_DATALOG; req = GrepReq::START_DATALOG;
} else if (!strcmp(startType, "DATASCAN")) { } else if (!strcasecmp(startType, "DATASCAN")) {
req = GrepReq::START_DATASCAN; req = GrepReq::START_DATASCAN;
} else if (!strcmp(startType, "REQUESTOR")) { } else if (!strcasecmp(startType, "REQUESTOR")) {
req = GrepReq::START_REQUESTOR; req = GrepReq::START_REQUESTOR;
} else if (!strcmp(startType, "TRANSFER")) { } else if (!strcasecmp(startType, "TRANSFER")) {
req = GrepReq::START_TRANSFER; req = GrepReq::START_TRANSFER;
} else if (!strcmp(startType, "APPLY")) { } else if (!strcasecmp(startType, "APPLY")) {
req = GrepReq::START_APPLY; req = GrepReq::START_APPLY;
} else if (!strcmp(startType, "DELETE")) { } else if (!strcasecmp(startType, "DELETE")) {
req = GrepReq::START_DELETE; req = GrepReq::START_DELETE;
} else { } else {
ndbout_c("Illegal argument to command 'REPLICATION START'"); ndbout_c("Illegal argument to command 'REPLICATION START'");
...@@ -2044,7 +2062,7 @@ CommandInterpreter::executeRep(char* parameters) ...@@ -2044,7 +2062,7 @@ CommandInterpreter::executeRep(char* parameters)
/******** /********
* STOP * STOP
********/ ********/
if (!strcmp(firstToken, "STOP")) { if (!strcasecmp(firstToken, "STOP")) {
unsigned int req; unsigned int req;
char *startType = strtok(NULL, " "); char *startType = strtok(NULL, " ");
unsigned int epoch = 0; unsigned int epoch = 0;
...@@ -2054,7 +2072,7 @@ CommandInterpreter::executeRep(char* parameters) ...@@ -2054,7 +2072,7 @@ CommandInterpreter::executeRep(char* parameters)
* Stop immediately * Stop immediately
*/ */
req = GrepReq::STOP; req = GrepReq::STOP;
} else if (!strcmp(startType, "EPOCH")) { } else if (!strcasecmp(startType, "EPOCH")) {
char *strEpoch = strtok(NULL, "\0"); char *strEpoch = strtok(NULL, "\0");
if(strEpoch == NULL) { if(strEpoch == NULL) {
ndbout_c("Epoch expected!"); ndbout_c("Epoch expected!");
...@@ -2062,23 +2080,23 @@ CommandInterpreter::executeRep(char* parameters) ...@@ -2062,23 +2080,23 @@ CommandInterpreter::executeRep(char* parameters)
} }
req = GrepReq::STOP; req = GrepReq::STOP;
epoch=atoi(strEpoch); epoch=atoi(strEpoch);
} else if (!strcmp(startType, "SUBSCRIPTION")) { } else if (!strcasecmp(startType, "SUBSCRIPTION")) {
req = GrepReq::STOP_SUBSCR; req = GrepReq::STOP_SUBSCR;
} else if (!strcmp(startType, "METALOG")) { } else if (!strcasecmp(startType, "METALOG")) {
req = GrepReq::STOP_METALOG; req = GrepReq::STOP_METALOG;
} else if (!strcmp(startType, "METASCAN")) { } else if (!strcasecmp(startType, "METASCAN")) {
req = GrepReq::STOP_METASCAN; req = GrepReq::STOP_METASCAN;
} else if (!strcmp(startType, "DATALOG")) { } else if (!strcasecmp(startType, "DATALOG")) {
req = GrepReq::STOP_DATALOG; req = GrepReq::STOP_DATALOG;
} else if (!strcmp(startType, "DATASCAN")) { } else if (!strcasecmp(startType, "DATASCAN")) {
req = GrepReq::STOP_DATASCAN; req = GrepReq::STOP_DATASCAN;
} else if (!strcmp(startType, "REQUESTOR")) { } else if (!strcasecmp(startType, "REQUESTOR")) {
req = GrepReq::STOP_REQUESTOR; req = GrepReq::STOP_REQUESTOR;
} else if (!strcmp(startType, "TRANSFER")) { } else if (!strcasecmp(startType, "TRANSFER")) {
req = GrepReq::STOP_TRANSFER; req = GrepReq::STOP_TRANSFER;
} else if (!strcmp(startType, "APPLY")) { } else if (!strcasecmp(startType, "APPLY")) {
req = GrepReq::STOP_APPLY; req = GrepReq::STOP_APPLY;
} else if (!strcmp(startType, "DELETE")) { } else if (!strcasecmp(startType, "DELETE")) {
req = GrepReq::STOP_DELETE; req = GrepReq::STOP_DELETE;
} else { } else {
ndbout_c("Illegal argument to command 'REPLICATION STOP'"); ndbout_c("Illegal argument to command 'REPLICATION STOP'");
...@@ -2097,7 +2115,7 @@ CommandInterpreter::executeRep(char* parameters) ...@@ -2097,7 +2115,7 @@ CommandInterpreter::executeRep(char* parameters)
/********* /*********
* STATUS * STATUS
*********/ *********/
if (!strcmp(firstToken, "STATUS")) { if (!strcasecmp(firstToken, "STATUS")) {
struct rep_state repstate; struct rep_state repstate;
int result = int result =
ndb_rep_get_status(m_repserver, &repId, &reply, &repstate); ndb_rep_get_status(m_repserver, &repId, &reply, &repstate);
...@@ -2117,7 +2135,7 @@ CommandInterpreter::executeRep(char* parameters) ...@@ -2117,7 +2135,7 @@ CommandInterpreter::executeRep(char* parameters)
/********* /*********
* QUERY (see repapi.h for querable counters) * QUERY (see repapi.h for querable counters)
*********/ *********/
if (!strcmp(firstToken, "QUERY")) { if (!strcasecmp(firstToken, "QUERY")) {
char *query = strtok(NULL, "\0"); char *query = strtok(NULL, "\0");
int queryCounter=-1; int queryCounter=-1;
if(query != NULL) { if(query != NULL) {
......
...@@ -60,10 +60,15 @@ static const char default_prompt[]= "ndb_mgm> "; ...@@ -60,10 +60,15 @@ static const char default_prompt[]= "ndb_mgm> ";
static unsigned _try_reconnect; static unsigned _try_reconnect;
static char *opt_connect_str= 0; static char *opt_connect_str= 0;
static const char *prompt= default_prompt; static const char *prompt= default_prompt;
static char *opt_execute_str= 0;
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
{ {
NDB_STD_OPTS("ndb_mgm"), 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', { "try-reconnect", 't',
"Specify number of tries for connecting to ndb_mgmd (0 = infinite)", "Specify number of tries for connecting to ndb_mgmd (0 = infinite)",
(gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0, (gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0,
...@@ -156,19 +161,25 @@ int main(int argc, char** argv){ ...@@ -156,19 +161,25 @@ int main(int argc, char** argv){
opt_connect_str= buf; opt_connect_str= buf;
} }
if (!isatty(0)) if (!isatty(0) || opt_execute_str)
{ {
prompt= 0; prompt= 0;
} }
ndbout << "-- NDB Cluster -- Management Client --" << endl;
signal(SIGPIPE, handler); signal(SIGPIPE, handler);
com = new Ndb_mgmclient(opt_connect_str,1); com = new Ndb_mgmclient(opt_connect_str,1);
while(read_and_execute(_try_reconnect)); 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; delete com;
return 0; return ret;
} }
...@@ -23,8 +23,8 @@ class Ndb_mgmclient ...@@ -23,8 +23,8 @@ class Ndb_mgmclient
public: public:
Ndb_mgmclient(const char*,int verbose=0); Ndb_mgmclient(const char*,int verbose=0);
~Ndb_mgmclient(); ~Ndb_mgmclient();
int execute(const char *_line, int _try_reconnect=-1); int execute(const char *_line, int _try_reconnect=-1, int *error= 0);
int execute(int argc, char** argv, int _try_reconnect=-1); int execute(int argc, char** argv, int _try_reconnect=-1, int *error= 0);
int disconnect(); int disconnect();
private: private:
CommandInterpreter *m_cmd; CommandInterpreter *m_cmd;
......
...@@ -113,6 +113,11 @@ class AutoPtr { ...@@ -113,6 +113,11 @@ class AutoPtr {
void * m_ptr; 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() { int CommandInterpreter::readAndExecute() {
...@@ -600,8 +605,9 @@ stopCallback(int nodeId, void * anyData, int errCode){ ...@@ -600,8 +605,9 @@ stopCallback(int nodeId, void * anyData, int errCode){
ndbout << "\nNode " << nodeId << " has shutdown" << endl; ndbout << "\nNode " << nodeId << " has shutdown" << endl;
} else { } else {
MgmtSrvr * mgm = (MgmtSrvr *)anyData; MgmtSrvr * mgm = (MgmtSrvr *)anyData;
char err_str[1024];
ndbout << "Node " << nodeId << " has not shutdown: " ndbout << "Node " << nodeId << " has not shutdown: "
<< mgm->getErrorText(errCode) << endl; << mgm->getErrorText(errCode,err_str,sizeof(err_str)) << endl;
} }
} }
...@@ -653,7 +659,8 @@ versionCallback(int nodeId, int version, void * anyData, int errCode){ ...@@ -653,7 +659,8 @@ versionCallback(int nodeId, int version, void * anyData, int errCode){
} else { } else {
MgmtSrvr * mgm = (MgmtSrvr *)anyData; MgmtSrvr * mgm = (MgmtSrvr *)anyData;
ndbout << mgm->getErrorText(errCode) << endl; char err_str[1024];
ndbout << mgm->getErrorText(errCode,err_str,sizeof(err_str)) << endl;
} }
} }
...@@ -671,7 +678,7 @@ void CommandInterpreter::executeStop(int processId, ...@@ -671,7 +678,7 @@ void CommandInterpreter::executeStop(int processId,
result = _mgmtSrvr.stopNode(processId, false, stopCallback, this); result = _mgmtSrvr.stopNode(processId, false, stopCallback, this);
if(result != 0) if(result != 0)
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
...@@ -686,7 +693,7 @@ void CommandInterpreter::executeStart(int processId, const char* parameters, ...@@ -686,7 +693,7 @@ void CommandInterpreter::executeStart(int processId, const char* parameters,
int result = _mgmtSrvr.start(processId); int result = _mgmtSrvr.start(processId);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
} }
...@@ -719,7 +726,7 @@ CommandInterpreter::executeRestart(int processId, const char* parameters, ...@@ -719,7 +726,7 @@ CommandInterpreter::executeRestart(int processId, const char* parameters,
stopCallback, stopCallback,
this); this);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
} }
...@@ -760,7 +767,7 @@ CommandInterpreter::executeDumpState(int processId, const char* parameters, ...@@ -760,7 +767,7 @@ CommandInterpreter::executeDumpState(int processId, const char* parameters,
free(tmpString); free(tmpString);
int result = _mgmtSrvr.dumpState(processId, pars, no); int result = _mgmtSrvr.dumpState(processId, pars, no);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
} }
...@@ -781,7 +788,7 @@ void CommandInterpreter::executeStatus(int processId, ...@@ -781,7 +788,7 @@ void CommandInterpreter::executeStatus(int processId,
&status, &version, &startPhase, &system, &status, &version, &startPhase, &system,
&dynamicId, &nodeGroup, &connectCount); &dynamicId, &nodeGroup, &connectCount);
if(result != 0){ if(result != 0){
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
return; return;
} }
...@@ -875,7 +882,7 @@ void CommandInterpreter::executeLogLevel(int processId, ...@@ -875,7 +882,7 @@ void CommandInterpreter::executeLogLevel(int processId,
int result = _mgmtSrvr.setNodeLogLevel(processId, logLevel); int result = _mgmtSrvr.setNodeLogLevel(processId, logLevel);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
#endif #endif
} }
...@@ -913,7 +920,7 @@ void CommandInterpreter::executeError(int processId, ...@@ -913,7 +920,7 @@ void CommandInterpreter::executeError(int processId,
int result = _mgmtSrvr.insertError(processId, errorNo); int result = _mgmtSrvr.insertError(processId, errorNo);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
free(newpar); free(newpar);
} }
...@@ -953,7 +960,7 @@ void CommandInterpreter::executeTrace(int processId, ...@@ -953,7 +960,7 @@ void CommandInterpreter::executeTrace(int processId,
int result = _mgmtSrvr.setTraceNo(processId, traceNo); int result = _mgmtSrvr.setTraceNo(processId, traceNo);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
free(newpar); free(newpar);
} }
...@@ -974,7 +981,7 @@ void CommandInterpreter::executeLog(int processId, ...@@ -974,7 +981,7 @@ void CommandInterpreter::executeLog(int processId,
int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::InOut, blocks); int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::InOut, blocks);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
} }
...@@ -995,7 +1002,7 @@ void CommandInterpreter::executeLogIn(int processId, ...@@ -995,7 +1002,7 @@ void CommandInterpreter::executeLogIn(int processId,
int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::In, blocks); int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::In, blocks);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
} }
...@@ -1014,7 +1021,7 @@ void CommandInterpreter::executeLogOut(int processId, ...@@ -1014,7 +1021,7 @@ void CommandInterpreter::executeLogOut(int processId,
int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Out, blocks); int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Out, blocks);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
} }
...@@ -1035,7 +1042,7 @@ void CommandInterpreter::executeLogOff(int processId, ...@@ -1035,7 +1042,7 @@ void CommandInterpreter::executeLogOff(int processId,
int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Off, blocks); int result = _mgmtSrvr.setSignalLoggingMode(processId, MgmtSrvr::Off, blocks);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
} }
...@@ -1054,7 +1061,7 @@ void CommandInterpreter::executeTestOn(int processId, ...@@ -1054,7 +1061,7 @@ void CommandInterpreter::executeTestOn(int processId,
int result = _mgmtSrvr.startSignalTracing(processId); int result = _mgmtSrvr.startSignalTracing(processId);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
} }
...@@ -1073,7 +1080,7 @@ void CommandInterpreter::executeTestOff(int processId, ...@@ -1073,7 +1080,7 @@ void CommandInterpreter::executeTestOff(int processId,
int result = _mgmtSrvr.stopSignalTracing(processId); int result = _mgmtSrvr.stopSignalTracing(processId);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
} }
...@@ -1126,7 +1133,7 @@ void CommandInterpreter::executeEventReporting(int processId, ...@@ -1126,7 +1133,7 @@ void CommandInterpreter::executeEventReporting(int processId,
ndbout_c("processId %d", processId); ndbout_c("processId %d", processId);
int result = _mgmtSrvr.setEventReportingLevel(processId, logLevel); int result = _mgmtSrvr.setEventReportingLevel(processId, logLevel);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} }
#endif #endif
} }
...@@ -1136,7 +1143,7 @@ CommandInterpreter::executeStartBackup(char* parameters) { ...@@ -1136,7 +1143,7 @@ CommandInterpreter::executeStartBackup(char* parameters) {
Uint32 backupId; Uint32 backupId;
int result = _mgmtSrvr.startBackup(backupId); int result = _mgmtSrvr.startBackup(backupId);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} else { } else {
// ndbout << "Start of backup ordered" << endl; // ndbout << "Start of backup ordered" << endl;
} }
...@@ -1153,7 +1160,7 @@ CommandInterpreter::executeAbortBackup(char* parameters) { ...@@ -1153,7 +1160,7 @@ CommandInterpreter::executeAbortBackup(char* parameters) {
} }
int result = _mgmtSrvr.abortBackup(bid); int result = _mgmtSrvr.abortBackup(bid);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} else { } else {
ndbout << "Abort of backup " << bid << " ordered" << endl; ndbout << "Abort of backup " << bid << " ordered" << endl;
} }
...@@ -1174,7 +1181,7 @@ CommandInterpreter::executeEnterSingleUser(char* parameters) { ...@@ -1174,7 +1181,7 @@ CommandInterpreter::executeEnterSingleUser(char* parameters) {
} }
int result = _mgmtSrvr.enterSingleUser(0, nodeId,0,0); int result = _mgmtSrvr.enterSingleUser(0, nodeId,0,0);
if (result != 0) { if (result != 0) {
ndbout << _mgmtSrvr.getErrorText(result) << endl; ndbout << get_error_text(result) << endl;
} else { } else {
ndbout << "Entering single user mode, granting access for node " ndbout << "Entering single user mode, granting access for node "
<< nodeId << " OK." << endl; << nodeId << " OK." << endl;
......
...@@ -55,6 +55,9 @@ public: ...@@ -55,6 +55,9 @@ public:
int readAndExecute(); int readAndExecute();
private: private:
char m_err_str[1024];
const char *get_error_text(int err_no);
/** /**
* Read a string, and return a pointer to it. * Read a string, and return a pointer to it.
* *
......
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
#include <NdbAutoPtr.hpp> #include <NdbAutoPtr.hpp>
#include <ndberror.h>
#include <mgmapi.h> #include <mgmapi.h>
#include <mgmapi_configuration.hpp> #include <mgmapi_configuration.hpp>
#include <mgmapi_config_parameters.h> #include <mgmapi_config_parameters.h>
...@@ -264,16 +266,6 @@ MgmtSrvr::isEventLogFilterEnabled(int severity) ...@@ -264,16 +266,6 @@ MgmtSrvr::isEventLogFilterEnabled(int severity)
static ErrorItem errorTable[] = 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::NO_CONTACT_WITH_PROCESS, "No contact with the process (dead ?)."},
{MgmtSrvr::PROCESS_NOT_CONFIGURED, "The process is not configured."}, {MgmtSrvr::PROCESS_NOT_CONFIGURED, "The process is not configured."},
{MgmtSrvr::WRONG_PROCESS_TYPE, {MgmtSrvr::WRONG_PROCESS_TYPE,
...@@ -1856,18 +1848,21 @@ MgmtSrvr::dumpState(int processId, const Uint32 args[], Uint32 no) ...@@ -1856,18 +1848,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) { for (int i = 0; i < noOfErrorCodes; ++i) {
if (errorCode == errorTable[i]._errorCode) { 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); ndb_error_string(errorCode, buf, buf_sz);
return text; buf[buf_sz-1]= 0;
return buf;
} }
void void
......
...@@ -466,7 +466,7 @@ public: ...@@ -466,7 +466,7 @@ public:
* @param errorCode: Error code to get a match error text for. * @param errorCode: Error code to get a match error text for.
* @return The error text. * @return The error text.
*/ */
const char* getErrorText(int errorCode); const char* getErrorText(int errorCode, char *buf, int buf_sz);
/** /**
* Get configuration * Get configuration
......
...@@ -579,7 +579,7 @@ MgmApiSession::insertError(Parser<MgmApiSession>::Context &, ...@@ -579,7 +579,7 @@ MgmApiSession::insertError(Parser<MgmApiSession>::Context &,
m_output->println("insert error reply"); m_output->println("insert error reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println(""); m_output->println("");
...@@ -597,7 +597,7 @@ MgmApiSession::setTrace(Parser<MgmApiSession>::Context &, ...@@ -597,7 +597,7 @@ MgmApiSession::setTrace(Parser<MgmApiSession>::Context &,
m_output->println("set trace reply"); m_output->println("set trace reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println(""); m_output->println("");
...@@ -665,7 +665,7 @@ MgmApiSession::startBackup(Parser<MgmApiSession>::Context &, ...@@ -665,7 +665,7 @@ MgmApiSession::startBackup(Parser<MgmApiSession>::Context &,
m_output->println("start backup reply"); m_output->println("start backup reply");
if(result != 0) if(result != 0)
m_output->println("result: %s(%d)", m_mgmsrv.getErrorText(result), result); m_output->println("result: %s(%d)", get_error_text(result), result);
else{ else{
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println("id: %d", backupId); m_output->println("id: %d", backupId);
...@@ -685,7 +685,7 @@ MgmApiSession::startBackup(Parser<MgmApiSession>::Context &, ...@@ -685,7 +685,7 @@ MgmApiSession::startBackup(Parser<MgmApiSession>::Context &,
m_output->println("start backup reply"); m_output->println("start backup reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else{ else{
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println("id: %d", backupId); m_output->println("id: %d", backupId);
...@@ -705,7 +705,7 @@ MgmApiSession::abortBackup(Parser<MgmApiSession>::Context &, ...@@ -705,7 +705,7 @@ MgmApiSession::abortBackup(Parser<MgmApiSession>::Context &,
m_output->println("abort backup reply"); m_output->println("abort backup reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println(""); m_output->println("");
...@@ -727,7 +727,7 @@ MgmApiSession::repCommand(Parser<MgmApiSession>::Context &, ...@@ -727,7 +727,7 @@ MgmApiSession::repCommand(Parser<MgmApiSession>::Context &,
m_output->println("global replication reply"); m_output->println("global replication reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else{ else{
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println("id: %d", repReqId); m_output->println("id: %d", repReqId);
...@@ -749,7 +749,7 @@ MgmApiSession::dumpState(Parser<MgmApiSession>::Context &, ...@@ -749,7 +749,7 @@ MgmApiSession::dumpState(Parser<MgmApiSession>::Context &,
int result = m_mgmsrv.dumpState(node, args_str.c_str()); int result = m_mgmsrv.dumpState(node, args_str.c_str());
m_output->println("dump state reply"); m_output->println("dump state reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println(""); m_output->println("");
...@@ -834,7 +834,7 @@ MgmApiSession::stopSignalLog(Parser<MgmApiSession>::Context &, ...@@ -834,7 +834,7 @@ MgmApiSession::stopSignalLog(Parser<MgmApiSession>::Context &,
m_output->println("stop signallog"); m_output->println("stop signallog");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println(""); m_output->println("");
...@@ -874,7 +874,7 @@ MgmApiSession::restart(Parser<MgmApiSession>::Context &, ...@@ -874,7 +874,7 @@ MgmApiSession::restart(Parser<MgmApiSession>::Context &,
m_output->println("restart reply"); m_output->println("restart reply");
if(result != 0){ 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 } else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println("restarted: %d", restarted); m_output->println("restarted: %d", restarted);
...@@ -898,7 +898,7 @@ MgmApiSession::restartAll(Parser<MgmApiSession>::Context &, ...@@ -898,7 +898,7 @@ MgmApiSession::restartAll(Parser<MgmApiSession>::Context &,
m_output->println("restart reply"); m_output->println("restart reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println("restarted: %d", count); m_output->println("restarted: %d", count);
...@@ -1029,7 +1029,7 @@ MgmApiSession::stop(Parser<MgmApiSession>::Context &, ...@@ -1029,7 +1029,7 @@ MgmApiSession::stop(Parser<MgmApiSession>::Context &,
m_output->println("stop reply"); m_output->println("stop reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println("stopped: %d", stopped); m_output->println("stopped: %d", stopped);
...@@ -1051,7 +1051,7 @@ MgmApiSession::stopAll(Parser<MgmApiSession>::Context &, ...@@ -1051,7 +1051,7 @@ MgmApiSession::stopAll(Parser<MgmApiSession>::Context &,
m_output->println("stop reply"); m_output->println("stop reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println("stopped: %d", stopped); m_output->println("stopped: %d", stopped);
...@@ -1067,7 +1067,7 @@ MgmApiSession::enterSingleUser(Parser<MgmApiSession>::Context &, ...@@ -1067,7 +1067,7 @@ MgmApiSession::enterSingleUser(Parser<MgmApiSession>::Context &,
int result = m_mgmsrv.enterSingleUser(&stopped, nodeId); int result = m_mgmsrv.enterSingleUser(&stopped, nodeId);
m_output->println("enter single user reply"); m_output->println("enter single user reply");
if(result != 0) { if(result != 0) {
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
} }
else { else {
m_output->println("result: Ok"); m_output->println("result: Ok");
...@@ -1082,7 +1082,7 @@ MgmApiSession::exitSingleUser(Parser<MgmApiSession>::Context &, ...@@ -1082,7 +1082,7 @@ MgmApiSession::exitSingleUser(Parser<MgmApiSession>::Context &,
int result = m_mgmsrv.exitSingleUser(&stopped, false); int result = m_mgmsrv.exitSingleUser(&stopped, false);
m_output->println("exit single user reply"); m_output->println("exit single user reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println(""); m_output->println("");
...@@ -1100,7 +1100,7 @@ MgmApiSession::startSignalLog(Parser<MgmApiSession>::Context &, ...@@ -1100,7 +1100,7 @@ MgmApiSession::startSignalLog(Parser<MgmApiSession>::Context &,
m_output->println("start signallog reply"); m_output->println("start signallog reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println(""); m_output->println("");
...@@ -1145,7 +1145,7 @@ MgmApiSession::logSignals(Parser<MgmApiSession>::Context &, ...@@ -1145,7 +1145,7 @@ MgmApiSession::logSignals(Parser<MgmApiSession>::Context &,
m_output->println("log signals reply"); m_output->println("log signals reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println(""); m_output->println("");
...@@ -1162,7 +1162,7 @@ MgmApiSession::start(Parser<MgmApiSession>::Context &, ...@@ -1162,7 +1162,7 @@ MgmApiSession::start(Parser<MgmApiSession>::Context &,
m_output->println("start reply"); m_output->println("start reply");
if(result != 0) if(result != 0)
m_output->println("result: %s", m_mgmsrv.getErrorText(result)); m_output->println("result: %s", get_error_text(result));
else else
m_output->println("result: Ok"); m_output->println("result: Ok");
m_output->println(""); m_output->println("");
......
...@@ -39,10 +39,13 @@ private: ...@@ -39,10 +39,13 @@ private:
OutputStream *m_output; OutputStream *m_output;
Parser_t *m_parser; Parser_t *m_parser;
MgmtSrvr::Allocated_resources *m_allocated_resources; MgmtSrvr::Allocated_resources *m_allocated_resources;
char m_err_str[1024];
void getConfig_common(Parser_t::Context &ctx, void getConfig_common(Parser_t::Context &ctx,
const class Properties &args, const class Properties &args,
bool compat = false); 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: public:
MgmApiSession(class MgmtSrvr & mgm, NDB_SOCKET_TYPE sock); MgmApiSession(class MgmtSrvr & mgm, NDB_SOCKET_TYPE sock);
......
...@@ -35,6 +35,7 @@ typedef struct ErrorBundle { ...@@ -35,6 +35,7 @@ typedef struct ErrorBundle {
#define NE ndberror_cl_none #define NE ndberror_cl_none
#define AE ndberror_cl_application #define AE ndberror_cl_application
#define CE ndberror_cl_configuration
#define ND ndberror_cl_no_data_found #define ND ndberror_cl_no_data_found
#define CV ndberror_cl_constraint_violation #define CV ndberror_cl_constraint_violation
#define SE ndberror_cl_schema_error #define SE ndberror_cl_schema_error
...@@ -58,6 +59,27 @@ static const char REDO_BUFFER_MSG[]= ...@@ -58,6 +59,27 @@ static const char REDO_BUFFER_MSG[]=
static const char* empty_string = ""; 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 static
const const
ErrorBundle ErrorCodes[] = { ErrorBundle ErrorCodes[] = {
...@@ -303,6 +325,36 @@ ErrorBundle ErrorCodes[] = { ...@@ -303,6 +325,36 @@ ErrorBundle ErrorCodes[] = {
*/ */
{ 4003, NI, "Function not implemented yet" }, { 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 * Still uncategorized
*/ */
...@@ -467,6 +519,7 @@ const ...@@ -467,6 +519,7 @@ const
ErrorStatusClassification StatusClassificationMapping[] = { ErrorStatusClassification StatusClassificationMapping[] = {
{ ST_S, NE, "No error"}, { ST_S, NE, "No error"},
{ ST_P, AE, "Application error"}, { ST_P, AE, "Application error"},
{ ST_P, CE, "Configuration or application error"},
{ ST_P, ND, "No data found"}, { ST_P, ND, "No data found"},
{ ST_P, CV, "Constraint violation"}, { ST_P, CV, "Constraint violation"},
{ ST_P, SE, "Schema error"}, { ST_P, SE, "Schema error"},
......
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