]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/store/mysql/mysql_store.cpp
Enable some more libs.
[stg.git] / projects / stargazer / plugins / store / mysql / mysql_store.cpp
index 3ad79b3019e8c4279d196aacbc6482297840fbaf..a4ee430930b95b9b4a9602ea3747edcb7ce12252 100644 (file)
@@ -110,6 +110,7 @@ extern "C" STG::Store* GetStore()
 //-----------------------------------------------------------------------------
 MYSQL_STORE_SETTINGS::MYSQL_STORE_SETTINGS()
     : settings(NULL)
+    , dbPort(0)
 {
 }
 //-----------------------------------------------------------------------------
@@ -146,13 +147,25 @@ if (ParseParam(s.moduleParams, "server", dbHost) < 0 &&
     ParseParam(s.moduleParams, "dbhost", dbHost) < 0)
     return -1;
 
+// not required
+std::string dbPortAsString;
+if (ParseParam(s.moduleParams, "port", dbPortAsString) == 0 ||
+    ParseParam(s.moduleParams, "dbport", dbPortAsString) == 0)
+{
+    if (GetInt<unsigned int>(dbPortAsString, &dbPort, 0) != 0)
+    {
+        errorStr = "Can't parse db port from string: \"" + dbPortAsString + "\"\n";
+        return -1;
+    }
+}
+
 return 0;
 }
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 MYSQL_STORE::MYSQL_STORE()
-    : version("mysql_store v.0.67"),
+    : version("mysql_store v.0.68"),
       schemaVersion(0),
       logger(STG::PluginLogger::get("store_mysql"))
 {
@@ -195,7 +208,7 @@ else
     MYSQL * sock;
     if (!(sock = mysql_real_connect(&mysql,storeSettings.GetDBHost().c_str(),
             storeSettings.GetDBUser().c_str(),storeSettings.GetDBPassword().c_str(),
-            0,0,NULL,0)))
+            0,storeSettings.GetDBPort(),NULL,0)))
         {
             errorStr = "Couldn't connect to mysql engine! With error:\n";
             errorStr += mysql_error(&mysql);
@@ -252,7 +265,7 @@ if (!(result=mysql_list_tables(sock,str.c_str() )))
     errorStr = "Couldn't get tables list With error:\n";
     errorStr += mysql_error(sock);
     mysql_close(sock);
-    return -1;
+    return false;
 }
 
 my_ulonglong num_rows =  mysql_num_rows(result);
@@ -2136,7 +2149,7 @@ MYSQL *  MYSQL_STORE::MysqlConnect() const {
     }
     if (!(sock = mysql_real_connect(sock,storeSettings.GetDBHost().c_str(),
             storeSettings.GetDBUser().c_str(),storeSettings.GetDBPassword().c_str(),
-            0,0,NULL,0)))
+            0,storeSettings.GetDBPort(),NULL,0)))
         {
             errorStr = "Couldn't connect to mysql engine! With error:\n";
             errorStr += mysql_error(sock);