From 0886248b0d670944324feb94c2714d92cf02756b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 19 Jul 2017 18:06:43 +0200 Subject: [PATCH 1/3] Fix compilation with versions not defining MYSQL_SERVER_PUBLIC_KEY This was apparently added in 5.6.6, so put a guard around the code using it checking for the corresponding MYSQL_VERSION_ID. See https://bugs.mysql.com/bug.php?id=74706 --- driver/connect.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/driver/connect.c b/driver/connect.c index c5ef3150..1dd033f4 100644 --- a/driver/connect.c +++ b/driver/connect.c @@ -245,12 +245,14 @@ SQLRETURN myodbc_do_connect(DBC *dbc, DataSource *ds) mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (const char *)&opt_ssl_verify_server_cert); +#if MYSQL_VERSION_ID >= 50660 if (ds->rsakey) { /* Read the public key on the client side */ mysql_options(mysql, MYSQL_SERVER_PUBLIC_KEY, ds_get_utf8attr(ds->rsakey, &ds->rsakey8)); } +#endif #if MYSQL_VERSION_ID >= 50710 { From 9cb5ae232d4148a73171503790bef954e5ea517c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 19 Jul 2017 18:07:27 +0200 Subject: [PATCH 2/3] Rename DBC::net_buffer_length field to avoid conflict The field can't have the same name as the macro with the same name defined in mysql.h (at least in MySQL 5.5), so rename it to fix compilation. --- driver/connect.c | 4 ++-- driver/cursor.c | 2 +- driver/driver.h | 2 +- driver/info.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/driver/connect.c b/driver/connect.c index 1dd033f4..1d3cb4fb 100644 --- a/driver/connect.c +++ b/driver/connect.c @@ -513,10 +513,10 @@ SQLRETURN myodbc_do_connect(DBC *dbc, DataSource *ds) } #if MYSQL_VERSION_ID >= 50709 - mysql_get_option(mysql, MYSQL_OPT_NET_BUFFER_LENGTH, &dbc->net_buffer_length); + mysql_get_option(mysql, MYSQL_OPT_NET_BUFFER_LENGTH, &dbc->net_buffer_len); #else // for older versions just use net_buffer_length() macro - dbc->net_buffer_length = net_buffer_length; + dbc->net_buffer_len = net_buffer_length; #endif return rc; diff --git a/driver/cursor.c b/driver/cursor.c index 1d35c2a8..56827c17 100644 --- a/driver/cursor.c +++ b/driver/cursor.c @@ -1465,7 +1465,7 @@ static SQLRETURN batch_insert( STMT *stmt, SQLULEN irow, DYNAMIC_STRING *ext_que We have a limited capacity to shove data across the wire, but we handle this by sending in multiple calls to exec_stmt_query() */ - if (ext_query->length + length >= (SQLULEN) stmt->dbc->net_buffer_length) + if (ext_query->length + length >= (SQLULEN) stmt->dbc->net_buffer_len) { break_insert= TRUE; break; diff --git a/driver/driver.h b/driver/driver.h index 1c6ac3fe..23f8c434 100644 --- a/driver/driver.h +++ b/driver/driver.h @@ -378,7 +378,7 @@ typedef struct tagDBC int txn_isolation; uint port; uint cursor_count; - ulong net_buffer_length; + ulong net_buffer_len; uint commit_flag; #ifdef THREAD myodbc_mutex_t lock; diff --git a/driver/info.c b/driver/info.c index 570e6398..0db24b67 100644 --- a/driver/info.c +++ b/driver/info.c @@ -587,7 +587,7 @@ MySQLGetInfo(SQLHDBC hdbc, SQLUSMALLINT fInfoType, MYINFO_SET_USHORT(0); case SQL_MAX_STATEMENT_LEN: - MYINFO_SET_ULONG(dbc->net_buffer_length); + MYINFO_SET_ULONG(dbc->net_buffer_len); case SQL_MAX_TABLE_NAME_LEN: MYINFO_SET_USHORT(NAME_LEN); From c922dc42e0d697993a0e97ee3a0334611678cf13 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 19 Jul 2017 18:19:10 +0200 Subject: [PATCH 3/3] Define my_stpmov() in our own code if not available in MySQL This fixes build with pre-5.7 MySQL versions after the changes of e11e67f38b266acb1ca6730dcac0eee8ebe825c0. --- util/stringutil.c | 8 ++++++++ util/stringutil.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/util/stringutil.c b/util/stringutil.c index 06864890..c659c8ef 100644 --- a/util/stringutil.c +++ b/util/stringutil.c @@ -983,3 +983,11 @@ SQLWCHAR *wchar_t_as_sqlwchar(wchar_t *from, SQLWCHAR *to, size_t len) return out; } } + +#if MYSQL_VERSION_ID < 50700 +char *my_stpmov(char *dst, const char *src) +{ + while ((*dst++ = *src++)) ; + return dst-1; +} +#endif diff --git a/util/stringutil.h b/util/stringutil.h index e7097ed3..93f97afe 100644 --- a/util/stringutil.h +++ b/util/stringutil.h @@ -120,6 +120,8 @@ SQLWCHAR *wchar_t_as_sqlwchar(wchar_t *from, SQLWCHAR *to, size_t len); char * myodbc_strlwr(char *target, size_t len); SQLCHAR* sqlwchar_as_utf8_simple(SQLWCHAR *s); +char *my_stpmov(char *dst, const char *src); + #ifdef __cplusplus } #endif