summaryrefslogtreecommitdiff
path: root/ndb/tools
diff options
context:
space:
mode:
authorunknown <tulin@dl145b.mysql.com>2005-09-05 16:33:40 +0200
committerunknown <tulin@dl145b.mysql.com>2005-09-05 16:33:40 +0200
commit4a584b17e81c636f4819b9923e54c0ec1efeaa84 (patch)
tree9555ee9a3c4892310e27df273613d39786e7d3b1 /ndb/tools
parent354fa102a3294fe349a428d1507433165581caec (diff)
downloadmariadb-git-4a584b17e81c636f4819b9923e54c0ec1efeaa84.tar.gz
added --core-file option to ndb executables
added parseable printout in ndb_restore
Diffstat (limited to 'ndb/tools')
-rw-r--r--ndb/tools/Makefile.am2
-rw-r--r--ndb/tools/ndb_config.cpp1
-rw-r--r--ndb/tools/restore/consumer_restore.cpp29
-rw-r--r--ndb/tools/restore/restore_main.cpp48
4 files changed, 49 insertions, 31 deletions
diff --git a/ndb/tools/Makefile.am b/ndb/tools/Makefile.am
index 89830129576..795441380a8 100644
--- a/ndb/tools/Makefile.am
+++ b/ndb/tools/Makefile.am
@@ -30,7 +30,7 @@ ndb_restore_SOURCES = restore/restore_main.cpp \
restore/consumer.cpp \
restore/consumer_restore.cpp \
restore/consumer_printer.cpp \
- restore/Restore.cpp
+ restore/Restore.cpp $(tools_common_sources)
ndb_config_SOURCES = ndb_config.cpp \
../src/mgmsrv/Config.cpp \
diff --git a/ndb/tools/ndb_config.cpp b/ndb/tools/ndb_config.cpp
index d188aec1337..725249a5af5 100644
--- a/ndb/tools/ndb_config.cpp
+++ b/ndb/tools/ndb_config.cpp
@@ -42,6 +42,7 @@ static const char * g_field_delimiter=",";
static const char * g_row_delimiter=" ";
int g_print_full_config, opt_ndb_shm;
+my_bool opt_core;
typedef ndb_mgm_configuration_iterator Iter;
diff --git a/ndb/tools/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp
index d782a561e6a..70ea7460d78 100644
--- a/ndb/tools/restore/consumer_restore.cpp
+++ b/ndb/tools/restore/consumer_restore.cpp
@@ -14,9 +14,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#include <NDBT_ReturnCodes.h>
#include "consumer_restore.hpp"
#include <NdbSleep.h>
+extern my_bool opt_core;
+
extern FilteredNdbOut err;
extern FilteredNdbOut info;
extern FilteredNdbOut debug;
@@ -458,7 +461,11 @@ bool BackupRestore::errorHandler(restore_callback_t *cb)
void BackupRestore::exitHandler()
{
release();
- exit(-1);
+ NDBT_ProgramExit(NDBT_FAILED);
+ if (opt_core)
+ abort();
+ else
+ exit(NDBT_FAILED);
}
@@ -492,7 +499,7 @@ BackupRestore::logEntry(const LogEntry & tup)
{
// Deep shit, TODO: handle the error
err << "Cannot start transaction" << endl;
- exit(-1);
+ exitHandler();
} // if
const NdbDictionary::Table * table = get_table(tup.m_table->m_dictTable);
@@ -500,7 +507,7 @@ BackupRestore::logEntry(const LogEntry & tup)
if (op == NULL)
{
err << "Cannot get operation: " << trans->getNdbError() << endl;
- exit(-1);
+ exitHandler();
} // if
int check = 0;
@@ -518,13 +525,13 @@ BackupRestore::logEntry(const LogEntry & tup)
default:
err << "Log entry has wrong operation type."
<< " Exiting...";
- exit(-1);
+ exitHandler();
}
if (check != 0)
{
err << "Error defining op: " << trans->getNdbError() << endl;
- exit(-1);
+ exitHandler();
} // if
Bitmask<4096> keys;
@@ -553,7 +560,7 @@ BackupRestore::logEntry(const LogEntry & tup)
if (check != 0)
{
err << "Error defining op: " << trans->getNdbError() << endl;
- exit(-1);
+ exitHandler();
} // if
}
@@ -582,7 +589,7 @@ BackupRestore::logEntry(const LogEntry & tup)
if (!ok)
{
err << "execute failed: " << errobj << endl;
- exit(-1);
+ exitHandler();
}
}
@@ -629,7 +636,7 @@ BackupRestore::tuple(const TupleS & tup)
{
// Deep shit, TODO: handle the error
ndbout << "Cannot start transaction" << endl;
- exit(-1);
+ exitHandler();
} // if
const TableS * table = tup.getTable();
@@ -638,7 +645,7 @@ BackupRestore::tuple(const TupleS & tup)
{
ndbout << "Cannot get operation: ";
ndbout << trans->getNdbError() << endl;
- exit(-1);
+ exitHandler();
} // if
// TODO: check return value and handle error
@@ -646,7 +653,7 @@ BackupRestore::tuple(const TupleS & tup)
{
ndbout << "writeTuple call failed: ";
ndbout << trans->getNdbError() << endl;
- exit(-1);
+ exitHandler();
} // if
for (int i = 0; i < tup.getNoOfAttributes(); i++)
@@ -680,7 +687,7 @@ BackupRestore::tuple(const TupleS & tup)
{
ndbout << "execute failed: ";
ndbout << trans->getNdbError() << endl;
- exit(-1);
+ exitHandler();
}
m_ndb->closeTransaction(trans);
if (ret == 0)
diff --git a/ndb/tools/restore/restore_main.cpp b/ndb/tools/restore/restore_main.cpp
index 0c4419bb072..d786dffe89e 100644
--- a/ndb/tools/restore/restore_main.cpp
+++ b/ndb/tools/restore/restore_main.cpp
@@ -20,6 +20,7 @@
#include <ndb_limits.h>
#include <NdbTCP.h>
#include <NdbOut.hpp>
+#include <NDBT_ReturnCodes.h>
#include "consumer_restore.hpp"
#include "consumer_printer.hpp"
@@ -116,14 +117,14 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (ga_nodeId == 0)
{
printf("Error in --nodeid,-n setting, see --help\n");
- exit(1);
+ exit(NDBT_ProgramExit(NDBT_WRONGARGS));
}
break;
case 'b':
if (ga_backupId == 0)
{
printf("Error in --backupid,-b setting, see --help\n");
- exit(1);
+ exit(NDBT_ProgramExit(NDBT_WRONGARGS));
}
break;
}
@@ -136,7 +137,7 @@ readArguments(int *pargc, char*** pargv)
load_defaults("my",load_default_groups,pargc,pargv);
if (handle_options(pargc, pargv, my_long_options, get_one_option))
{
- exit(1);
+ exit(NDBT_ProgramExit(NDBT_WRONGARGS));
}
BackupPrinter* printer = new BackupPrinter();
@@ -226,6 +227,15 @@ free_data_callback()
g_consumers[i]->tuple_free();
}
+static void exitHandler(int code)
+{
+ NDBT_ProgramExit(code);
+ if (opt_core)
+ abort();
+ else
+ exit(code);
+}
+
int
main(int argc, char** argv)
{
@@ -233,7 +243,7 @@ main(int argc, char** argv)
if (!readArguments(&argc, &argv))
{
- return -1;
+ exitHandler(NDBT_FAILED);
}
Ndb::setConnectString(opt_connect_str);
@@ -245,7 +255,7 @@ main(int argc, char** argv)
if (!metaData.readHeader())
{
ndbout << "Failed to read " << metaData.getFilename() << endl << endl;
- return -1;
+ exitHandler(NDBT_FAILED);
}
const BackupFormat::FileHeader & tmp = metaData.getFileHeader();
@@ -263,20 +273,20 @@ main(int argc, char** argv)
if (res == 0)
{
ndbout_c("Restore: Failed to load content");
- return -1;
+ exitHandler(NDBT_FAILED);
}
if (metaData.getNoOfTables() == 0)
{
ndbout_c("Restore: The backup contains no tables ");
- return -1;
+ exitHandler(NDBT_FAILED);
}
if (!metaData.validateFooter())
{
ndbout_c("Restore: Failed to validate footer.");
- return -1;
+ exitHandler(NDBT_FAILED);
}
Uint32 i;
@@ -285,7 +295,7 @@ main(int argc, char** argv)
if (!g_consumers[i]->init())
{
clearConsumers();
- return -11;
+ exitHandler(NDBT_FAILED);
}
}
@@ -300,7 +310,7 @@ main(int argc, char** argv)
ndbout_c("Restore: Failed to restore table: %s. "
"Exiting...",
metaData[i]->getTableName());
- return -11;
+ exitHandler(NDBT_FAILED);
}
}
}
@@ -309,7 +319,7 @@ main(int argc, char** argv)
if (!g_consumers[i]->endOfTables())
{
ndbout_c("Restore: Failed while closing tables");
- return -11;
+ exitHandler(NDBT_FAILED);
}
if (ga_restore || ga_print)
@@ -322,7 +332,7 @@ main(int argc, char** argv)
if (!dataIter.readHeader())
{
ndbout << "Failed to read header of data file. Exiting..." ;
- return -11;
+ exitHandler(NDBT_FAILED);
}
@@ -340,12 +350,12 @@ main(int argc, char** argv)
{
ndbout_c("Restore: An error occured while restoring data. "
"Exiting...");
- return -1;
+ exitHandler(NDBT_FAILED);
}
if (!dataIter.validateFragmentFooter()) {
ndbout_c("Restore: Error validating fragment footer. "
"Exiting...");
- return -1;
+ exitHandler(NDBT_FAILED);
}
} // while (dataIter.readFragmentHeader(res))
@@ -353,7 +363,7 @@ main(int argc, char** argv)
{
err << "Restore: An error occured while restoring data. Exiting... "
<< "res=" << res << endl;
- return -1;
+ exitHandler(NDBT_FAILED);
}
@@ -366,7 +376,7 @@ main(int argc, char** argv)
if (!logIter.readHeader())
{
err << "Failed to read header of data file. Exiting..." << endl;
- return -1;
+ exitHandler(NDBT_FAILED);
}
const LogEntry * logEntry = 0;
@@ -380,7 +390,7 @@ main(int argc, char** argv)
{
err << "Restore: An restoring the data log. Exiting... res="
<< res << endl;
- return -1;
+ exitHandler(NDBT_FAILED);
}
logIter.validateFooter(); //not implemented
for (i= 0; i < g_consumers.size(); i++)
@@ -395,14 +405,14 @@ main(int argc, char** argv)
ndbout_c("Restore: Failed to finalize restore table: %s. "
"Exiting...",
metaData[i]->getTableName());
- return -11;
+ exitHandler(NDBT_FAILED);
}
}
}
}
}
clearConsumers();
- return 0;
+ return NDBT_ProgramExit(NDBT_OK);
} // main
template class Vector<BackupConsumer*>;