[fdo-commits] r624 - in branches/3.2.x/Providers/GenericRdbms: Nls
Src/MySQL/Driver
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Fri Jan 12 17:12:00 EST 2007
Author: jacklee
Date: 2007-01-12 17:11:59 -0500 (Fri, 12 Jan 2007)
New Revision: 624
Modified:
branches/3.2.x/Providers/GenericRdbms/Nls/fdordbmsmsg.mc
branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/connect.c
branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/nls.h
Log:
Handle the case when the host is invalid
Modified: branches/3.2.x/Providers/GenericRdbms/Nls/fdordbmsmsg.mc
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Nls/fdordbmsmsg.mc 2007-01-12 15:46:57 UTC (rev 623)
+++ branches/3.2.x/Providers/GenericRdbms/Nls/fdordbmsmsg.mc 2007-01-12 22:11:59 UTC (rev 624)
@@ -1800,3 +1800,8 @@
Language=English
Non-feature metaclass
.
+MessageId=2730
+SymbolicName=FDORDBMS_505
+Language=English
+Unknown MySQL server host '%1$ls'
+.
Modified: branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/connect.c
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/connect.c 2007-01-12 15:46:57 UTC (rev 623)
+++ branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/connect.c 2007-01-12 22:11:59 UTC (rev 624)
@@ -17,7 +17,13 @@
*/
#include "stdafx.h"
+#include <errmsg.h>
+#include "nls.h"
+#include <Inc/Nls/fdordbms_msg.h>
+#include <Common/Std.h>
+#include <Common/StringP.h>
+
#include "connect.h"
#include "Inc/ut.h"
#include "run_sql.h"
@@ -101,7 +107,17 @@
handle = mysql_real_connect (mysql, host, user, pswd, db, port, NULL, 0);
if ((MYSQL *)NULL == handle) {
// mysql_get_msg() will get this
- swprintf(context->mysql_last_err_msg, RDBI_MSG_SIZE, L"%hs", mysql_error(mysql));
+ // Handle the case when the host is not found.
+ // The language setting is only on the server. If the host is invalid, the message
+ // returned by mysql_error is in English.
+ if (mysql_errno(mysql) == CR_UNKNOWN_HOST)
+ {
+ swprintf(context->mysql_last_err_msg, RDBI_MSG_SIZE, mysql_nls_msg_get(FDORDBMS_505, "Unknown MySQL server host '%1$ls'", (FdoString *) FdoStringP(host)));
+ }
+ else
+ {
+ swprintf(context->mysql_last_err_msg, RDBI_MSG_SIZE, L"%hs", mysql_error(mysql));
+ }
context->mysql_last_err_msg[RDBI_MSG_SIZE - 1] = 0;
ret = RDBI_GENERIC_ERROR;
}
Modified: branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/nls.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/nls.h 2007-01-12 15:46:57 UTC (rev 623)
+++ branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/nls.h 2007-01-12 22:11:59 UTC (rev 624)
@@ -29,4 +29,6 @@
// Constructs a message indicating that the connected MySQL database is too old for FDO
const wchar_t* mysql_nls_server_version( unsigned long client_version );
+const wchar_t* mysql_nls_msg_get(int msg_num, char* default_msg, ...);
+
#endif // MYSQL_NLS_H
More information about the fdo-commits
mailing list