Bug #47426 | Parser.cpp won't parse "x=c:\windows" | ||
---|---|---|---|
Submitted: | 18 Sep 2009 1:27 | Modified: | 25 Sep 2009 11:27 |
Reporter: | jack andrews | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Cluster: Cluster (NDB) storage engine | Severity: | S3 (Non-critical) |
Version: | mysql-5.1-telco-7.0 | OS: | Windows |
Assigned to: | jack andrews | CPU Architecture: | Any |
[18 Sep 2009 1:27]
jack andrews
[18 Sep 2009 3:31]
jack andrews
patch posted to dev-ndb@
[22 Sep 2009 7:45]
jack andrews
patch here: === modified file 'storage/ndb/src/common/util/Parser.cpp' Index: storage/ndb/src/common/util/Parser.cpp =================================================================== --- storage/ndb/src/common/util/Parser.cpp.orig 2009-09-22 17:41:01.001000000 +1000 +++ storage/ndb/src/common/util/Parser.cpp 2009-09-22 17:43:10.758000000 +1000 @@ -122,11 +122,10 @@ static bool split(char * buf, char ** name, char ** value){ - - * value = strchr(buf, ':'); - if(* value == 0) - * value = strchr(buf, '='); + for (*value=buf; **value; (*value)++) + if (**value == ':' || **value == '=') + break; if(* value == 0){ return false; @@ -357,3 +356,20 @@ } template class Vector<const ParserRow<ParserImpl::Dummy>*>; + +#ifdef TEST_PARSER +#include <NdbTap.hpp> + +TAPTEST(Parser) +{ + char *str, *name, *value; + + //split modifies arg so dup + str = strdup("x=c:\\windows"); + OK(split(str, &name, &value)); + OK(!strcmp(name, "x")); + OK(!strcmp(value, "c:\\windows")); + + return 1; +} +#endif Index: storage/ndb/src/common/util/CMakeLists.txt =================================================================== --- storage/ndb/src/common/util/CMakeLists.txt.orig 2009-09-22 17:41:00.979000000 +1000 +++ storage/ndb/src/common/util/CMakeLists.txt 2009-09-22 17:42:15.278000000 +1000 @@ -67,3 +67,7 @@ PROPERTIES COMPILE_FLAGS "-DTEST_BITMASK") TARGET_LINK_LIBRARIES(Bitmask-t ndbgeneral) +ADD_EXECUTABLE(Parser-t Parser.cpp) +SET_TARGET_PROPERTIES(Parser-t + PROPERTIES COMPILE_FLAGS "-DTEST_PARSER") +TARGET_LINK_LIBRARIES(Parser-t ndbgeneral)
[22 Sep 2009 7:50]
Jonas Oreland
for 6.2 ?
[22 Sep 2009 7:55]
jack andrews
the patch is for 7.0 (it includes tap and CMakeLists.txt) but could be back ported -- i'm too busy on assigned tasks at the moment
[22 Sep 2009 8:31]
jack andrews
sorry, no braces around the for and if statmenets: === modified file 'storage/ndb/src/common/util/Parser.cpp' Index: storage/ndb/src/common/util/Parser.cpp =================================================================== --- storage/ndb/src/common/util/Parser.cpp.orig 2009-09-22 17:45:50.408000000 +1000 +++ storage/ndb/src/common/util/Parser.cpp 2009-09-22 18:28:54.762000000 +1000 @@ -122,11 +122,12 @@ static bool split(char * buf, char ** name, char ** value){ - - * value = strchr(buf, ':'); - if(* value == 0) - * value = strchr(buf, '='); + for (*value=buf; **value; (*value)++) { + if (**value == ':' || **value == '=') { + break; + } + } if(* value == 0){ return false; @@ -357,3 +358,20 @@ } template class Vector<const ParserRow<ParserImpl::Dummy>*>; + +#ifdef TEST_PARSER +#include <NdbTap.hpp> + +TAPTEST(Parser) +{ + char *str, *name, *value; + + //split modifies arg so dup + str = strdup("x=c:\\windows"); + OK(split(str, &name, &value)); + OK(!strcmp(name, "x")); + OK(!strcmp(value, "c:\\windows")); + + return 1; +} +#endif Index: storage/ndb/src/common/util/CMakeLists.txt =================================================================== --- storage/ndb/src/common/util/CMakeLists.txt.orig 2009-09-22 17:45:50.355000000 +1000 +++ storage/ndb/src/common/util/CMakeLists.txt 2009-09-22 17:48:10.882000000 +1000 @@ -67,3 +67,7 @@ PROPERTIES COMPILE_FLAGS "-DTEST_BITMASK") TARGET_LINK_LIBRARIES(Bitmask-t ndbgeneral) +ADD_EXECUTABLE(Parser-t Parser.cpp) +SET_TARGET_PROPERTIES(Parser-t + PROPERTIES COMPILE_FLAGS "-DTEST_PARSER") +TARGET_LINK_LIBRARIES(Parser-t ndbgeneral)
[23 Sep 2009 2:15]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/84228 3030 jack andrews 2009-09-23 Bug #47426: Parser.cpp won't parse "x=c:\windows" . now finds first of ':' or '=' for the split
[25 Sep 2009 9:56]
jack andrews
hi jon, [at least i guess i'm talking to you :) ] i don't know if this needs documenting, but pushing your way anyway. ta, jack.
[25 Sep 2009 11:27]
Jon Stephens
Documented bugfix in the NDB-7.0.8 changelog as follows: The NDB kernel's parser (ndb/src/common/util/Parser.cpp) did not interpret the backslash ("\") character correctly. Closed.
[30 Sep 2009 8:14]
Bugs System
Pushed into 5.1.37-ndb-7.0.9 (revid:jonas@mysql.com-20090930075942-1q6asjcp0gaeynmj) (version source revid:jack@sun.com-20090923021325-g0iixq1ssbl32my4) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[30 Sep 2009 8:15]
Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:jonas@mysql.com-20090930080049-1c8a8cio9qgvhq35) (version source revid:jonas@mysql.com-20090923044045-pskiy7h7aayo25ko) (merge vers: 5.1.35-ndb-7.1.0) (pib:11)