[fdo-commits] r713 -
branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Mon Jan 29 15:35:05 EST 2007
Author: romicadascalescu
Date: 2007-01-29 15:35:04 -0500 (Mon, 29 Jan 2007)
New Revision: 713
Modified:
branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/connect.c
branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/stdafx.h
branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/xlt_status.c
Log:
Fixed MySQL: Raise FDO exception connection is made to an old MySql version (at connection time).
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-29 20:25:50 UTC (rev 712)
+++ branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/connect.c 2007-01-29 20:35:04 UTC (rev 713)
@@ -57,6 +57,8 @@
MYSQL *handle;
int rows_processed;
int ret;
+ unsigned long server_client_version = 0;
+ const wchar_t* server_client_msg = NULL;
ret = mysql_xlt_status(context, MYSQL_SUCCESS, (MYSQL*) NULL, (MYSQL_STMT*) NULL);
@@ -123,32 +125,49 @@
}
else
{
- if (context->mysql_current_connect == -1)
- {
- context->mysql_connect_count++;
- context->mysql_current_connect = index;
- context->mysql_connections[index] = handle;
+ server_client_version = mysql_get_client_version();
+ if ( server_client_version < MIN_CLIENT_VER )
+ server_client_msg = mysql_nls_client_version( server_client_version );
+
+ server_client_version = mysql_get_server_version( handle );
+ if ( server_client_version < MIN_SERVER_VER )
+ server_client_msg = mysql_nls_server_version( server_client_version );
- *connect_id = index;
- // The following allows RDBMS object names to be double quote
- // delimited in SQL statements, thus allowing queries on tables
- // and columns with special characters in their names.
- ret = mysql_run_sql( context, "set sql_mode='ANSI_QUOTES'", false, &rows_processed );
- if ( ret == 0 )
- ret = set_characterset( context, false );
- }
- else if (context->mysql_current_connect2 == -1)
- {
- context->mysql_connect_count++;
- context->mysql_current_connect2 = index;
- context->mysql_connections[index] = handle;
- // See note 10 lines above.
- ret = mysql_run_sql( context, "set sql_mode='ANSI_QUOTES'", true, &rows_processed );
- if ( ret == 0 )
- ret = set_characterset( context, true );
- break;
- }
+ if ( server_client_msg != NULL)
+ {
+ swprintf(context->mysql_last_err_msg, RDBI_MSG_SIZE, L"%ls", server_client_msg);
+ mysql_close (handle);
+ context->mysql_last_err_msg[RDBI_MSG_SIZE - 1] = 0;
+ ret = RDBI_GENERIC_ERROR;
+ }
+ else
+ {
+ if (context->mysql_current_connect == -1)
+ {
+ context->mysql_connect_count++;
+ context->mysql_current_connect = index;
+ context->mysql_connections[index] = handle;
+ *connect_id = index;
+ // The following allows RDBMS object names to be double quote
+ // delimited in SQL statements, thus allowing queries on tables
+ // and columns with special characters in their names.
+ ret = mysql_run_sql( context, "set sql_mode='ANSI_QUOTES'", false, &rows_processed );
+ if ( ret == 0 )
+ ret = set_characterset( context, false );
+ }
+ else if (context->mysql_current_connect2 == -1)
+ {
+ context->mysql_connect_count++;
+ context->mysql_current_connect2 = index;
+ context->mysql_connections[index] = handle;
+ // See note 10 lines above.
+ ret = mysql_run_sql( context, "set sql_mode='ANSI_QUOTES'", true, &rows_processed );
+ if ( ret == 0 )
+ ret = set_characterset( context, true );
+ break;
+ }
+ }
}
}
}
Modified: branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/stdafx.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/stdafx.h 2007-01-29 20:25:50 UTC (rev 712)
+++ branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/stdafx.h 2007-01-29 20:35:04 UTC (rev 713)
@@ -45,3 +45,8 @@
// Helper macro that determines the number of elements in a statically-sized array
// (this doesn't work for dynamically-sized arrays)
#define ELEMENTS(x) (sizeof(x)/sizeof(x[0]))
+
+// defines minimum client version accepted
+#define MIN_CLIENT_VER 50000
+// defines minimum server version accepted
+#define MIN_SERVER_VER 50022
Modified: branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/xlt_status.c
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/xlt_status.c 2007-01-29 20:25:50 UTC (rev 712)
+++ branches/3.2.x/Providers/GenericRdbms/Src/MySQL/Driver/xlt_status.c 2007-01-29 20:35:04 UTC (rev 713)
@@ -142,7 +142,7 @@
// cryptic. Therefore, prepend more explanatory info when one of the other
// is too old to work with the MySQL Provider.
- if ( client_version < 50000 ) {
+ if ( client_version < MIN_CLIENT_VER ) {
// Pre-version 5 clients can't handle some version 5 data types used in the
// information_schema, so MySQL provider can't work with them.
const wchar_t* client_msg = mysql_nls_client_version( client_version );
@@ -152,7 +152,7 @@
if ( mysql ) {
unsigned long server_version = mysql_get_server_version( mysql );
- if ( server_version < 50022 ) {
+ if ( server_version < MIN_SERVER_VER ) {
// Also, various errors can occur when database has too old a version.
const wchar_t* server_msg = mysql_nls_server_version( server_version );
cat_msg( err_msg, server_msg, err_msg_left );
More information about the fdo-commits
mailing list