mysql_libraray_init failed due to invalid datadir setting. Fixed this by setting the working directory/data as data directory.
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
|
||||||
#include "../../utils/skygw_utils.h"
|
#include "../../utils/skygw_utils.h"
|
||||||
@ -7,6 +9,8 @@
|
|||||||
//#include "skygw_types.h"
|
//#include "skygw_types.h"
|
||||||
#include "../query_classifier.h"
|
#include "../query_classifier.h"
|
||||||
|
|
||||||
|
static char datadir[1024] = "";
|
||||||
|
static char mysqldir[1024] = "";
|
||||||
|
|
||||||
static char* server_options[] = {
|
static char* server_options[] = {
|
||||||
"SkySQL Gateway",
|
"SkySQL Gateway",
|
||||||
@ -122,6 +126,8 @@ int main(int argc, char** argv)
|
|||||||
int nsucc = 0;
|
int nsucc = 0;
|
||||||
int nfail = 0;
|
int nfail = 0;
|
||||||
MYSQL* mysql;
|
MYSQL* mysql;
|
||||||
|
char* workingdir;
|
||||||
|
char ddoption[1024];
|
||||||
|
|
||||||
ss_dfprintf(stderr, ">> testmain\n");
|
ss_dfprintf(stderr, ">> testmain\n");
|
||||||
c = slist_init();
|
c = slist_init();
|
||||||
@ -321,6 +327,36 @@ int main(int argc, char** argv)
|
|||||||
/**
|
/**
|
||||||
* Init libmysqld.
|
* Init libmysqld.
|
||||||
*/
|
*/
|
||||||
|
workingdir = getenv("PWD");
|
||||||
|
|
||||||
|
if (workingdir == NULL) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Failed to resolve the working directory, $PWD is not "
|
||||||
|
"set.\n");
|
||||||
|
goto return_without_server;
|
||||||
|
} else if (access(workingdir, R_OK) != 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Failed to access the working directory due %d, %s\n",
|
||||||
|
errno,
|
||||||
|
strerror(errno));
|
||||||
|
goto return_without_server;
|
||||||
|
} else {
|
||||||
|
char** so = server_options;
|
||||||
|
snprintf(datadir, 1023, "%s/data", workingdir);
|
||||||
|
mkdir(datadir, 0777);
|
||||||
|
snprintf(ddoption, 1023, "--datadir=%s", datadir);
|
||||||
|
|
||||||
|
while (strncmp(*so++, "--datadir=", 10) != 0) ;
|
||||||
|
|
||||||
|
if (*so == NULL) {
|
||||||
|
fprintf(stderr, "Failed to find datadir option.\n");
|
||||||
|
goto return_without_server;
|
||||||
|
}
|
||||||
|
*so = ddoption;
|
||||||
|
|
||||||
|
snprintf(mysqldir, 1023, "%s/mysql", workingdir);
|
||||||
|
setenv("MYSQL_HOME", mysqldir, 1);
|
||||||
|
}
|
||||||
failp = mysql_library_init(num_elements, server_options, server_groups);
|
failp = mysql_library_init(num_elements, server_options, server_groups);
|
||||||
|
|
||||||
if (failp) {
|
if (failp) {
|
||||||
|
Reference in New Issue
Block a user