List:Internals« Previous MessageNext Message »
From:Stewart Smith Date:September 14 2005 9:25am
Subject:bk commit into 5.1 tree (stewart:1.2009)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2009 05/09/14 17:24:57 stewart@stripped +1 -0
  WL#2076 Add more statistics for ndbd process
  
  Add ndb_desc support for logfilegroup, undofile, datafile and tablespace.

  storage/ndb/tools/desc.cpp
    1.21 05/09/14 17:24:53 stewart@stripped +171 -39
    Add support for ndb_desc of logfilegroup, undofile, datafile and tablespace.
    
    (needs extra code for undofile and datafile in the api for those to work,
    although once the API code is done, this should automagically start working).

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	stewart
# Host:	willster.(none)
# Root:	/home/stewart/Documents/MySQL/5.1/ndb-dd

--- 1.20/storage/ndb/tools/desc.cpp	2005-04-27 12:07:11 +10:00
+++ 1.21/storage/ndb/tools/desc.cpp	2005-09-14 17:24:53 +10:00
@@ -19,6 +19,13 @@
 #include <NDBT.hpp>
 #include <NdbApi.hpp>
 
+void desc_AutoGrowSpecification(struct NdbDictionary::AutoGrowSpecification ags);
+int desc_logfilegroup(Ndb *myndb, char* name);
+int desc_undofile(Ndb *myndb, char* name);
+int desc_datafile(Ndb *myndb, char* name);
+int desc_tablespace(Ndb *myndb,char* name);
+int desc_table(Ndb *myndb,char* name);
+
 NDB_STD_OPTS_VARS;
 
 static const char* _dbname = "TEST_DB";
@@ -74,46 +81,171 @@
     ERR(MyNdb.getNdbError());
     return NDBT_ProgramExit(NDBT_FAILED);
   }
-  
-  const NdbDictionary::Dictionary * dict= MyNdb.getDictionary();
-  for (int i = 0; i < argc; i++) {
-    NDBT_Table* pTab = (NDBT_Table*)dict->getTable(argv[i]);
-    if (pTab != 0){
-      ndbout << (* pTab) << endl;
-
-      NdbDictionary::Dictionary::List list;
-      if (dict->listIndexes(list, argv[i]) != 0){
-	ndbout << argv[i] << ": " << dict->getNdbError() << endl;
-	return NDBT_ProgramExit(NDBT_FAILED);
-      }
-        
-      ndbout << "-- Indexes -- " << endl;
-      ndbout << "PRIMARY KEY(";
-      unsigned j;
-      for (j= 0; (int)j < pTab->getNoOfPrimaryKeys(); j++)
-      {
-	const NdbDictionary::Column * col = pTab->getColumn(pTab->getPrimaryKey(j));
-	ndbout << col->getName();
-	if ((int)j < pTab->getNoOfPrimaryKeys()-1)
-	  ndbout << ", ";       
-      }
-      ndbout << ") - UniqueHashIndex" << endl;
-	
-      for (j= 0; j < list.count; j++) {
-	NdbDictionary::Dictionary::List::Element& elt = list.elements[j];
-	const NdbDictionary::Index *pIdx = dict->getIndex(elt.name, argv[i]);
-	if (!pIdx){
-	  ndbout << argv[i] << ": " << dict->getNdbError() << endl;
-	  return NDBT_ProgramExit(NDBT_FAILED);
-	}
-	  
-	ndbout << (*pIdx) << endl;
-      }
-      ndbout << endl;
-    }
+
+  NdbDictionary::Dictionary * dict= MyNdb.getDictionary();
+  for(int i= 0; i<argc;i++)
+  {
+    if(desc_table(&MyNdb,argv[i]))
+      ;
+    else if(desc_tablespace(&MyNdb,argv[i]))
+      ;
+    else if(desc_logfilegroup(&MyNdb,argv[i]))
+      ;
+    else if(desc_datafile(&MyNdb, argv[i]))
+      ;
+    else if(desc_undofile(&MyNdb, argv[i]))
+      ;
     else
-      ndbout << argv[i] << ": " << dict->getNdbError() <<
endl;
+      ndbout << "No such object: " << argv[i] << endl << endl;
   }
-  
+
   return NDBT_ProgramExit(NDBT_OK);
+}
+
+void desc_AutoGrowSpecification(struct NdbDictionary::AutoGrowSpecification ags)
+{
+  ndbout << "AutoGrow.min_free: " << ags.min_free << endl;
+  ndbout << "AutoGrow.max_size: " << ags.max_size << endl;
+  ndbout << "AutoGrow.file_size: " << ags.file_size << endl;
+  ndbout << "AutoGrow.filename_pattern: " << ags.filename_pattern <<
endl;
+}
+
+int desc_logfilegroup(Ndb *myndb, char* name)
+{
+  NdbDictionary::Dictionary *dict= myndb->getDictionary();
+  assert(dict);
+  NdbDictionary::LogfileGroup lfg= dict->getLogfileGroup(name);
+  NdbError err= dict->getNdbError();
+  if(err.classification!=ndberror_cl_none)
+    return 0;
+
+  ndbout << "Type: LogfileGroup" << endl;
+  ndbout << "Name: " << lfg.getName() << endl;
+  ndbout << "UndoBuffer size: " << lfg.getUndoBufferSize() << endl;
+  ndbout << "Version: " << lfg.getObjectVersion() << endl;
+
+  desc_AutoGrowSpecification(lfg.getAutoGrowSpecification());
+
+  ndbout << endl;
+
+  return 1;
+}
+
+int desc_tablespace(Ndb *myndb, char* name)
+{
+  NdbDictionary::Dictionary *dict= myndb->getDictionary();
+  assert(dict);
+  NdbDictionary::Tablespace ts= dict->getTablespace(name);
+  NdbError err= dict->getNdbError();
+  if(err.classification!=ndberror_cl_none)
+    return 0;
+
+  ndbout << "Type: Tablespace" << endl;
+  ndbout << "Name: " << ts.getName() << endl;
+  ndbout << "Object Version: " << ts.getObjectVersion() << endl;
+  ndbout << "Extent Size: " << ts.getExtentSize() << endl;
+  ndbout << "Default Logfile Group: " << ts.getDefaultLogfileGroup() <<
endl;
+  ndbout << endl;
+  return 1;
+}
+
+int desc_undofile(Ndb *myndb, char* name)
+{
+  NdbDictionary::Dictionary *dict= myndb->getDictionary();
+  assert(dict);
+  NdbDictionary::Undofile uf= dict->getUndofile(1,name);
+  NdbError err= dict->getNdbError();
+  if(err.classification!=ndberror_cl_none)
+    return 0;
+
+  ndbout << "Type: Undofile" << endl;
+  ndbout << "Name: " << name << endl;
+  ndbout << "Path: " << uf.getPath() << endl;
+  ndbout << "Size: " << uf.getSize() << endl;
+  ndbout << "Free: " << uf.getFree() << endl;
+
+  ndbout << "Logfile Group: " << uf.getLogfileGroup() << endl;
+
+  /** FIXME: are these needed, the functions aren't there
+      but the prototypes are...
+
+      ndbout << "Node: " << uf.getNode() << endl;
+
+      ndbout << "Number: " << uf.getFileNo() << endl;
+  */
+
+  ndbout << endl;
+
+  return 1;
+}
+
+int desc_datafile(Ndb *myndb, char* name)
+{
+  NdbDictionary::Dictionary *dict= myndb->getDictionary();
+  assert(dict);
+  NdbDictionary::Datafile df= dict->getDatafile(1,name);
+  NdbError err= dict->getNdbError();
+  if(err.classification!=ndberror_cl_none)
+    return 0;
+
+  ndbout << "Type: Datafile" << endl;
+  ndbout << "Name: " << name << endl;
+  ndbout << "Path: " << df.getPath() << endl;
+  ndbout << "Size: " << df.getSize() << endl;
+  ndbout << "Free: " << df.getFree() << endl;
+
+  ndbout << "Tablespace: " << df.getTablespace() << endl;
+
+  /** FIXME: are these needed, the functions aren't there
+      but the prototypes are...
+
+      ndbout << "Node: " << uf.getNode() << endl;
+
+      ndbout << "Number: " << uf.getFileNo() << endl;
+  */
+
+  ndbout << endl;
+
+  return 1;
+}
+
+int desc_table(Ndb *myndb, char* name)
+{
+  NdbDictionary::Dictionary * dict= myndb->getDictionary();
+  NDBT_Table* pTab = (NDBT_Table*)dict->getTable(name);
+  if (!pTab)
+    return 0;
+
+  ndbout << (* pTab) << endl;
+
+  NdbDictionary::Dictionary::List list;
+  if (dict->listIndexes(list, name) != 0){
+    ndbout << name << ": " << dict->getNdbError() << endl;
+    return NDBT_ProgramExit(NDBT_FAILED);
+  }
+
+  ndbout << "-- Indexes -- " << endl;
+  ndbout << "PRIMARY KEY(";
+  unsigned j;
+  for (j= 0; (int)j < pTab->getNoOfPrimaryKeys(); j++)
+  {
+    const NdbDictionary::Column * col= pTab->getColumn(pTab->getPrimaryKey(j));
+    ndbout << col->getName();
+    if ((int)j < pTab->getNoOfPrimaryKeys()-1)
+      ndbout << ", ";
+  }
+  ndbout << ") - UniqueHashIndex" << endl;
+  for (j= 0; j < list.count; j++) {
+    NdbDictionary::Dictionary::List::Element& elt = list.elements[j];
+    const NdbDictionary::Index *pIdx = dict->getIndex(elt.name, name);
+    if (!pIdx){
+      ndbout << name << ": " << dict->getNdbError() << endl;
+      return NDBT_ProgramExit(NDBT_FAILED);
+    }
+
+    ndbout << (*pIdx) << endl;
+  }
+  ndbout << endl;
+
+  return 1;
 }
Thread
bk commit into 5.1 tree (stewart:1.2009)Stewart Smith14 Sep