mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
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
This commit is contained in:
@ -16,6 +16,7 @@
|
||||
|
||||
|
||||
#include <ndb_global.h>
|
||||
#include <ndb_opts.h>
|
||||
|
||||
#include <NdbOut.hpp>
|
||||
|
||||
@ -23,7 +24,6 @@
|
||||
#include <NdbMain.h>
|
||||
#include <NDBT.hpp>
|
||||
#include <NdbSleep.h>
|
||||
#include <getarg.h>
|
||||
#include <UtilTransactions.hpp>
|
||||
|
||||
static int
|
||||
@ -32,34 +32,68 @@ select_count(Ndb* pNdb, const NdbDictionary::Table* pTab,
|
||||
int* count_rows,
|
||||
UtilTransactions::ScanLock lock);
|
||||
|
||||
int main(int argc, const char** argv){
|
||||
ndb_init();
|
||||
const char* _dbname = "TEST_DB";
|
||||
int _parallelism = 240;
|
||||
int _help = 0;
|
||||
int _lock = 0;
|
||||
|
||||
struct getargs args[] = {
|
||||
{ "database", 'd', arg_string, &_dbname, "dbname",
|
||||
"Name of database table is in"},
|
||||
{ "parallelism", 's', arg_integer, &_parallelism, "parallelism", "parallelism" },
|
||||
{ "usage", '?', arg_flag, &_help, "Print help", "" },
|
||||
{ "lock", 'l', arg_integer, &_lock,
|
||||
"Read(0), Read-hold(1), Exclusive(2)", "lock"}
|
||||
|
||||
};
|
||||
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 int _parallelism = 240;
|
||||
static int _lock = 0;
|
||||
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 },
|
||||
{ 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[] =
|
||||
"tabname1 ... tabnameN\n"\
|
||||
"This program will count the number of records in tables\n";
|
||||
|
||||
if(getarg(args, num_args, argc, argv, &optind) ||
|
||||
argv[optind] == NULL || _help) {
|
||||
arg_printusage(args, num_args, argv[0], desc);
|
||||
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_count.trace");
|
||||
break;
|
||||
case 'V':
|
||||
print_version();
|
||||
exit(0);
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
int ho_error;
|
||||
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
|
||||
return NDBT_ProgramExit(NDBT_WRONGARGS);
|
||||
if (argc < 1) {
|
||||
usage();
|
||||
return NDBT_ProgramExit(NDBT_WRONGARGS);
|
||||
}
|
||||
|
||||
Ndb::setConnectString(opt_connect_str);
|
||||
// Connect to Ndb
|
||||
Ndb MyNdb(_dbname);
|
||||
|
||||
@ -72,7 +106,7 @@ int main(int argc, const char** argv){
|
||||
while(MyNdb.waitUntilReady() != 0)
|
||||
ndbout << "Waiting for ndb to become ready..." << endl;
|
||||
|
||||
for(int i = optind; i<argc; i++){
|
||||
for(int i = 0; i<argc; i++){
|
||||
// Check if table exists in db
|
||||
const NdbDictionary::Table * pTab = NDBT_Table::discoverTableFromDb(&MyNdb, argv[i]);
|
||||
if(pTab == NULL){
|
||||
|
Reference in New Issue
Block a user