summaryrefslogtreecommitdiff
path: root/ndb/tools
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.(none)>2004-09-01 14:56:53 +0000
committerunknown <tomas@poseidon.(none)>2004-09-01 14:56:53 +0000
commita0475132996a55e082b758ba11f86aa789d9d437 (patch)
treea898799030e3f3a5580dbc4561c3771f53d258ae /ndb/tools
parent9ed92fea50cd8e6688a4370905050dc3cadfb771 (diff)
downloadmariadb-git-a0475132996a55e082b758ba11f86aa789d9d437.tar.gz
added class Ndb_cluster_connection to prepare for making order of starting mysqld and ndbd irrelevant
ndb/src/mgmsrv/Makefile.am: changed so that datadir is "." by default so that behaviour is the same as before
Diffstat (limited to 'ndb/tools')
-rw-r--r--ndb/tools/listTables.cpp45
-rw-r--r--ndb/tools/select_all.cpp14
2 files changed, 55 insertions, 4 deletions
diff --git a/ndb/tools/listTables.cpp b/ndb/tools/listTables.cpp
index bddf61848e8..b9e050ab6a4 100644
--- a/ndb/tools/listTables.cpp
+++ b/ndb/tools/listTables.cpp
@@ -22,12 +22,13 @@
*/
#include <ndb_global.h>
+#include <my_sys.h>
#include <getarg.h>
#include <NdbApi.hpp>
#include <NDBT.hpp>
-
+static Ndb_cluster_connection *ndb_cluster_connection= 0;
static Ndb* ndb = 0;
static NdbDictionary::Dictionary* dic = 0;
static int _unqualified = 0;
@@ -49,16 +50,32 @@ fatal(char const* fmt, ...)
}
static void
+fatal_dict(char const* fmt, ...)
+{
+ va_list ap;
+ char buf[500];
+ va_start(ap, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, ap);
+ va_end(ap);
+ ndbout << buf;
+ if (dic)
+ ndbout << " - " << dic->getNdbError();
+ ndbout << endl;
+ NDBT_ProgramExit(NDBT_FAILED);
+ exit(1);
+}
+
+static void
list(const char * tabname,
NdbDictionary::Object::Type type)
{
NdbDictionary::Dictionary::List list;
if (tabname == 0) {
if (dic->listObjects(list, type) == -1)
- fatal("listObjects");
+ fatal_dict("listObjects");
} else {
if (dic->listIndexes(list, tabname) == -1)
- fatal("listIndexes");
+ fatal_dict("listIndexes");
}
if (ndb->usingFullyQualifiedNames())
ndbout_c("%-5s %-20s %-8s %-7s %-12s %-8s %s", "id", "type", "state", "logging", "database", "schema", "name");
@@ -145,12 +162,17 @@ list(const char * tabname,
}
}
+#ifndef DBUG_OFF
+const char *debug_option= 0;
+#endif
+
int main(int argc, const char** argv){
int _loops = 1;
const char* _tabname = NULL;
const char* _dbname = "TEST_DB";
int _type = 0;
int _help = 0;
+ const char* _connect_str = NULL;
struct getargs args[] = {
{ "loops", 'l', arg_integer, &_loops, "loops",
@@ -161,6 +183,13 @@ int main(int argc, const char** argv){
"Name of database table is in"},
{ "type", 't', arg_integer, &_type, "type",
"Type of objects to show, see NdbDictionary.hpp for numbers(default = 0)" },
+ { "connect-string", 'c', arg_string, &_connect_str,
+ "Set connect string for connecting to ndb_mgmd. <constr>=\"host=<hostname:port>[;nodeid=<id>]\". Overides specifying entries in NDB_CONNECTSTRING and config file",
+ "<constr>" },
+#ifndef DBUG_OFF
+ { "debug", 0, arg_string, &debug_option,
+ "Specify debug options e.g. d:t:i:o,out.trace", "options" },
+#endif
{ "usage", '?', arg_flag, &_help, "Print help", "" }
};
int num_args = sizeof(args) / sizeof(args[0]);
@@ -179,10 +208,18 @@ int main(int argc, const char** argv){
}
_tabname = argv[optind];
- ndb = new Ndb(_dbname);
+#ifndef DBUG_OFF
+ my_init();
+ if (debug_option)
+ DBUG_PUSH(debug_option);
+#endif
+
+ ndb_cluster_connection = new Ndb_cluster_connection(_connect_str);
+ ndb = new Ndb(ndb_cluster_connection, _dbname);
ndb->useFullyQualifiedNames(!_unqualified);
if (ndb->init() != 0)
fatal("init");
+ ndb_cluster_connection->connect();
if (ndb->waitUntilReady(30) < 0)
fatal("waitUntilReady");
dic = ndb->getDictionary();
diff --git a/ndb/tools/select_all.cpp b/ndb/tools/select_all.cpp
index 329ed87bc48..eb95947fc0f 100644
--- a/ndb/tools/select_all.cpp
+++ b/ndb/tools/select_all.cpp
@@ -16,6 +16,7 @@
#include <ndb_global.h>
+#include <my_sys.h>
#include <NdbOut.hpp>
@@ -26,6 +27,9 @@
#include <getarg.h>
#include <NdbScanFilter.hpp>
+#ifndef DBUG_OFF
+const char *debug_option= 0;
+#endif
int scanReadRecords(Ndb*,
const NdbDictionary::Table*,
@@ -58,6 +62,10 @@ int main(int argc, const char** argv){
"Output numbers in hexadecimal format", "useHexFormat" },
{ "delimiter", 'd', arg_string, &_delimiter, "Column delimiter",
"delimiter" },
+#ifndef DBUG_OFF
+ { "debug", 0, arg_string, &debug_option,
+ "Specify debug options e.g. d:t:i:o,out.trace", "options" },
+#endif
{ "usage", '?', arg_flag, &_help, "Print help", "" },
{ "lock", 'l', arg_integer, &_lock,
"Read(0), Read-hold(1), Exclusive(2)", "lock"},
@@ -80,6 +88,12 @@ int main(int argc, const char** argv){
}
_tabname = argv[optind];
+#ifndef DBUG_OFF
+ my_init();
+ if (debug_option)
+ DBUG_PUSH(debug_option);
+#endif
+
// Connect to Ndb
Ndb MyNdb(_dbname);