提交 a4646734 编写于 作者: Z zhiru 提交者: jinhai

fix c_str error when connecting to MySQL


Former-commit-id: 055a1e26fb253783f9fdfcc0f6f8206ef29455dd
上级 42b2f8f3
...@@ -144,15 +144,15 @@ namespace meta { ...@@ -144,15 +144,15 @@ namespace meta {
if (dialect.find("mysql") == std::string::npos) { if (dialect.find("mysql") == std::string::npos) {
return Status::Error("URI's dialect is not MySQL"); return Status::Error("URI's dialect is not MySQL");
} }
const char* username = pieces_match[2].str().c_str(); std::string username = pieces_match[2].str();
const char* password = pieces_match[3].str().c_str(); std::string password = pieces_match[3].str();
const char* serverAddress = pieces_match[4].str().c_str(); std::string serverAddress = pieces_match[4].str();
unsigned int port = 0; unsigned int port = 0;
if (!pieces_match[5].str().empty()) { if (!pieces_match[5].str().empty()) {
port = std::stoi(pieces_match[5].str()); port = std::stoi(pieces_match[5].str());
} }
const char* dbName = pieces_match[6].str().c_str(); std::string dbName = pieces_match[6].str();
//std::cout << dbName << " " << serverAddress << " " << username << " " << password << " " << port << std::endl; // std::cout << dbName << " " << serverAddress << " " << username << " " << password << " " << port << std::endl;
// connectionPtr->set_option(new MultiStatementsOption(true)); // connectionPtr->set_option(new MultiStatementsOption(true));
// connectionPtr->set_option(new mysqlpp::ReconnectOption(true)); // connectionPtr->set_option(new mysqlpp::ReconnectOption(true));
int threadHint = std::thread::hardware_concurrency(); int threadHint = std::thread::hardware_concurrency();
...@@ -1753,8 +1753,8 @@ namespace meta { ...@@ -1753,8 +1753,8 @@ namespace meta {
Query cleanUpQuery = connectionPtr->query(); Query cleanUpQuery = connectionPtr->query();
cleanUpQuery << "SELECT table_name " << cleanUpQuery << "SELECT table_name " <<
"FROM information_schema.tables " << "FROM information_schema.tables " <<
"WHERE table_schema = " << quote << mysql_connection_pool_->getDB() << quote << " " << "WHERE table_schema = " << quote << mysql_connection_pool_->getDB() << " " <<
"AND table_name = " << quote << "TableFiles" << quote << ";"; "AND table_name = " << quote << "TableFiles" << ";";
ENGINE_LOG_DEBUG << "MySQLMetaImpl::CleanUp: " << cleanUpQuery.str(); ENGINE_LOG_DEBUG << "MySQLMetaImpl::CleanUp: " << cleanUpQuery.str();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册