19 #include <ndb_global.h>
27 static int g_diskbased = 0;
28 static const char* g_tsname = 0;
38 col->setStorageType(NdbDictionary::Column::StorageTypeDisk);
42 if (g_tsname != NULL) {
43 tab.setTablespaceName(g_tsname);
49 int main(
int argc,
const char** argv){
56 const char* _connectstr = NULL;
58 const char* _tsname = NULL;
62 {
"all",
'a', arg_flag, &_all,
"Create/print all tables", 0 },
63 {
"print",
'p', arg_flag, &_print,
"Print table(s) instead of creating it", 0},
64 {
"temp",
't', arg_flag, &_temp,
"Temporary table", 0 },
65 {
"trans",
'x', arg_flag, &_trans,
"Use single schema trans", 0 },
66 {
"connstr",
'c', arg_string, &_connectstr,
"Connect string",
"cs" },
67 {
"diskbased", 0, arg_flag, &_diskbased,
"Store attrs on disk if possible", 0 },
68 {
"tsname", 0, arg_string, &_tsname,
"Tablespace name",
"ts" },
69 {
"usage",
'?', arg_flag, &_help,
"Print help",
"" }
71 int num_args =
sizeof(args) /
sizeof(args[0]);
75 "This program will create one table in Ndb.\n"\
76 "The tables may be selected from a fixed list of tables\n"\
77 "defined in NDBT_Tables class\n";
79 if(getarg(args, num_args, argc, argv, &optind) || _help){
80 arg_printusage(args, num_args, argv[0], desc);
81 return NDBT_ProgramExit(NDBT_WRONGARGS);
84 if(argv[optind] == NULL && !_all){
85 arg_printusage(args, num_args, argv[0], desc);
86 return NDBT_ProgramExit(NDBT_WRONGARGS);
89 g_diskbased = _diskbased;
98 for(
int i = optind;
i<argc;
i++){
99 NDBT_Tables::print(argv[
i]);
102 NDBT_Tables::printAll();
113 return NDBT_ProgramExit(NDBT_FAILED);
115 Ndb MyNdb(&con,
"TEST_DB" );
117 if(MyNdb.init() != 0){
118 ERR(MyNdb.getNdbError());
119 return NDBT_ProgramExit(NDBT_FAILED);
122 while(MyNdb.waitUntilReady() != 0)
123 ndbout <<
"Waiting for ndb to become ready..." << endl;
130 return NDBT_ProgramExit(NDBT_FAILED);
135 res = NDBT_Tables::createAllTables(&MyNdb, _temp);
138 for(
int i = optind;
i<argc;
i++){
139 ndbout <<
"Trying to create " << argv[
i] << endl;
140 if((tmp = NDBT_Tables::createTable(&MyNdb, argv[
i], _temp,
false,
141 g_create_hook)) != 0)
149 return NDBT_ProgramExit(NDBT_FAILED);
155 return NDBT_ProgramExit(NDBT_FAILED);
157 return NDBT_ProgramExit(NDBT_OK);