18 #include <ndb_global.h> 
   25 int desc_logfilegroup(
Ndb *myndb, 
char* 
name);
 
   28 int desc_tablespace(
Ndb *myndb,
char* 
name);
 
   29 int desc_table(
Ndb *myndb,
char* 
name);
 
   32 static const char* _dbname = 
"TEST_DB";
 
   33 static int _unqualified = 0;
 
   34 static int _partinfo = 0;
 
   35 static int _blobinfo = 0;
 
   36 static int _nodeinfo = 0;
 
   38 const char *load_default_groups[]= { 
"mysql_cluster",0 };
 
   40 static int _retries = 0;
 
   42 static struct my_option my_long_options[] =
 
   44   NDB_STD_OPTS(
"ndb_desc"),
 
   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   { 
"unqualified", 
'u', 
"Use unqualified table names",
 
   49     (uchar**) &_unqualified, (uchar**) &_unqualified, 0,
 
   50     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, 
 
   51   { 
"extra-partition-info", 
'p', 
"Print more info per partition",
 
   52     (uchar**) &_partinfo, (uchar**) &_partinfo, 0,
 
   53     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, 
 
   54   { 
"retries", 
'r', 
"Retry every second for # retries",
 
   55     (uchar**) &_retries, (uchar**) &_retries, 0,
 
   56     GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 
 
   57   { 
"blob-info", 
'b', 
"Show information for hidden blob tables (requires -p)",
 
   58     (uchar**) &_blobinfo, (uchar**) &_blobinfo, 0,
 
   59     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
 
   60   { 
"extra-node-info", 
'n', 
"Print node info for partitions (requires -p)",
 
   61     (uchar**) &_nodeinfo, (uchar**) &_nodeinfo, 0,
 
   62     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
 
   63   { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 
   66 static void short_usage_sub(
void)
 
   68   ndb_short_usage_sub(NULL);
 
   73   ndb_usage(short_usage_sub, load_default_groups, my_long_options);
 
   78 int main(
int argc, 
char** argv){
 
   81   ndb_opt_set_usage_funcs(short_usage_sub, usage);
 
   82   load_defaults(
"my",load_default_groups,&argc,&argv);
 
   85   opt_debug= 
"d:t:O,/tmp/ndb_desc.trace";
 
   87   if ((ho_error=handle_options(&argc, &argv, my_long_options, 
 
   88                                ndb_std_get_one_option)))
 
   89     return NDBT_ProgramExit(NDBT_WRONGARGS);
 
   95     ndbout << 
"Unable to connect to management server." << endl;
 
   96     return NDBT_ProgramExit(NDBT_FAILED);
 
  100     ndbout << 
"Cluster nodes not ready in 30 seconds." << endl;
 
  101     return NDBT_ProgramExit(NDBT_FAILED);
 
  104   Ndb MyNdb(&con, _dbname);
 
  105   if(MyNdb.init() != 0){
 
  106     ERR(MyNdb.getNdbError());
 
  107     return NDBT_ProgramExit(NDBT_FAILED);
 
  110   for(
int i= 0; 
i<argc;
i++)
 
  112     if(desc_table(&MyNdb,argv[
i]))
 
  114     else if(desc_tablespace(&MyNdb,argv[i]))
 
  116     else if(desc_logfilegroup(&MyNdb,argv[i]))
 
  118     else if(desc_datafile(con, &MyNdb, argv[i]))
 
  120     else if(desc_undofile(con, &MyNdb, argv[i]))
 
  122     else if (desc_hashmap(con, &MyNdb, argv[i]))
 
  125       ndbout << 
"No such object: " << argv[
i] << endl << endl;
 
  128   return NDBT_ProgramExit(NDBT_OK);
 
  133   ndbout << 
"AutoGrow.min_free: " << ags.min_free << endl;
 
  134   ndbout << 
"AutoGrow.max_size: " << ags.max_size << endl;
 
  135   ndbout << 
"AutoGrow.file_size: " << ags.file_size << endl;
 
  136   ndbout << 
"AutoGrow.filename_pattern: " << ags.filename_pattern << endl;
 
  139 int desc_logfilegroup(
Ndb *myndb, 
char* 
name)
 
  148   ndbout << 
"Type: LogfileGroup" << endl;
 
  149   ndbout << 
"Name: " << lfg.getName() << endl;
 
  150   ndbout << 
"UndoBuffer size: " << lfg.getUndoBufferSize() << endl;
 
  152   ndbout << 
"Free Words: " << lfg.getUndoFreeWords() << endl;
 
  154   desc_AutoGrowSpecification(lfg.getAutoGrowSpecification());
 
  161 int desc_tablespace(
Ndb *myndb, 
char* name)
 
  170   ndbout << 
"Type: Tablespace" << endl;
 
  171   ndbout << 
"Name: " << ts.getName() << endl;
 
  173   ndbout << 
"Extent Size: " << ts.getExtentSize() << endl;
 
  174   ndbout << 
"Default Logfile Group: " << ts.getDefaultLogfileGroup() << endl;
 
  187   con.init_get_next_node(iter);
 
  189   while ((
id= con.get_next_node(iter)))
 
  196     ndbout << 
"Type: Undofile" << endl;
 
  197     ndbout << 
"Name: " << name << endl;
 
  198     ndbout << 
"Node: " << 
id << endl;
 
  199     ndbout << 
"Path: " << uf.getPath() << endl;
 
  200     ndbout << 
"Size: " << uf.getSize() << endl;
 
  202     ndbout << 
"Logfile Group: " << uf.getLogfileGroup() << endl;
 
  223   con.init_get_next_node(iter);
 
  225   while ((
id= con.get_next_node(iter)))
 
  232     ndbout << 
"Type: Datafile" << endl;
 
  233     ndbout << 
"Name: " << name << endl;
 
  234     ndbout << 
"Node: " << 
id << endl;
 
  235     ndbout << 
"Path: " << df.getPath() << endl;
 
  236     ndbout << 
"Size: " << df.getSize() << endl;
 
  237     ndbout << 
"Free: " << df.getFree() << endl;
 
  239     ndbout << 
"Tablespace: " << df.getTablespace() << endl;
 
  251 int desc_table(
Ndb *myndb, 
char* name)
 
  255   while ((pTab = (
NDBT_Table*)dict->
getTable(name)) == NULL && --_retries >= 0) NdbSleep_SecSleep(1);
 
  259   ndbout << (* pTab) << endl;
 
  263     ndbout << name << 
": " << dict->
getNdbError() << endl;
 
  264     return NDBT_ProgramExit(NDBT_FAILED);
 
  267   ndbout << 
"-- Indexes -- " << endl;
 
  268   ndbout << 
"PRIMARY KEY(";
 
  270   for (j= 0; (int)j < pTab->getNoOfPrimaryKeys(); j++)
 
  274     if ((
int)j < pTab->getNoOfPrimaryKeys()-1)
 
  277   ndbout << 
") - UniqueHashIndex" << endl;
 
  278   for (j= 0; j < list.
count; j++) {
 
  282       ndbout << name << 
": " << dict->
getNdbError() << endl;
 
  283       return NDBT_ProgramExit(NDBT_FAILED);
 
  286     ndbout << (*pIdx) << endl;
 
  292     print_part_info(myndb, pTab);
 
  297       for (
int i = 0; i < noOfAttributes; i++)
 
  303           print_part_info(myndb, (
NDBT_Table*) column->getBlobTable());
 
  315   const char * m_title;
 
  325     { 
"Partition", 0, NdbDictionary::Column::FRAGMENT },
 
  326     { 
"Row count", 0, NdbDictionary::Column::ROW_COUNT },
 
  327     { 
"Commit count", 0, NdbDictionary::Column::COMMIT_COUNT },
 
  328     { 
"Frag fixed memory", 0, NdbDictionary::Column::FRAGMENT_FIXED_MEMORY },
 
  329     { 
"Frag varsized memory", 0, NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY },
 
  330     { 
"Extent_space", 0, NdbDictionary::Column::FRAGMENT_EXTENT_SPACE },
 
  331     { 
"Free extent_space", 0, NdbDictionary::Column::FRAGMENT_FREE_EXTENT_SPACE },
 
  335   const Uint32 FragmentIdOffset = 0;
 
  337   ndbout << 
"-- Per partition info";
 
  339   if (_blobinfo && _partinfo)
 
  340     ndbout << 
" for " << pTab->
getName();
 
  342   ndbout << 
" -- " << endl;
 
  344   const Uint32 codeWords= 1;
 
  345   Uint32 codeSpace[ codeWords ];
 
  349   if ((
code.interpret_exit_last_row() != 0) ||
 
  350       (
code.finalise() != 0))
 
  373     for(i = 0; g_part_info[
i].m_title != 0; i++)
 
  375       if ((g_part_info[i].m_rec_attr = pOp->
getValue(g_part_info[i].m_column)) == 0)
 
  379     if (g_part_info[i].m_title != 0)
 
  382     if (pTrans->
execute(NoCommit) != 0)
 
  385     for (i = 0; g_part_info[
i].m_title != 0; i++)
 
  386       ndbout << g_part_info[i].m_title << 
"\t";
 
  397       for(i = 0; g_part_info[
i].m_title != 0; i++)
 
  400         unsigned long long val;
 
  412           printf(
"%-*.llu\t", (
int)strlen(g_part_info[i].m_title), val);
 
  414           printf(
"0%*.s\t", (
int)strlen(g_part_info[i].m_title), 
"");
 
  419         Uint32 partId = g_part_info[ FragmentIdOffset ].m_rec_attr -> u_32_value();
 
  421         const Uint32 MaxReplicas = 4;
 
  422         Uint32 nodeIds[ MaxReplicas ];
 
  427           for (Uint32 
n = 0; 
n < nodeCnt; 
n++)
 
  431             printf(
"%u", nodeIds[
n]);
 
  455     Uint32 len = hm.getMapLen();
 
  456     Uint32 * tmp = 
new Uint32[len];
 
  457     hm.getMapValues(tmp, len);
 
  458     for (Uint32 i = 0; i<len; i++)
 
  460       printf(
"%.2u ", tmp[i]);
 
  461       if (((i+1) % 25) == 0)
 
  464     if (((len + 1) % 25) != 0)