Skip to content

Commit

Permalink
Windows : if plugin cannot be loaded, provide a full path of the library
Browse files Browse the repository at this point in the history
in the error message, to simplify troubleshooting by users.

Elswhere, dlerror() already seems to include full library path already.
  • Loading branch information
vaintroub committed Mar 26, 2018
1 parent 668757a commit 6e1dd7a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions libmariadb/ma_client_plugin.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
{
const char *errmsg;
#ifdef _WIN32
char errbuf[255];
char errbuf[1024];
#endif
char dlpath[FN_REFLEN+1];
void *sym, *dlhandle;
Expand Down Expand Up @@ -392,11 +392,20 @@ mysql_load_plugin_v(MYSQL *mysql, const char *name, int type,
if (!(dlhandle= dlopen((const char *)dlpath, RTLD_NOW)))
{
#ifdef _WIN32
char winmsg[255];
size_t len;
winmsg[0] = 0;
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&errbuf, 255, NULL);
winmsg, 255, NULL);
len= strlen(winmsg);
while (len > 0 && (winmsg[len - 1] == '\n' || winmsg[len - 1] == '\r'))
len--;
if (len)
winmsg[len] = 0;
snprintf(errbuf, sizeof(errbuf), "%s Library path is '%s'", winmsg, dlpath);
errmsg= errbuf;
#else
errmsg= dlerror();
Expand Down

0 comments on commit 6e1dd7a

Please sign in to comment.