List:Internals« Previous MessageNext Message »
From:jonas Date:April 18 2006 9:27pm
Subject:bk commit into 5.0 tree (jonas:1.2011)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jonas. When jonas 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.2011 06/04/18 21:27:27 jonas@eel.(none) +4 -0
  ndb - Impl. support for making distinction between alias/name
    (typically API/MYSQLD)

  ndb/src/mgmsrv/InitConfigFileParser.hpp
    1.9 06/04/18 21:27:23 jonas@eel.(none) +3 -2
    Impl. support for making distinction between alias/name
      (typically API/MYSQLD)

  ndb/src/mgmsrv/InitConfigFileParser.cpp
    1.24 06/04/18 21:27:23 jonas@eel.(none) +64 -50
    Impl. support for making distinction between alias/name
      (typically API/MYSQLD)

  ndb/src/mgmsrv/ConfigInfo.hpp
    1.12 06/04/18 21:27:23 jonas@eel.(none) +8 -8
    Impl. support for making distinction between alias/name
      (typically API/MYSQLD)

  ndb/src/mgmsrv/ConfigInfo.cpp
    1.69 06/04/18 21:27:23 jonas@eel.(none) +50 -37
    Impl. support for making distinction between alias/name
      (typically API/MYSQLD)

# 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:	jonas
# Host:	eel.(none)
# Root:	/home/jonas/src/50-atrt

--- 1.68/ndb/src/mgmsrv/ConfigInfo.cpp	2005-09-30 10:02:54 +02:00
+++ 1.69/ndb/src/mgmsrv/ConfigInfo.cpp	2006-04-18 21:27:23 +02:00
@@ -46,32 +46,23 @@
 #define MGM_TOKEN "MGM"
 #define API_TOKEN "API"
 
-const ConfigInfo::AliasPair
-ConfigInfo::m_sectionNameAliases[]={
-  {API_TOKEN, "MYSQLD"},
-  {DB_TOKEN,  "NDBD"},
-  {MGM_TOKEN, "NDB_MGMD"},
-  {0, 0}
-};
-
-const char* 
-ConfigInfo::m_sectionNames[]={
-  "SYSTEM",
-  "EXTERNAL SYSTEM",
-  "COMPUTER",
-
-  DB_TOKEN,
-  MGM_TOKEN,
-  API_TOKEN,
-
-  "TCP",
-  "SCI",
-  "SHM",
-  "OSE"
+const ConfigInfoAliasPair
+ConfigInfo::m_sectionNames[]=
+{
+  { "SYSTEM", 0, 0 },
+  { "EXTERNAL SYSTEM", 0, 0 },
+  { "COMPUTER", 0, 0 },
+  
+  { DB_TOKEN, "NDBD", 0 },
+  { MGM_TOKEN, "NDB_MGMD", 0 },
+  { API_TOKEN, "MYSQLD", 0 },
+  
+  { "TCP", 0, 0 },
+  { "SCI", 0, 0 },
+  { "SHM", 0, 0 },
+  { "OSE", 0, 0 },
+  { 0, 0, 0 }
 };
-const int ConfigInfo::m_noOfSectionNames = 
-sizeof(m_sectionNames)/sizeof(char*);
-
 
 /****************************************************************************
  * Section Rules declarations
@@ -100,6 +91,7 @@
 static bool fixBackupDataDir(InitConfigFileParser::Context & ctx, const char * data);
 static bool fixShmUniqueId(InitConfigFileParser::Context & ctx, const char * data);
 static bool checkLocalhostHostnameMix(InitConfigFileParser::Context & ctx, const char
* data);
+static bool handleApiMysqld(InitConfigFileParser::Context & ctx, const char * data);
 
 const ConfigInfo::SectionRule 
 ConfigInfo::m_SectionRules[] = {
@@ -190,6 +182,8 @@
   
   { "*",    checkMandatory, 0 },
   
+  { API_TOKEN, handleApiMysqld, 0 },
+  
   { DB_TOKEN,   saveInConfigValues, 0 },
   { API_TOKEN,  saveInConfigValues, 0 },
   { MGM_TOKEN,  saveInConfigValues, 0 },
@@ -2419,27 +2413,33 @@
   return getInfoString(section, fname, "Description");
 }
 
-bool
-ConfigInfo::isSection(const char * section) const {
-  for (int i = 0; i<m_noOfSectionNames; i++) {
-    if(!strcasecmp(section, m_sectionNames[i])) return true;
+const ConfigInfoAliasPair*
+ConfigInfo::getSection(const char * section) const 
+{
+  for (int i = 0; m_sectionNames[i].name; i++) {
+    if (!strcasecmp(section, m_sectionNames[i].name)) 
+      return m_sectionNames + i;
+    if (m_sectionNames[i].alias && 
+	!strcasecmp(section, m_sectionNames[i].alias))
+      return m_sectionNames + i;
   }
-  return false;
+  return 0;
 }
 
 const char*
 ConfigInfo::nameToAlias(const char * name) {
-  for (int i = 0; m_sectionNameAliases[i].name != 0; i++)
-    if(!strcasecmp(name, m_sectionNameAliases[i].name))
-      return m_sectionNameAliases[i].alias;
+  for (int i = 0; m_sectionNames[i].name; i++)
+    if(!strcasecmp(name, m_sectionNames[i].name) && m_sectionNames[i].alias)
+      return m_sectionNames[i].alias;
   return 0;
 }
 
 const char*
 ConfigInfo::getAlias(const char * section) {
-  for (int i = 0; m_sectionNameAliases[i].name != 0; i++)
-    if(!strcasecmp(section, m_sectionNameAliases[i].alias))
-      return m_sectionNameAliases[i].name;
+  for (int i = 0; m_sectionNames[i].name != 0; i++)
+    if(m_sectionNames[i].alias && 
+       !strcasecmp(section, m_sectionNames[i].alias))
+      return m_sectionNames[i].name;
   return 0;
 }
 
@@ -2623,6 +2623,18 @@
   DBUG_RETURN(true);
 }
 
+static bool 
+handleApiMysqld(InitConfigFileParser::Context & ctx, const char * data)
+{
+  const char * name = 0;
+  if (ctx.m_currentSection->get("FileSection", &name) &&
+      strcmp(name, "MYSQLD") == 0)
+  {
+    ctx.m_currentSection->put("SectionType", NODE_TYPE_API);
+  }
+  return true;
+}
+
 bool
 fixNodeHostname(InitConfigFileParser::Context & ctx, const char * data)
 {
@@ -3501,7 +3513,8 @@
     require(sec->get("Fname", &secName));
     require(sec->get("Id", &id));
     require(sec->get("Status", &status));
-    require(sec->get("SectionType", &typeVal));
+    if (!ctx.m_currentSection->get("SectionType", &typeVal))
+      require(sec->get("SectionType", &typeVal));
     
     if(id == KEY_INTERNAL || status == ConfigInfo::CI_INTERNAL){
       ndbout_c("skipping section %s", ctx.fname);

--- 1.11/ndb/src/mgmsrv/ConfigInfo.hpp	2005-07-26 10:14:27 +02:00
+++ 1.12/ndb/src/mgmsrv/ConfigInfo.hpp	2006-04-18 21:27:23 +02:00
@@ -30,6 +30,12 @@
 static const char* MANDATORY = (char*)~(UintPtr)0;// Default value for mandatory params.
 static const char* UNDEFINED = 0;                 // Default value for undefined params.
 
+struct ConfigInfoAliasPair {
+  const char * name;
+  const char * alias;
+  const char * supplied_name; // point to either name or alias
+};
+
 /**
  * @class  ConfigInfo
  * @brief  Metainformation about ALL cluster configuration parameters 
@@ -61,10 +67,6 @@
     const char*    _max;
   };
 
-  struct AliasPair{
-    const char * name;
-    const char * alias;
-  };
 
   /**
    * Entry for one section rule
@@ -107,7 +109,7 @@
   bool verify(const Properties* secti, const char* fname, Uint64 value) const;
   static const char* nameToAlias(const char*);
   static const char* getAlias(const char*);
-  bool isSection(const char*) const;
+  const ConfigInfoAliasPair* getSection(const char*) const;
 
   const char*  getDescription(const Properties * sec, const char* fname) const;
   Type         getType(const Properties * section, const char* fname) const;
@@ -127,9 +129,7 @@
   Properties               m_info;
   Properties               m_systemDefaults;
 
-  static const AliasPair   m_sectionNameAliases[];
-  static const char*       m_sectionNames[];
-  static const int         m_noOfSectionNames;
+  static const ConfigInfoAliasPair   m_sectionNames[];
 
 public:
   static const ParamInfo   m_ParamInfo[];

--- 1.23/ndb/src/mgmsrv/InitConfigFileParser.cpp	2005-10-03 11:49:00 +02:00
+++ 1.24/ndb/src/mgmsrv/InitConfigFileParser.cpp	2006-04-18 21:27:23 +02:00
@@ -107,14 +107,14 @@
     /********************************
      * 1. Parse new default section *
      ********************************/
-    if (char* section = parseDefaultSectionHeader(line)) {
+    ConfigInfoAliasPair section;
+    if (parseDefaultSectionHeader(line, &section)) {
       if(!storeSection(ctx)){
-	free(section);
 	ctx.reportError("Could not store previous default section "
 			"of configuration file.");
 	return 0;
       }
-      BaseString::snprintf(ctx.fname, sizeof(ctx.fname), section); free(section);
+      BaseString::snprintf(ctx.fname, sizeof(ctx.fname), section.name);
       ctx.type             = InitConfigFileParser::DefaultSection;
       ctx.m_sectionLineno  = ctx.m_lineno;
       ctx.m_currentSection = new Properties(true);
@@ -127,18 +127,17 @@
     /************************
      * 2. Parse new section *
      ************************/
-    if (char* section = parseSectionHeader(line)) {
+    if (parseSectionHeader(line, &section)) {
       if(!storeSection(ctx)){
-	free(section);
 	ctx.reportError("Could not store previous section "
 			"of configuration file.");
 	return 0;
       }
-      BaseString::snprintf(ctx.fname, sizeof(ctx.fname), section);
-      free(section);
+      BaseString::snprintf(ctx.fname, sizeof(ctx.fname), section.name);
       ctx.type             = InitConfigFileParser::Section;
       ctx.m_sectionLineno  = ctx.m_lineno;      
       ctx.m_currentSection = new Properties(true);
+      ctx.m_currentSection->put("FileSection", section.supplied_name);
       ctx.m_userDefaults   = getSection(ctx.fname, ctx.m_defaults);
       require((ctx.m_currentInfo    = m_info->getInfo(ctx.fname)) != 0);
       require((ctx.m_systemDefaults = m_info->getDefaults(ctx.fname)) != 0);
@@ -463,70 +462,85 @@
   memmove(str, &str[pos], len - pos + 2);
 }
 
-char* 
-InitConfigFileParser::parseSectionHeader(const char* line) const {
+bool
+InitConfigFileParser::parseSectionHeader(const char* line,
+					 ConfigInfoAliasPair* out) const {
+  bool retVal = false;
   char * tmp = strdup(line);
 
-  if(tmp[0] != '['){
-    free(tmp);
-    return NULL;
-  }
-
-  if(tmp[strlen(tmp)-1] != ']'){
-    free(tmp);
-    return NULL;
-  }
-  tmp[strlen(tmp)-1] = 0;
+  do {
+    if(tmp[0] != '[')
+      break;
 
-  tmp[0] = ' ';
-  trim(tmp);
+    if(tmp[strlen(tmp)-1] != ']')
+      break;
 
-  // Get the correct header name if an alias
-  {
-    const char *tmp_alias= m_info->getAlias(tmp);
-    if (tmp_alias) {
-      free(tmp);
-      tmp= strdup(tmp_alias);
+    tmp[strlen(tmp)-1] = 0;
+    
+    tmp[0] = ' ';
+    trim(tmp);
+    
+    // Get the correct header name if an alias
+    const ConfigInfoAliasPair *section = m_info->getSection(tmp);
+    if (section == 0)
+      break;
+    
+    * out = *section;
+    if (strcasecmp(tmp, out->name) == 0)
+    {
+      out->supplied_name = out->name;
     }
-  }
-
-  // Lookup token among sections
-  if(!m_info->isSection(tmp)) {
-    free(tmp);
-    return NULL;
-  }
-  if(m_info->getInfo(tmp)) return tmp;
-
+    else
+    {
+      out->supplied_name = out->alias;
+    }
+    
+    if(m_info->getInfo(out->name))
+      retVal = true;
+    
+  } while(0);
+  
   free(tmp);
-  return NULL;
+  return retVal;
 }
 
 //****************************************************************************
 //  Parse Default Section Header
 //****************************************************************************
 
-char* 
-InitConfigFileParser::parseDefaultSectionHeader(const char* line) const {
+bool
+InitConfigFileParser::parseDefaultSectionHeader
+(const char* line, ConfigInfoAliasPair *out) const 
+{
   static char token1[MAX_LINE_LENGTH], token2[MAX_LINE_LENGTH];
-
+  
   int no = sscanf(line, "[%120[A-Z_a-z] %120[A-Z_a-z]]", token1, token2);
-
+  
   // Not correct no of tokens 
-  if (no != 2) return NULL;
-
+  if (no != 2) 
+    return false;
+  
   // Not correct keyword at end
-  if (!strcasecmp(token2, "DEFAULT") == 0) return NULL;
+  if (!strcasecmp(token2, "DEFAULT") == 0) 
+    return false;
+  
+  const ConfigInfoAliasPair * section = m_info->getSection(token1);
+  if (section == 0)
+    return false;
 
-  const char *token1_alias= m_info->getAlias(token1);
-  if (token1_alias == 0)
-    token1_alias= token1;
+  * out = * section;
+  if (strcasecmp(token1, out->name) == 0)
+    out->supplied_name = out->name;
+  else
+    out->supplied_name = out->alias;
 
-  if(m_info->getInfo(token1_alias)){
-    return strdup(token1_alias);
+  if(m_info->getInfo(out->name))
+  {
+    return true;
   }
   
   // Did not find section
-  return NULL;
+  return false;
 }
 
 const Properties *

--- 1.8/ndb/src/mgmsrv/InitConfigFileParser.hpp	2005-09-30 11:42:29 +02:00
+++ 1.9/ndb/src/mgmsrv/InitConfigFileParser.hpp	2006-04-18 21:27:23 +02:00
@@ -24,6 +24,7 @@
 
 class Config;
 class ConfigInfo;
+struct ConfigInfoAliasPair;
 
 /**
  * @class InitConfigFileParser
@@ -105,14 +106,14 @@
    *   @param   line:  String to search
    *   @return  section header if matching some section header, NULL otherwise
    */
-  char* parseSectionHeader(const char* line) const;
+  bool parseSectionHeader(const char* line, ConfigInfoAliasPair* out) const;
 
   /**
    *   Checks if line contains a default header
    *   @param   line:  String to search
    *   @return  section header if matching some section header, NULL otherwise
    */
-  char* parseDefaultSectionHeader(const char* line) const;
+  bool parseDefaultSectionHeader(const char*, ConfigInfoAliasPair*) const;
   
   bool parseNameValuePair(Context&, const char* line);
   bool storeNameValuePair(Context&, const char* fname, const char* value);
Thread
bk commit into 5.0 tree (jonas:1.2011)jonas18 Apr