Commit 2279f08a authored by unknown's avatar unknown

ndb -

  Add per partition info (optionally to ndb_desc)


ndb/tools/desc.cpp:
  Add per partition info (optionally to ndb_desc)
parent e74b313c
......@@ -23,6 +23,7 @@ NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB";
static int _unqualified = 0;
static int _partinfo = 0;
static struct my_option my_long_options[] =
{
NDB_STD_OPTS("ndb_desc"),
......@@ -32,6 +33,9 @@ static struct my_option my_long_options[] =
{ "unqualified", 'u', "Use unqualified table names",
(gptr*) &_unqualified, (gptr*) &_unqualified, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "extra-partition-info", 'p', "Print more info per partition",
(gptr*) &_partinfo, (gptr*) &_partinfo, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
static void usage()
......@@ -52,6 +56,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
"d:t:O,/tmp/ndb_desc.trace");
}
static void print_part_info(Ndb* pNdb, NDBT_Table* pTab);
int main(int argc, char** argv){
NDB_INIT(argv[0]);
const char *load_default_groups[]= { "mysql_cluster",0 };
......@@ -106,7 +112,11 @@ int main(int argc, char** argv){
ndbout << (*pIdx) << endl;
}
ndbout << endl;
if (_partinfo)
print_part_info(pMyNdb, pTab);
}
else
ndbout << argv[i] << ": " << dict->getNdbError() << endl;
......@@ -115,3 +125,70 @@ int main(int argc, char** argv){
delete pMyNdb;
return NDBT_ProgramExit(NDBT_OK);
}
struct InfoInfo
{
const char * m_title;
NdbRecAttr* m_rec_attr;
const NdbDictionary::Column* m_column;
};
static
void print_part_info(Ndb* pNdb, NDBT_Table* pTab)
{
InfoInfo g_part_info[] = {
{ "Partition", 0, NdbDictionary::Column::FRAGMENT },
{ "Row count", 0, NdbDictionary::Column::ROW_COUNT },
{ "Commit count", 0, NdbDictionary::Column::COMMIT_COUNT },
{ 0, 0, 0 }
};
ndbout << "-- Per partition info -- " << endl;
NdbConnection* pTrans = pNdb->startTransaction();
if (pTrans == 0)
return;
do
{
NdbScanOperation* pOp= pTrans->getNdbScanOperation(pTab->getName());
if (pOp == NULL)
break;
NdbResultSet* rs= pOp->readTuples(NdbOperation::LM_CommittedRead);
if (rs == 0)
break;
if (pOp->interpret_exit_last_row() != 0)
break;
Uint32 i = 0;
for(i = 0; g_part_info[i].m_title != 0; i++)
{
if ((g_part_info[i].m_rec_attr = pOp->getValue(g_part_info[i].m_column)) == 0)
break;
}
if (g_part_info[i].m_title != 0)
break;
if (pTrans->execute(NoCommit) != 0)
break;
for (i = 0; g_part_info[i].m_title != 0; i++)
ndbout << g_part_info[i].m_title << "\t";
ndbout << endl;
while(rs->nextResult() == 0)
{
for(i = 0; g_part_info[i].m_title != 0; i++)
{
ndbout << *g_part_info[i].m_rec_attr << "\t";
}
ndbout << endl;
}
} while(0);
pTrans->close();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment