summaryrefslogtreecommitdiff
path: root/ndb/tools
diff options
context:
space:
mode:
authorunknown <jonas@perch.ndb.mysql.com>2006-03-22 15:06:44 +0100
committerunknown <jonas@perch.ndb.mysql.com>2006-03-22 15:06:44 +0100
commit2279f08af421311fb7b22474942dc7fe2cfd3bc6 (patch)
treeb2b50e5387260b7e461328ecec357f5d73d6cb79 /ndb/tools
parente74b313c115b6eec1e96a33e16d117f33c788ce8 (diff)
downloadmariadb-git-2279f08af421311fb7b22474942dc7fe2cfd3bc6.tar.gz
ndb -
Add per partition info (optionally to ndb_desc) ndb/tools/desc.cpp: Add per partition info (optionally to ndb_desc)
Diffstat (limited to 'ndb/tools')
-rw-r--r--ndb/tools/desc.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/ndb/tools/desc.cpp b/ndb/tools/desc.cpp
index aac47c9042c..e5371b9b458 100644
--- a/ndb/tools/desc.cpp
+++ b/ndb/tools/desc.cpp
@@ -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();
+}