Browse Source

Merge pull request #6383 from richardkchapman/mysql-port

HPCC-12136 Embedded MySQL has no means to specify port

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 10 years ago
parent
commit
ca6f50c0cf
1 changed files with 4 additions and 1 deletions
  1. 4 1
      plugins/mysql/mysqlembed.cpp

+ 4 - 1
plugins/mysql/mysqlembed.cpp

@@ -861,6 +861,7 @@ public:
         const char *user = "";
         const char *password = "";
         const char *database = "";
+        unsigned port = 0;
         StringArray opts;
         opts.appendList(options, ",");
         ForEachItemIn(idx, opts)
@@ -873,6 +874,8 @@ public:
                 val++;
                 if (stricmp(optName, "server")==0)
                     server = val;   // Note that lifetime of val is adequate for this to be safe
+                else if (stricmp(optName, "port")==0)
+                    port = atoi(val);
                 else if (stricmp(optName, "user")==0)
                     user = val;
                 else if (stricmp(optName, "password")==0)
@@ -882,7 +885,7 @@ public:
             }
         }
         conn.setown(new MySQLConnection(mysql_init(NULL)));
-        if (!mysql_real_connect(*conn, server, user, password, database, 0, NULL, 0))
+        if (!mysql_real_connect(*conn, server, user, password, database, port, NULL, 0))
         {
             VStringBuffer err("mysql: failed to connect (%s)", mysql_error(*conn));
             rtlFail(0, err.str());