18 #include <ndb_global.h>
27 bool fetch_across_commit,
int parallelism=240);
29 const char *load_default_groups[]= {
"mysql_cluster",0 };
31 static const char* _dbname =
"TEST_DB";
32 static my_bool _transactional =
false;
33 static my_bool _tupscan = 0;
34 static my_bool _diskscan = 0;
36 static struct my_option my_long_options[] =
38 NDB_STD_OPTS(
"ndb_desc"),
39 {
"database",
'd',
"Name of database table is in",
40 (uchar**) &_dbname, (uchar**) &_dbname, 0,
41 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
42 {
"transactional",
't',
"Single transaction (may run out of operations)",
43 (uchar**) &_transactional, (uchar**) &_transactional, 0,
44 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
45 {
"tupscan", NDB_OPT_NOSHORT,
"Run tupscan",
46 (uchar**) &_tupscan, (uchar**) &_tupscan, 0,
47 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
48 {
"diskscan", NDB_OPT_NOSHORT,
"Run diskcan",
49 (uchar**) &_diskscan, (uchar**) &_diskscan, 0,
50 GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
51 { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
54 static void short_usage_sub(
void)
56 ndb_short_usage_sub(NULL);
61 ndb_usage(short_usage_sub, load_default_groups, my_long_options);
64 int main(
int argc,
char** argv){
66 ndb_opt_set_usage_funcs(short_usage_sub, usage);
67 load_defaults(
"my",load_default_groups,&argc,&argv);
70 opt_debug=
"d:t:O,/tmp/ndb_delete_all.trace";
72 if ((ho_error=handle_options(&argc, &argv, my_long_options,
73 ndb_std_get_one_option)))
74 return NDBT_ProgramExit(NDBT_WRONGARGS);
80 ndbout <<
"Unable to connect to management server." << endl;
81 return NDBT_ProgramExit(NDBT_FAILED);
85 ndbout <<
"Cluster nodes not ready in 30 seconds." << endl;
86 return NDBT_ProgramExit(NDBT_FAILED);
89 Ndb MyNdb(&con, _dbname );
90 if(MyNdb.init() != 0){
91 ERR(MyNdb.getNdbError());
92 return NDBT_ProgramExit(NDBT_FAILED);
97 for(
int i = 0;
i<argc;
i++){
100 ndbout <<
" Table " << argv[
i] <<
" does not exist!" << endl;
101 return NDBT_ProgramExit(NDBT_WRONGARGS);
103 ndbout <<
"Deleting all from " << argv[
i];
104 if (! _transactional)
105 ndbout <<
" (non-transactional)";
107 if(clear_table(&MyNdb, pTab, ! _transactional) == NDBT_FAILED){
109 ndbout <<
"FAILED" << endl;
112 return NDBT_ProgramExit(res);
117 bool fetch_across_commit,
int parallelism)
121 int retryAttempt = 0;
122 const int retryMax = 10;
129 int par = parallelism;
132 if (retryAttempt++ >= retryMax){
133 g_info <<
"ERROR: has retried this operation " << retryAttempt
134 <<
" times, failing!" << endl;
139 if (pTrans == NULL) {
143 NdbSleep_MilliSleep(50);
155 flags |= _tupscan ? NdbScanOperation::SF_TupScan : 0;
156 flags |= _diskscan ? NdbScanOperation::SF_DiskScan : 0;
167 NdbSleep_MilliSleep(50);
179 }
while((check = pOp->
nextResult(
false)) == 0);
182 if (fetch_across_commit) {
195 NdbSleep_MilliSleep(50);
207 NdbSleep_MilliSleep(50);
213 if (! fetch_across_commit &&
226 return (err.
code != 0 ? err.
code : NDBT_FAILED);