fix c_str error when connecting to MySQL

Former-commit-id: 6c7b477cac2330c169a076550553dbba7efd533e
pull/191/head
zhiru 2019-07-04 15:58:28 +08:00 committed by jinhai
parent 107d8efdf2
commit 1c441df72e
1 changed files with 7 additions and 7 deletions

View File

@ -144,14 +144,14 @@ 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));
@ -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();