19 #include <ndb_global.h> 
   28 #include <UtilTransactions.hpp> 
   36 static const char* _dbname = 
"TEST_DB";
 
   37 static int _parallelism = 240;
 
   40 const char *load_default_groups[]= { 
"mysql_cluster",0 };
 
   42 static struct my_option my_long_options[] =
 
   44   NDB_STD_OPTS(
"ndb_select_count"),
 
   45   { 
"database", 
'd', 
"Name of database table is in",
 
   46     (uchar**) &_dbname, (uchar**) &_dbname, 0,
 
   47     GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
 
   48   { 
"parallelism", 
'p', 
"parallelism",
 
   49     (uchar**) &_parallelism, (uchar**) &_parallelism, 0,
 
   50     GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 }, 
 
   51   { 
"lock", 
'l', 
"Read(0), Read-hold(1), Exclusive(2)",
 
   52     (uchar**) &_lock, (uchar**) &_lock, 0,
 
   53     GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 
 
   54   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 
   57 static void short_usage_sub(
void)
 
   59   ndb_short_usage_sub(NULL);
 
   64   ndb_usage(short_usage_sub, load_default_groups, my_long_options);
 
   67 int main(
int argc, 
char** argv){
 
   69   ndb_opt_set_usage_funcs(short_usage_sub, usage);
 
   70   load_defaults(
"my",load_default_groups,&argc,&argv);
 
   73   opt_debug= 
"d:t:O,/tmp/ndb_select_count.trace";
 
   75   if ((ho_error=handle_options(&argc, &argv, my_long_options,
 
   76                                ndb_std_get_one_option)))
 
   77     return NDBT_ProgramExit(NDBT_WRONGARGS);
 
   80     return NDBT_ProgramExit(NDBT_WRONGARGS);
 
   87     ndbout << 
"Unable to connect to management server." << endl;
 
   88     return NDBT_ProgramExit(NDBT_FAILED);
 
   92     ndbout << 
"Cluster nodes not ready in 30 seconds." << endl;
 
   93     return NDBT_ProgramExit(NDBT_FAILED);
 
   96   Ndb MyNdb(&con, _dbname );
 
   97   if(MyNdb.init() != 0){
 
   98     ERR(MyNdb.getNdbError());
 
   99     return NDBT_ProgramExit(NDBT_FAILED);
 
  102   for(
int i = 0; 
i<argc; 
i++){
 
  106       ndbout << 
" Table " << argv[
i] << 
" does not exist!" << endl;
 
  111     if (select_count(&MyNdb, pTab, _parallelism, &rows, 
 
  113       return NDBT_ProgramExit(NDBT_FAILED);
 
  116     ndbout << rows << 
" records in table " << argv[
i] << endl;
 
  118   return NDBT_ProgramExit(NDBT_OK);
 
  127   int                  retryAttempt = 0;
 
  128   const int            retryMax = 100;
 
  132   const Uint32 codeWords= 1;
 
  133   Uint32 codeSpace[ codeWords ];
 
  137   if ((
code.interpret_exit_last_row() != 0) ||
 
  138       (
code.finalise() != 0))
 
  140     ERR(
code.getNdbError());
 
  146     if (retryAttempt >= retryMax){
 
  147       g_info << 
"ERROR: has retried this operation " << retryAttempt 
 
  148              << 
" times, failing!" << endl;
 
  153     if (pTrans == NULL) {
 
  157         NdbSleep_MilliSleep(50);
 
  171     if( pOp->
readTuples(NdbScanOperation::LM_Dirty) ) {
 
  187     pOp->
getValue(NdbDictionary::Column::ROW_COUNT, (
char*)&tmp);
 
  188     pOp->
getValue(NdbDictionary::Column::ROW_SIZE, (
char*)&row_size);
 
  196     Uint64 row_count = 0;
 
  207         NdbSleep_MilliSleep(50);
 
  218     if (count_rows != NULL){
 
  219       *count_rows = row_count;