summaryrefslogtreecommitdiff
path: root/ndb/tools/select_all.cpp
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2004-11-01 13:55:43 +0000
committerunknown <tomas@poseidon.ndb.mysql.com>2004-11-01 13:55:43 +0000
commita2e4768f2019f0d4ffb10ad6afcb443e15f99602 (patch)
tree3ff4c0a0dfa3044edc7beaad3bc8fd54f77f9661 /ndb/tools/select_all.cpp
parentd46c7366ebf3e7cd37253f61b927d62fbe180170 (diff)
downloadmariadb-git-a2e4768f2019f0d4ffb10ad6afcb443e15f99602.tar.gz
aligned ndb versioning with mysql
changed define SNPRINTF_RETURN_ZERO to SNPRINTF_RETURN_TRUNC added define NDB_INIT removed getarg, strlcat, strlcpy aligned ndb version with mysql version cpcd: removed old way of reading config file and replaced with mysql load_defaults changed from using getarg to my_getopts use mysql my_progname moved getarg to test BitKeeper/deleted/.del-strlcat.c~250851f8f1ac1c2c: Delete: ndb/src/common/util/strlcat.c BitKeeper/deleted/.del-strlcpy.c~43266e312d11c47b: Delete: ndb/src/common/util/strlcpy.c ndb/test/include/getarg.h: Rename: ndb/include/util/getarg.h -> ndb/test/include/getarg.h configure.in: aligned ndb versioning with mysql changed define SNPRINTF_RETURN_ZERO to SNPRINTF_RETURN_TRUNC ndb/include/ndb_global.h: added define NDB_INIT removed strlcpy, strlcat ndb/src/common/editline/sysunix.c: removed usage of strlcat ndb/src/common/util/Makefile.am: removed getarg, strlcat, strlcpy ndb/src/common/util/basestring_vsnprintf.c: changed define from SNPRINTF_RETURN_ZERO to SNPRINTF_RETURN_TRUNC ndb/src/common/util/socket_io.cpp: removed usage of strlcat ndb/src/common/util/version.c: aligned ndb version with mysql version ndb/src/cw/cpcd/common.cpp: removed old way of reading config file and replaced with mysql load_defaults ndb/src/cw/cpcd/common.hpp: removed old way of reading config file and replaced with mysql load_defaults ndb/src/cw/cpcd/main.cpp: changed from usin getarg to my_opts ndb/src/kernel/blocks/backup/restore/main.cpp: changed from usin getarg to my_opts ndb/src/kernel/error/ErrorReporter.cpp: use mysql my_progname ndb/src/kernel/main.cpp: removed const in main declaration ndb/src/kernel/vm/Configuration.cpp: changed from usin getarg to my_opts ndb/src/kernel/vm/Configuration.hpp: removed const in main declaration ndb/src/mgmclient/main.cpp: changed from usin getarg to my_opts ndb/src/mgmsrv/main.cpp: changed from usin getarg to my_opts ndb/src/ndbapi/Ndb.cpp: fixed compiler warnings ndb/test/run-test/Makefile.am: moved getarg to test ndb/test/src/Makefile.am: moved getarg to test ndb/test/src/getarg.c: moved strlcat and strlcpy into getarg.c ndb/tools/delete_all.cpp: changed from usin getarg to my_opts ndb/tools/desc.cpp: changed from usin getarg to my_opts ndb/tools/drop_index.cpp: changed from usin getarg to my_opts ndb/tools/drop_tab.cpp: changed from usin getarg to my_opts ndb/tools/listTables.cpp: changed from usin getarg to my_opts ndb/tools/select_all.cpp: changed from usin getarg to my_opts ndb/tools/select_count.cpp: changed from usin getarg to my_opts ndb/tools/waiter.cpp: changed from usin getarg to my_opts
Diffstat (limited to 'ndb/tools/select_all.cpp')
-rw-r--r--ndb/tools/select_all.cpp124
1 files changed, 74 insertions, 50 deletions
diff --git a/ndb/tools/select_all.cpp b/ndb/tools/select_all.cpp
index 9f8108d9f32..758c1e48c88 100644
--- a/ndb/tools/select_all.cpp
+++ b/ndb/tools/select_all.cpp
@@ -16,6 +16,7 @@
#include <ndb_global.h>
+#include <ndb_opts.h>
#include <NdbOut.hpp>
@@ -23,13 +24,8 @@
#include <NdbMain.h>
#include <NDBT.hpp>
#include <NdbSleep.h>
-#include <getarg.h>
#include <NdbScanFilter.hpp>
-#ifndef DBUG_OFF
-const char *debug_option= 0;
-#endif
-
int scanReadRecords(Ndb*,
const NdbDictionary::Table*,
const NdbDictionary::Index*,
@@ -40,39 +36,44 @@ int scanReadRecords(Ndb*,
char delim,
bool orderby);
-int main(int argc, const char** argv){
- ndb_init();
- int _parallelism = 240;
- const char* _delimiter = "\t";
- int _header = true;
- int _useHexFormat = false;
- const char* _tabname = NULL;
- const char* _dbname = "TEST_DB";
- int _help = 0;
- int _lock = 0;
- int _order = 0;
-
- struct getargs args[] = {
- { "database", 'd', arg_string, &_dbname, "dbname",
- "Name of database table is in"},
- { "parallelism", 'p', arg_integer, &_parallelism, "parallelism",
- "parallelism" },
- { "header", 'h', arg_flag, &_header, "Print header", "header" },
- { "useHexFormat", 'x', arg_flag, &_useHexFormat,
- "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"},
- { "order", 'o', arg_flag, &_order, "Sort resultset according to index", ""}
- };
- int num_args = sizeof(args) / sizeof(args[0]);
- int optind = 0;
+static const char* opt_connect_str= 0;
+static const char* _dbname = "TEST_DB";
+static const char* _delimiter = "\t";
+static int _unqualified, _header, _parallelism, _useHexFormat, _lock,
+ _order;
+
+static struct my_option my_long_options[] =
+{
+ NDB_STD_OPTS("ndb_desc"),
+ { "database", 'd', "Name of database table is in",
+ (gptr*) &_dbname, (gptr*) &_dbname, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+ { "parallelism", 'p', "parallelism",
+ (gptr*) &_parallelism, (gptr*) &_parallelism, 0,
+ GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 },
+ { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)",
+ (gptr*) &_lock, (gptr*) &_lock, 0,
+ GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+ { "order", 'o', "Sort resultset according to index",
+ (gptr*) &_order, (gptr*) &_order, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+ { "header", 'h', "Print header",
+ (gptr*) &_header, (gptr*) &_header, 0,
+ GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 },
+ { "useHexFormat", 'x', "Output numbers in hexadecimal format",
+ (gptr*) &_useHexFormat, (gptr*) &_useHexFormat, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+ { "delimiter", 'D', "Column delimiter",
+ (gptr*) &_delimiter, (gptr*) &_delimiter, 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}
+};
+static void print_version()
+{
+ printf("MySQL distrib %s, for %s (%s)\n",MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE);
+}
+static void usage()
+{
char desc[] =
"tabname\n"\
"This program reads all records from one table in NDB Cluster\n"\
@@ -80,19 +81,42 @@ int main(int argc, const char** argv){
"(It only print error messages if it encounters a permanent error.)\n"\
"It can also be used to dump the content of a table to file \n"\
" ex: select_all --no-header --delimiter=';' T4 > T4.data\n";
-
- if(getarg(args, num_args, argc, argv, &optind) ||
- argv[optind] == NULL || _help) {
- arg_printusage(args, num_args, argv[0], desc);
- return NDBT_ProgramExit(NDBT_WRONGARGS);
+ print_version();
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
+}
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument)
+{
+ switch (optid) {
+ case '#':
+ DBUG_PUSH(argument ? argument : "d:t:O,/tmp/ndb_select_all.trace");
+ break;
+ case 'V':
+ print_version();
+ exit(0);
+ case '?':
+ usage();
+ exit(0);
}
- _tabname = argv[optind];
+ return 0;
+}
-#ifndef DBUG_OFF
- if (debug_option)
- DBUG_PUSH(debug_option);
-#endif
+int main(int argc, char** argv){
+ NDB_INIT(argv[0]);
+ const char *load_default_groups[]= { "ndb_tools",0 };
+ load_defaults("my",load_default_groups,&argc,&argv);
+ const char* _tabname;
+ int ho_error;
+ if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ if ((_tabname = argv[0]) == 0) {
+ usage();
+ return NDBT_ProgramExit(NDBT_WRONGARGS);
+ }
+ Ndb::setConnectString(opt_connect_str);
// Connect to Ndb
Ndb MyNdb(_dbname);
@@ -108,8 +132,8 @@ int main(int argc, const char** argv){
// Check if table exists in db
const NdbDictionary::Table* pTab = NDBT_Table::discoverTableFromDb(&MyNdb, _tabname);
const NdbDictionary::Index * pIdx = 0;
- if(optind+1 < argc){
- pIdx = MyNdb.getDictionary()->getIndex(argv[optind+1], _tabname);
+ if(argc > 1){
+ pIdx = MyNdb.getDictionary()->getIndex(argv[0], _tabname);
}
if(pTab == NULL){