17 #include <ndb_global.h>
25 int main(
int argc,
const char** argv){
30 const char * db =
"TEST_DB";
31 const char* _connectstr = NULL;
34 {
"database",
'd', arg_string, &db,
"database", 0 },
35 {
"connstr",
'c', arg_string, &_connectstr,
"Connect string",
"cs" },
36 {
"partitions",
'p', arg_integer, &_p,
"New no of partitions", 0},
37 {
"usage",
'?', arg_flag, &_help,
"Print help",
"" }
39 int num_args =
sizeof(args) /
sizeof(args[0]);
43 "This program will alter no of partitions of table in Ndb.\n";
45 if(getarg(args, num_args, argc, argv, &optind) || _help){
46 arg_printusage(args, num_args, argv[0], desc);
47 return NDBT_ProgramExit(NDBT_WRONGARGS);
50 if(argv[optind] == NULL)
52 arg_printusage(args, num_args, argv[0], desc);
53 return NDBT_ProgramExit(NDBT_WRONGARGS);
61 return NDBT_ProgramExit(NDBT_FAILED);
65 if(MyNdb.init() != 0){
66 ERR(MyNdb.getNdbError());
67 return NDBT_ProgramExit(NDBT_FAILED);
70 while(MyNdb.waitUntilReady() != 0)
71 ndbout <<
"Waiting for ndb to become ready..." << endl;
74 for (
int i = optind;
i<argc;
i++)
76 printf(
"altering %s/%s...", db, argv[
i]);
81 ndbout <<
"Failed to retrieve table " << argv[
i]
83 return NDBT_ProgramExit(NDBT_FAILED);
95 if (MyDic->
alterTable(*oldTable, newTable) != 0)
104 return NDBT_ProgramExit(NDBT_OK);
109 MyDic->
endSchemaTrans(NdbDictionary::Dictionary::SchemaTransAbort);
113 return NDBT_ProgramExit(NDBT_FAILED);