Commit cd6e9fa1 authored by unknown's avatar unknown

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1

into poseidon.(none):/home/tomas/mysql-4.1-clean
parents a394be5d 13a21072
...@@ -24,13 +24,13 @@ ExecuteOnComputer: 2 ...@@ -24,13 +24,13 @@ ExecuteOnComputer: 2
[MGM] [MGM]
PortNumber: CHOOSE_PORT_MGM PortNumber: CHOOSE_PORT_MGM
[API] [MYSQLD]
[API] [MYSQLD]
[API] [MYSQLD]
[API] [MYSQLD]
[TCP DEFAULT] [TCP DEFAULT]
PortNumber: CHOOSE_PORT_TRANSPORTER PortNumber: CHOOSE_PORT_TRANSPORTER
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
static const char delimiter = ':'; static const char delimiter = ':';
static const char version[]; static const char version[];
Properties(); Properties(bool case_insensitive= false);
Properties(const Properties &); Properties(const Properties &);
Properties(const Property *, int len); Properties(const Property *, int len);
virtual ~Properties(); virtual ~Properties();
......
...@@ -25,6 +25,13 @@ ...@@ -25,6 +25,13 @@
/**************************************************************************** /****************************************************************************
* Section names * Section names
****************************************************************************/ ****************************************************************************/
const ConfigInfo::AliasPair
ConfigInfo::m_sectionNameAliases[]={
{"API", "MYSQLD"},
{0, 0}
};
const char* const char*
ConfigInfo::m_sectionNames[]={ ConfigInfo::m_sectionNames[]={
"SYSTEM", "SYSTEM",
...@@ -153,14 +160,14 @@ const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule); ...@@ -153,14 +160,14 @@ const int ConfigInfo::m_NoOfRules = sizeof(m_SectionRules)/sizeof(SectionRule);
* Config Rules declarations * Config Rules declarations
****************************************************************************/ ****************************************************************************/
static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, static bool add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx, struct InitConfigFileParser::Context &ctx,
const char * rule_data); const char * rule_data);
static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx, struct InitConfigFileParser::Context &ctx,
const char * rule_data); const char * rule_data);
static bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections, static bool check_node_vs_replicas(Vector<ConfigInfo::ConfigRuleSection>&sections,
struct InitConfigFileParser::Context &ctx, struct InitConfigFileParser::Context &ctx,
const char * rule_data); const char * rule_data);
const ConfigInfo::ConfigRule const ConfigInfo::ConfigRule
ConfigInfo::m_ConfigRules[] = { ConfigInfo::m_ConfigRules[] = {
...@@ -432,7 +439,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -432,7 +439,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
8192, 8192,
0, 0,
MAX_INT_RNIL MAX_INT_RNIL
}, },
{ {
CFG_DB_NO_TRIGGERS, CFG_DB_NO_TRIGGERS,
...@@ -1885,21 +1892,19 @@ const int ConfigInfo::m_NoOfParams = sizeof(m_ParamInfo) / sizeof(ParamInfo); ...@@ -1885,21 +1892,19 @@ const int ConfigInfo::m_NoOfParams = sizeof(m_ParamInfo) / sizeof(ParamInfo);
****************************************************************************/ ****************************************************************************/
static void require(bool v) { if(!v) abort();} static void require(bool v) { if(!v) abort();}
ConfigInfo::ConfigInfo() { ConfigInfo::ConfigInfo()
: m_info(true), m_systemDefaults(true)
{
int i; int i;
Properties *section; Properties *section;
const Properties *oldpinfo; const Properties *oldpinfo;
m_info.setCaseInsensitiveNames(true);
m_systemDefaults.setCaseInsensitiveNames(true);
for (i=0; i<m_NoOfParams; i++) { for (i=0; i<m_NoOfParams; i++) {
const ParamInfo & param = m_ParamInfo[i]; const ParamInfo & param = m_ParamInfo[i];
// Create new section if it did not exist // Create new section if it did not exist
if (!m_info.getCopy(param._section, &section)) { if (!m_info.getCopy(param._section, &section)) {
Properties newsection; Properties newsection(true);
newsection.setCaseInsensitiveNames(true);
m_info.put(param._section, &newsection); m_info.put(param._section, &newsection);
} }
...@@ -1907,7 +1912,7 @@ ConfigInfo::ConfigInfo() { ...@@ -1907,7 +1912,7 @@ ConfigInfo::ConfigInfo() {
m_info.getCopy(param._section, &section); m_info.getCopy(param._section, &section);
// Create pinfo (parameter info) entry // Create pinfo (parameter info) entry
Properties pinfo; Properties pinfo(true);
pinfo.put("Id", param._paramId); pinfo.put("Id", param._paramId);
pinfo.put("Fname", param._fname); pinfo.put("Fname", param._fname);
pinfo.put("Description", param._description); pinfo.put("Description", param._description);
...@@ -1935,8 +1940,7 @@ ConfigInfo::ConfigInfo() { ...@@ -1935,8 +1940,7 @@ ConfigInfo::ConfigInfo() {
if(param._type != ConfigInfo::SECTION){ if(param._type != ConfigInfo::SECTION){
Properties * p; Properties * p;
if(!m_systemDefaults.getCopy(param._section, &p)){ if(!m_systemDefaults.getCopy(param._section, &p)){
p = new Properties(); p = new Properties(true);
p->setCaseInsensitiveNames(true);
} }
if(param._type != STRING && if(param._type != STRING &&
param._default != UNDEFINED && param._default != UNDEFINED &&
...@@ -2063,6 +2067,14 @@ ConfigInfo::isSection(const char * section) const { ...@@ -2063,6 +2067,14 @@ ConfigInfo::isSection(const char * section) const {
return false; return false;
} }
const char*
ConfigInfo::getAlias(const char * section) const {
for (int i = 0; m_sectionNameAliases[i].name != 0; i++)
if(!strcmp(section, m_sectionNameAliases[i].alias))
return m_sectionNameAliases[i].name;
return 0;
}
bool bool
ConfigInfo::verify(const Properties * section, const char* fname, ConfigInfo::verify(const Properties * section, const char* fname,
Uint64 value) const { Uint64 value) const {
...@@ -2819,7 +2831,7 @@ fixDepricated(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2819,7 +2831,7 @@ fixDepricated(InitConfigFileParser::Context & ctx, const char * data){
* Transform old values to new values * Transform old values to new values
* Transform new values to old values (backward compatible) * Transform new values to old values (backward compatible)
*/ */
Properties tmp; Properties tmp(true);
Properties::Iterator it(ctx.m_currentSection); Properties::Iterator it(ctx.m_currentSection);
for (name = it.first(); name != NULL; name = it.next()) { for (name = it.first(); name != NULL; name = it.next()) {
const DepricationTransform * p = &f_deprication[0]; const DepricationTransform * p = &f_deprication[0];
...@@ -2951,8 +2963,8 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, ...@@ -2951,8 +2963,8 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
{ {
Uint32 i; Uint32 i;
Properties * props= ctx.m_config; Properties * props= ctx.m_config;
Properties p_connections; Properties p_connections(true);
Properties p_connections2; Properties p_connections2(true);
for (i = 0;; i++){ for (i = 0;; i++){
const Properties * tmp; const Properties * tmp;
...@@ -2972,8 +2984,8 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, ...@@ -2972,8 +2984,8 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
Uint32 nNodes; Uint32 nNodes;
ctx.m_userProperties.get("NoOfNodes", &nNodes); ctx.m_userProperties.get("NoOfNodes", &nNodes);
Properties p_db_nodes; Properties p_db_nodes(true);
Properties p_api_mgm_nodes; Properties p_api_mgm_nodes(true);
Uint32 i_db= 0, i_api_mgm= 0, n; Uint32 i_db= 0, i_api_mgm= 0, n;
for (i= 0, n= 0; n < nNodes; i++){ for (i= 0, n= 0; n < nNodes; i++){
...@@ -2999,7 +3011,7 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, ...@@ -2999,7 +3011,7 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) { if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) {
ConfigInfo::ConfigRuleSection s; ConfigInfo::ConfigRuleSection s;
s.m_sectionType= BaseString("TCP"); s.m_sectionType= BaseString("TCP");
s.m_sectionData= new Properties; s.m_sectionData= new Properties(true);
char buf[16]; char buf[16];
snprintf(buf, sizeof(buf), "%u", nodeId1); snprintf(buf, sizeof(buf), "%u", nodeId1);
s.m_sectionData->put("NodeId1", buf); s.m_sectionData->put("NodeId1", buf);
...@@ -3016,7 +3028,7 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, ...@@ -3016,7 +3028,7 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
if(!p_db_nodes.get("", j, &nodeId2)) break; if(!p_db_nodes.get("", j, &nodeId2)) break;
ConfigInfo::ConfigRuleSection s; ConfigInfo::ConfigRuleSection s;
s.m_sectionType= BaseString("TCP"); s.m_sectionType= BaseString("TCP");
s.m_sectionData= new Properties; s.m_sectionData= new Properties(true);
char buf[16]; char buf[16];
snprintf(buf, sizeof(buf), "%u", nodeId1); snprintf(buf, sizeof(buf), "%u", nodeId1);
s.m_sectionData->put("NodeId1", buf); s.m_sectionData->put("NodeId1", buf);
...@@ -3037,7 +3049,7 @@ static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections, ...@@ -3037,7 +3049,7 @@ static bool add_server_ports(Vector<ConfigInfo::ConfigRuleSection>&sections,
{ {
#if 0 #if 0
Properties * props= ctx.m_config; Properties * props= ctx.m_config;
Properties computers; Properties computers(true);
Uint32 port_base = NDB_BASE_PORT+2; Uint32 port_base = NDB_BASE_PORT+2;
Uint32 nNodes; Uint32 nNodes;
......
...@@ -61,6 +61,11 @@ public: ...@@ -61,6 +61,11 @@ public:
Uint64 _max; Uint64 _max;
}; };
struct AliasPair{
const char * name;
const char * alias;
};
/** /**
* Entry for one section rule * Entry for one section rule
*/ */
...@@ -100,6 +105,7 @@ public: ...@@ -100,6 +105,7 @@ public:
* @note Result is not defined if section/name are wrong! * @note Result is not defined if section/name are wrong!
*/ */
bool verify(const Properties* secti, const char* fname, Uint64 value) const; bool verify(const Properties* secti, const char* fname, Uint64 value) const;
const char* getAlias(const char*) const;
bool isSection(const char*) const; bool isSection(const char*) const;
const char* getDescription(const Properties * sec, const char* fname) const; const char* getDescription(const Properties * sec, const char* fname) const;
...@@ -123,6 +129,7 @@ private: ...@@ -123,6 +129,7 @@ private:
static const ParamInfo m_ParamInfo[]; static const ParamInfo m_ParamInfo[];
static const int m_NoOfParams; static const int m_NoOfParams;
static const AliasPair m_sectionNameAliases[];
static const char* m_sectionNames[]; static const char* m_sectionNames[];
static const int m_noOfSectionNames; static const int m_noOfSectionNames;
......
...@@ -43,10 +43,10 @@ InitConfigFileParser::~InitConfigFileParser() { ...@@ -43,10 +43,10 @@ InitConfigFileParser::~InitConfigFileParser() {
// Read Config File // Read Config File
//**************************************************************************** //****************************************************************************
InitConfigFileParser::Context::Context(const ConfigInfo * info) InitConfigFileParser::Context::Context(const ConfigInfo * info)
: m_configValues(1000, 20) { : m_configValues(1000, 20), m_userProperties(true) {
m_config = new Properties(); m_config = new Properties(true);
m_defaults = new Properties(); m_defaults = new Properties(true);
} }
InitConfigFileParser::Context::~Context(){ InitConfigFileParser::Context::~Context(){
...@@ -115,7 +115,7 @@ InitConfigFileParser::parseConfig(FILE * file) { ...@@ -115,7 +115,7 @@ InitConfigFileParser::parseConfig(FILE * file) {
snprintf(ctx.fname, sizeof(ctx.fname), section); free(section); snprintf(ctx.fname, sizeof(ctx.fname), section); free(section);
ctx.type = InitConfigFileParser::DefaultSection; ctx.type = InitConfigFileParser::DefaultSection;
ctx.m_sectionLineno = ctx.m_lineno; ctx.m_sectionLineno = ctx.m_lineno;
ctx.m_currentSection = new Properties(); ctx.m_currentSection = new Properties(true);
ctx.m_userDefaults = NULL; ctx.m_userDefaults = NULL;
ctx.m_currentInfo = m_info->getInfo(ctx.fname); ctx.m_currentInfo = m_info->getInfo(ctx.fname);
ctx.m_systemDefaults = m_info->getDefaults(ctx.fname); ctx.m_systemDefaults = m_info->getDefaults(ctx.fname);
...@@ -137,7 +137,7 @@ InitConfigFileParser::parseConfig(FILE * file) { ...@@ -137,7 +137,7 @@ InitConfigFileParser::parseConfig(FILE * file) {
free(section); free(section);
ctx.type = InitConfigFileParser::Section; ctx.type = InitConfigFileParser::Section;
ctx.m_sectionLineno = ctx.m_lineno; ctx.m_sectionLineno = ctx.m_lineno;
ctx.m_currentSection = new Properties(); ctx.m_currentSection = new Properties(true);
ctx.m_userDefaults = getSection(ctx.fname, ctx.m_defaults); ctx.m_userDefaults = getSection(ctx.fname, ctx.m_defaults);
ctx.m_currentInfo = m_info->getInfo(ctx.fname); ctx.m_currentInfo = m_info->getInfo(ctx.fname);
ctx.m_systemDefaults = m_info->getDefaults(ctx.fname); ctx.m_systemDefaults = m_info->getDefaults(ctx.fname);
...@@ -222,6 +222,8 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) { ...@@ -222,6 +222,8 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) {
char tmpLine[MAX_LINE_LENGTH]; char tmpLine[MAX_LINE_LENGTH];
char fname[MAX_LINE_LENGTH], rest[MAX_LINE_LENGTH]; char fname[MAX_LINE_LENGTH], rest[MAX_LINE_LENGTH];
char* t; char* t;
const char *separator_list[]= {":", "="};
const char *separator= 0;
if (ctx.m_currentSection == NULL){ if (ctx.m_currentSection == NULL){
ctx.reportError("Value specified outside section"); ctx.reportError("Value specified outside section");
...@@ -233,7 +235,14 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) { ...@@ -233,7 +235,14 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) {
// ************************************* // *************************************
// Check if a separator exists in line // Check if a separator exists in line
// ************************************* // *************************************
if (!strchr(tmpLine, ':')) { for(int i= 0; i < sizeof(separator_list); i++) {
if(strchr(tmpLine, separator_list[i][0])) {
separator= separator_list[i];
break;
}
}
if (separator == 0) {
ctx.reportError("Parse error"); ctx.reportError("Parse error");
return false; return false;
} }
...@@ -241,13 +250,13 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) { ...@@ -241,13 +250,13 @@ bool InitConfigFileParser::parseNameValuePair(Context& ctx, const char* line) {
// ******************************************* // *******************************************
// Get pointer to substring before separator // Get pointer to substring before separator
// ******************************************* // *******************************************
t = strtok(tmpLine, ":"); t = strtok(tmpLine, separator);
// ***************************************** // *****************************************
// Count number of tokens before separator // Count number of tokens before separator
// ***************************************** // *****************************************
if (sscanf(t, "%120s%120s", fname, rest) != 1) { if (sscanf(t, "%120s%120s", fname, rest) != 1) {
ctx.reportError("Multiple names before \':\'"); ctx.reportError("Multiple names before \'%c\'", separator[0]);
return false; return false;
} }
if (!ctx.m_currentInfo->contains(fname)) { if (!ctx.m_currentInfo->contains(fname)) {
...@@ -475,8 +484,24 @@ InitConfigFileParser::parseSectionHeader(const char* line) const { ...@@ -475,8 +484,24 @@ InitConfigFileParser::parseSectionHeader(const char* line) const {
tmp[0] = ' '; tmp[0] = ' ';
trim(tmp); trim(tmp);
// Convert section header to upper
for(int i= strlen(tmp)-1; i >= 0; i--)
tmp[i]= toupper(tmp[i]);
// 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);
}
}
// Lookup token among sections // Lookup token among sections
if(!m_info->isSection(tmp)) return NULL; if(!m_info->isSection(tmp)) {
free(tmp);
return NULL;
}
if(m_info->getInfo(tmp)) return tmp; if(m_info->getInfo(tmp)) return tmp;
free(tmp); free(tmp);
......
...@@ -56,7 +56,7 @@ class PropertiesImpl { ...@@ -56,7 +56,7 @@ class PropertiesImpl {
PropertiesImpl(const PropertiesImpl &); // Not implemented PropertiesImpl(const PropertiesImpl &); // Not implemented
PropertiesImpl& operator=(const PropertiesImpl&); // Not implemented PropertiesImpl& operator=(const PropertiesImpl&); // Not implemented
public: public:
PropertiesImpl(Properties *); PropertiesImpl(Properties *, bool case_insensitive);
PropertiesImpl(Properties *, const PropertiesImpl &); PropertiesImpl(Properties *, const PropertiesImpl &);
~PropertiesImpl(); ~PropertiesImpl();
...@@ -69,6 +69,7 @@ class PropertiesImpl { ...@@ -69,6 +69,7 @@ class PropertiesImpl {
bool m_insensitive; bool m_insensitive;
int (* compare)(const char *s1, const char *s2); int (* compare)(const char *s1, const char *s2);
void setCaseInsensitiveNames(bool value);
void grow(int sizeToAdd); void grow(int sizeToAdd);
PropertyImpl * get(const char * name) const; PropertyImpl * get(const char * name) const;
...@@ -113,9 +114,9 @@ Property::~Property(){ ...@@ -113,9 +114,9 @@ Property::~Property(){
/** /**
* Methods for Properties * Methods for Properties
*/ */
Properties::Properties(){ Properties::Properties(bool case_insensitive){
parent = 0; parent = 0;
impl = new PropertiesImpl(this); impl = new PropertiesImpl(this, case_insensitive);
} }
Properties::Properties(const Properties & org){ Properties::Properties(const Properties & org){
...@@ -124,7 +125,7 @@ Properties::Properties(const Properties & org){ ...@@ -124,7 +125,7 @@ Properties::Properties(const Properties & org){
} }
Properties::Properties(const Property * anArray, int arrayLen){ Properties::Properties(const Property * anArray, int arrayLen){
impl = new PropertiesImpl(this); impl = new PropertiesImpl(this, false);
put(anArray, arrayLen); put(anArray, arrayLen);
} }
...@@ -479,13 +480,12 @@ Properties::unpack(const Uint32 * buf, Uint32 bufLen){ ...@@ -479,13 +480,12 @@ Properties::unpack(const Uint32 * buf, Uint32 bufLen){
/** /**
* Methods for PropertiesImpl * Methods for PropertiesImpl
*/ */
PropertiesImpl::PropertiesImpl(Properties * p){ PropertiesImpl::PropertiesImpl(Properties * p, bool case_insensitive){
this->properties = p; this->properties = p;
items = 0; items = 0;
size = 25; size = 25;
content = new PropertyImpl * [size]; content = new PropertyImpl * [size];
this->m_insensitive = false; setCaseInsensitiveNames(case_insensitive);
this->compare = strcmp;
} }
PropertiesImpl::PropertiesImpl(Properties * p, const PropertiesImpl & org){ PropertiesImpl::PropertiesImpl(Properties * p, const PropertiesImpl & org){
...@@ -506,6 +506,15 @@ PropertiesImpl::~PropertiesImpl(){ ...@@ -506,6 +506,15 @@ PropertiesImpl::~PropertiesImpl(){
delete [] content; delete [] content;
} }
void
PropertiesImpl::setCaseInsensitiveNames(bool value){
m_insensitive = value;
if(value)
compare = strcasecmp;
else
compare = strcmp;
}
void void
PropertiesImpl::grow(int sizeToAdd){ PropertiesImpl::grow(int sizeToAdd){
PropertyImpl ** newContent = new PropertyImpl * [size + sizeToAdd]; PropertyImpl ** newContent = new PropertyImpl * [size + sizeToAdd];
...@@ -523,9 +532,11 @@ PropertiesImpl::get(const char * name) const { ...@@ -523,9 +532,11 @@ PropertiesImpl::get(const char * name) const {
return 0; return 0;
} }
for(unsigned int i = 0; i<tmp->items; i++) for(unsigned int i = 0; i<tmp->items; i++) {
if((* compare)(tmp->content[i]->name, short_name) == 0) if((* compare)(tmp->content[i]->name, short_name) == 0)
return tmp->content[i]; return tmp->content[i];
}
return 0; return 0;
} }
...@@ -1110,11 +1121,7 @@ Properties::getCopy(const char * name, Uint32 no, Properties ** value) const { ...@@ -1110,11 +1121,7 @@ Properties::getCopy(const char * name, Uint32 no, Properties ** value) const {
void void
Properties::setCaseInsensitiveNames(bool value){ Properties::setCaseInsensitiveNames(bool value){
impl->m_insensitive = value; impl->setCaseInsensitiveNames(value);
if(value)
impl->compare = strcasecmp;
else
impl->compare = strcmp;
} }
bool bool
......
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