From 252880ebdf54096e7f9a3f811a241986fee96d51 Mon Sep 17 00:00:00 2001 From: Ben Thompson Date: Tue, 5 Dec 2017 16:58:06 -0600 Subject: [PATCH] MCOL-446: update myCnf-include-args.text to fix variable name. Modify mycnfUpgrade to use regex search instead of find for more accurate variable searches, this would cause problem with generic variable 'port'. --- oam/install_scripts/myCnf-include-args.text | 2 +- oamapps/postConfigure/mycnfUpgrade.cpp | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/oam/install_scripts/myCnf-include-args.text b/oam/install_scripts/myCnf-include-args.text index bc2c4c74f..40545c7ed 100644 --- a/oam/install_scripts/myCnf-include-args.text +++ b/oam/install_scripts/myCnf-include-args.text @@ -1,7 +1,7 @@ # List of my.cnf arguments that should be checked and saved during upgrade install # infinidb_local_query -log-bin=mysql-bin +log-bin server-id max_length_for_sort_data tmpdir diff --git a/oamapps/postConfigure/mycnfUpgrade.cpp b/oamapps/postConfigure/mycnfUpgrade.cpp index aa61c2cf6..a8808e740 100644 --- a/oamapps/postConfigure/mycnfUpgrade.cpp +++ b/oamapps/postConfigure/mycnfUpgrade.cpp @@ -47,7 +47,7 @@ #include #include #include - +#include #include "liboamcpp.h" #include "installdir.h" @@ -107,6 +107,7 @@ int main(int argc, char *argv[]) { includeArg = line; + boost::regex icludeArgRegEx("^#*\\s*" + includeArg + "\\s*="); //see if in my.cnf.rpmsave ifstream mycnfsavefile (mycnfsaveFile.c_str()); char line[200]; @@ -114,8 +115,7 @@ int main(int argc, char *argv[]) while (mycnfsavefile.getline(line, 200)) { oldbuf = line; - string::size_type pos = oldbuf.find(includeArg,0); - if ( pos != string::npos ) { + if ( boost::regex_search(oldbuf.begin(),oldbuf.end(),icludeArgRegEx) ) { //found in my.cnf.rpmsave, check if this is commented out if ( line[0] != '#' ) { @@ -129,8 +129,7 @@ int main(int argc, char *argv[]) while (mycnffile.getline(line1, 200)) { newbuf = line1; - string::size_type pos = newbuf.find(includeArg,0); - if ( pos != string::npos ) { + if ( boost::regex_search(newbuf.begin(),newbuf.end(),icludeArgRegEx) ) { newbuf = oldbuf; cout << "Updated argument: " << includeArg << endl; updated = true; @@ -161,8 +160,8 @@ int main(int argc, char *argv[]) while (mycnffile.getline(line1, 200)) { newbuf = line1; - string::size_type pos = newbuf.find("[mysqld]",0); - if ( pos != string::npos ) { + boost::regex mysqldSectionRegEx("\\[mysqld\\]"); + if ( boost::regex_search(newbuf.begin(),newbuf.end(),mysqldSectionRegEx) ) { lines.push_back(newbuf); newbuf = oldbuf; cout << "Added argument: " << includeArg << endl; @@ -183,10 +182,9 @@ int main(int argc, char *argv[]) newFile.close(); close(fd); + break; } } - - break; } } }