summaryrefslogtreecommitdiff
path: root/ndb/tools/desc.cpp
diff options
context:
space:
mode:
authorunknown <jonas@perch.ndb.mysql.com>2006-03-22 15:24:32 +0100
committerunknown <jonas@perch.ndb.mysql.com>2006-03-22 15:24:32 +0100
commitbe47bcecb6353a957b95535ca951a50a673881c2 (patch)
tree5baef32155a286745604acbd7f1b549e930c6518 /ndb/tools/desc.cpp
parent4a02c1939057746d996652c81a4abb2c87399d3d (diff)
parent2279f08af421311fb7b22474942dc7fe2cfd3bc6 (diff)
downloadmariadb-git-be47bcecb6353a957b95535ca951a50a673881c2.tar.gz
Merge perch.ndb.mysql.com:/home/jonas/src/41-work
into perch.ndb.mysql.com:/home/jonas/src/50-work mysql-test/lib/mtr_timer.pl: Auto merged ndb/src/kernel/blocks/ERROR_codes.txt: Auto merged ndb/src/kernel/blocks/dbdih/Dbdih.hpp: Auto merged ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Auto merged ndb/src/kernel/blocks/dbtc/Dbtc.hpp: Auto merged ndb/src/kernel/blocks/qmgr/QmgrMain.cpp: Auto merged ndb/src/ndbapi/NdbTransaction.cpp: Auto merged ndb/src/ndbapi/TransporterFacade.hpp: Auto merged ndb/test/ndbapi/testNodeRestart.cpp: Auto merged ndb/test/run-test/Makefile.am: Auto merged ndb/test/src/NdbRestarter.cpp: Auto merged sql/ha_innodb.cc: Auto merged ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: merge ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: merge ndb/src/ndbapi/Ndbif.cpp: merge ndb/src/ndbapi/TransporterFacade.cpp: merge ndb/test/ndbapi/testTimeout.cpp: merge ndb/test/run-test/daily-basic-tests.txt: merge ndb/tools/desc.cpp: merge
Diffstat (limited to 'ndb/tools/desc.cpp')
-rw-r--r--ndb/tools/desc.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/ndb/tools/desc.cpp b/ndb/tools/desc.cpp
index be0f6942db5..408227452a7 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()
@@ -45,6 +49,8 @@ static void usage()
my_print_variables(my_long_options);
}
+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 };
@@ -109,7 +115,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;
@@ -117,3 +127,71 @@ int main(int argc, char** argv){
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 },
+ { "Frag memory", 0, NdbDictionary::Column::FRAGMENT_MEMORY },
+ { 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();
+}