Skip to content

Commit ae6eb7a

Browse files
committed
MDEV-11088 Client plugins cannot be loaded by command line tools
in default installation. Added plugin-dir to the [client] section of the generated my.ini, so that installed services (MSI or mysql_install_db.exe) would be able to find plugin directory.
1 parent e4978d2 commit ae6eb7a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

sql/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ IF(WIN32)
387387
${CMAKE_CURRENT_BINARY_DIR}/mysql_bootstrap_sql.c
388388
COMPONENT Server
389389
)
390+
SET_TARGET_PROPERTIES(mysql_install_db PROPERTIES COMPILE_FLAGS -DINSTALL_PLUGINDIR=${INSTALL_PLUGINDIR})
390391
TARGET_LINK_LIBRARIES(mysql_install_db mysys)
391392

392393
ADD_LIBRARY(winservice STATIC winservice.c)

sql/mysql_install_db.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,20 @@ static void get_basedir(char *basedir, int size, const char *mysqld_path)
233233
}
234234
}
235235

236+
#define STR(s) _STR(s)
237+
#define _STR(s) #s
238+
239+
static char *get_plugindir()
240+
{
241+
static char plugin_dir[2*MAX_PATH];
242+
get_basedir(plugin_dir, sizeof(plugin_dir), mysqld_path);
243+
strcat(plugin_dir, "/" STR(INSTALL_PLUGINDIR));
244+
245+
if (access(plugin_dir, 0) == 0)
246+
return plugin_dir;
247+
248+
return NULL;
249+
}
236250

237251
/**
238252
Allocate and initialize command line for mysqld --bootstrap.
@@ -313,6 +327,10 @@ static int create_myini()
313327
fprintf(myini,"protocol=pipe\n");
314328
else if (opt_port)
315329
fprintf(myini,"port=%d\n",opt_port);
330+
331+
char *plugin_dir = get_plugindir();
332+
if (plugin_dir)
333+
fprintf(myini, "plugin-dir=%s\n", plugin_dir);
316334
fclose(myini);
317335
return 0;
318336
}

0 commit comments

Comments
 (0)