--- sql/mysql/parser3mysql.C 2019/09/10 14:33:39 1.60 +++ sql/mysql/parser3mysql.C 2021/11/08 08:21:09 1.64 @@ -1,7 +1,7 @@ /** @file Parser MySQL driver. - Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2019 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) @@ -15,7 +15,7 @@ #include "pa_sql_driver.h" -volatile const char * IDENT_PARSER3MYSQL_C="$Id: parser3mysql.C,v 1.60 2019/09/10 14:33:39 moko Exp $" IDENT_PA_SQL_DRIVER_H; +volatile const char * IDENT_PARSER3MYSQL_C="$Id: parser3mysql.C,v 1.64 2021/11/08 08:21:09 moko Exp $" IDENT_PA_SQL_DRIVER_H; #define NO_CLIENT_LONG_LONG #include "mysql.h" @@ -24,7 +24,7 @@ volatile const char * IDENT_PARSER3MYSQL #define MAX_STRING 0x400 #define MAX_NUMBER 20 -#if _MSC_VER +#ifdef _MSC_VER # define snprintf _snprintf # define strcasecmp _stricmp #endif @@ -128,8 +128,7 @@ public: /// initialize driver by loading sql dynamic link library const char *initialize(char *dlopen_file_spec) { - return dlopen_file_spec? - dlink(dlopen_file_spec):"client library column is empty"; + return dlopen_file_spec ? dlink(dlopen_file_spec) : "client library column is empty"; } /** connect @@ -231,8 +230,8 @@ public: } if(charset){ - char statement[MAX_STRING+1]="SET NAMES "; - strncat(statement, charset, MAX_STRING); + char statement[MAX_STRING]; + snprintf(statement, MAX_STRING, "SET NAMES %s", charset); _exec(connection, statement); } @@ -334,7 +333,7 @@ public: MYSQL_RES *res=NULL; if(placeholders_count>0) - services._throw("bind variables not supported (yet)"); + services._throw("bind variables not supported yet"); bool transcode_needed=_transcode_required(connection); @@ -418,7 +417,11 @@ public: } if(transcode_needed) { +#ifdef _MSC_VER + bool* transcode_column = (bool*)services.malloc_atomic(column_count*sizeof(bool)); +#else bool transcode_column[column_count]; +#endif DO_FETCH_FIELDS( transcode_column[i] = is_column_transcode_required(field->type); // transcode column's name from ?ClientCharset to $request:charset @@ -430,11 +433,14 @@ public: if(transcode_column[i]) services.transcode(str, length, str, length, connection.client_charset, services.request_charset()); ) +#ifdef _MSC_VER + services.realloc(transcode_column,0); +#endif } else { // without transcoding - DO_FETCH_FIELDS() + DO_FETCH_FIELDS({}) CHECK(handlers.before_rows(sql_error)); - DO_FETCH_ROWS() + DO_FETCH_ROWS({}) } mysql_free_result(res); @@ -510,14 +516,19 @@ private: // mysql client library funcs private: // mysql client library funcs linking - const char *dlink(const char *dlopen_file_spec) { + const char *dlink(char *dlopen_file_spec) { if(lt_dlinit()){ if(const char* result=lt_dlerror()) return result; return "can not prepare to dynamic loading"; } - lt_dlhandle handle=lt_dlopen(dlopen_file_spec); + lt_dlhandle handle; + do { + char *next=lsplit(dlopen_file_spec, ','); + handle=lt_dlopen(dlopen_file_spec); + dlopen_file_spec=next; + } while (!handle && dlopen_file_spec); if(!handle){ if(const char* result=lt_dlerror())