#include "mysql.h" #include #include int main(int argc, char *argv[]) { if (argc != 2) { printf( "please pass in the --basedir for the embedded server \n"); return 1; } int number_of_server_args; MYSQL* mysql; char* server_args[] = { "this_program", // this string is not used "--skip-innodb", "--datadir=/tmp/data", "--skip-networking", "--tmpdir=/tmp/mysql_tmpdir_WnrlT8", argv[1]}; // "--basedir=/users/hfisk/csc/47074/mysql-5.5.4-m3-linux2.6-x86_64"}; number_of_server_args = sizeof(server_args) / sizeof(char*); char* server_groups[] = {"embedded", "server", "this_program_SERVER", (char*)NULL }; /////////// First connect mkdir("/tmp/mysql_tmpdir_WnrlT8",S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); mysql_library_init(number_of_server_args, server_args, server_groups); mysql = mysql_init(NULL); if ((MYSQL*)NULL == mysql) { throw "Failed in mysql_init."; } if (! mysql_real_connect(mysql, NULL,NULL,NULL, NULL, 0, NULL, CLIENT_MULTI_STATEMENTS)) { throw mysql_error(mysql); } /////////////First disconnect mysql_close(mysql); mysql = NULL; mysql_library_end(); rmdir("/tmp/mysql_tmpdir_WnrlT8"); ///////////Second connect //////Crash in 5.5.4 mkdir("/tmp/mysql_tmpdir_WnrlT8",S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); mysql_library_init(number_of_server_args, server_args, server_groups); //////continue run in 5.0.22 mysql = mysql_init(NULL); if (! mysql_real_connect(mysql, NULL,NULL,NULL, NULL, 0, NULL, CLIENT_MULTI_STATEMENTS)) { throw mysql_error(mysql); } printf("Completed successfully \n"); return 0; }