Skip to content

Commit

Permalink
Merge pull request #68 from pali/embedded
Browse files Browse the repository at this point in the history
Fix compilation of embedded mysql server
  • Loading branch information
mbeijen authored Oct 30, 2016
2 parents a16dfbf + e5c73bd commit 8bf3b8c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ perl:
- "5.24"
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libmysqlclient-dev
- sudo apt-get install -qq libmysqlclient-dev libmysqld-dev libwrap0-dev
- perlbrew install-cpanm -f
install:
- cpanm --quiet DBI Test::Pod Test::Deep Test::DistManifest Proc::ProcessTable
script: "export RELEASE_TESTING=1 && perl Makefile.PL && make disttest"
script: "export RELEASE_TESTING=1 && perl Makefile.PL && make disttest && perl Makefile.PL --force-embedded && make disttest"
16 changes: 11 additions & 5 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ my $TESTDB = "test";
our $opt = { "help" => \&Usage, };

{
local ($::test_host, $::test_port, $::test_user, $::test_socket, $::test_password, $::test_db);
eval { require "t/mysql.mtest"; 1; } and do {
local ($::test_host, $::test_port, $::test_user, $::test_socket, $::test_password, $::test_db, $::test_force_embedded);
eval { require "t/mysql.mtest"; 1; } || eval { require "../t/mysql.mtest"; 1; } and do {
$opt->{'testhost'} = $::test_host;
$opt->{'testport'} = $::test_port;
$opt->{'testuser'} = $::test_user;
$opt->{'testsocket'} = $::test_socket;
$opt->{'testpassword'} = $::test_password;
$opt->{'testdb'} = $::test_db;
$opt->{'force-embedded'} = $::test_force_embedded if $::test_force_embedded;
}
}

Expand Down Expand Up @@ -116,7 +117,11 @@ if (-f "mysqlEmb/Makefile.PL")
}

#Disable of building of dbd::mysqlEmb driver by default
$opt->{'embedded'}="" if !$opt->{'force-embedded'};
if (!$opt->{'force-embedded'})
{
$opt->{'embedded'} = '';
$source->{ldflags} = 'guessed';
}

if ($opt->{'embedded'})
{
Expand Down Expand Up @@ -222,6 +227,7 @@ my $fileName = $@ ?
"\$::test_dsn .= \";mysql_socket=\$::test_socket\" if \$::test_socket;\n" .
"\$::test_dsn .= \":\$::test_host\" if \$::test_host;\n" .
"\$::test_dsn .= \":\$::test_port\" if \$::test_port;\n".
"\$::test_force_embedded = \$opt->{'force-embedded'} if \$opt->{'force-embedded'};\n" .
$dsn .
"} 1;\n")) &&
close(FILE)) || die "Failed to create $fileName: $!";
Expand Down Expand Up @@ -276,7 +282,7 @@ if ($opt->{'embedded'})
't/mysql.mtest' => { filename => 'mysqlEmb/t/mysqlEmb.mtest',
makedir => 'mysqlEmb/t',
replace => { 'DBI:mysql'=> 'DBI:mysqlEmb',
'test_db";' => 'test_db;mysql_embedded_options=--datadir=./t,--skip-innodb,--skip-bdb";'
'test_db";' => 'test_db;mysql_embedded_options=--datadir=./t,--skip-innodb";'
}
},
't/lib.pl' => { filename => 'mysqlEmb/t/lib.pl',
Expand Down Expand Up @@ -545,7 +551,7 @@ sub Configure {

# First try to get options values from mysql_config
my @mysql_config_options = qw(
cflags include libs libs_r plugindir socket port version libmysqld-libs
cflags include libs libs_r plugindir socket port version libmysqld-libs embedded
);
if ( grep {$_ eq $param} @mysql_config_options ) {
my $command = $opt->{'mysql_config'} . " --$param";
Expand Down
13 changes: 7 additions & 6 deletions dbdimp.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,14 @@ int free_embedded_options(char ** options_list, int options_count)
Print out embedded option settings
*/
int print_embedded_options(char ** options_list, int options_count)
int print_embedded_options(PerlIO *stream, char ** options_list, int options_count)
{
int i;

for (i=0; i<options_count; i++)
{
if (options_list[i])
PerlIO_printf(DBILOGFP,
PerlIO_printf(stream,
"Embedded server, parameter[%d]=%s\n",
i, options_list[i]);
}
Expand All @@ -471,7 +471,8 @@ int print_embedded_options(char ** options_list, int options_count)
/*
*/
char **fill_out_embedded_options(char *options,
char **fill_out_embedded_options(PerlIO *stream,
char *options,
int options_type,
int slen, int cnt)
{
Expand All @@ -482,7 +483,7 @@ char **fill_out_embedded_options(char *options,

if (!(options_list= (char **) calloc(cnt, sizeof(char *))))
{
PerlIO_printf(DBILOGFP,
PerlIO_printf(stream,
"Initialize embedded server. Out of memory \n");
return NULL;
}
Expand Down Expand Up @@ -1602,7 +1603,7 @@ MYSQL *mysql_dr_connect(
if ((server_groups_cnt=count_embedded_options(options)))
{
/* number of server_groups always server_groups+1 */
server_groups=fill_out_embedded_options(options, 0,
server_groups=fill_out_embedded_options(DBIc_LOGPIO(imp_xxh), options, 0,
(int)lna, ++server_groups_cnt);
if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
{
Expand All @@ -1622,7 +1623,7 @@ MYSQL *mysql_dr_connect(
if ((server_args_cnt=count_embedded_options(options)))
{
/* number of server_options always server_options+1 */
server_args=fill_out_embedded_options(options, 1, (int)lna, ++server_args_cnt);
server_args=fill_out_embedded_options(DBIc_LOGPIO(imp_xxh), options, 1, (int)lna, ++server_args_cnt);
if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
{
PerlIO_printf(DBIc_LOGPIO(imp_xxh), "Server options passed to embedded server:\n");
Expand Down
2 changes: 1 addition & 1 deletion dbdimp.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ int mysql_st_next_results(SV*, imp_sth_t*);

#if defined(DBD_MYSQL_EMBEDDED)
int count_embedded_options(char *);
char ** fill_out_embedded_options(char *, int , int , int );
char ** fill_out_embedded_options(PerlIO *, char *, int , int , int);
int free_embedded_options(char **, int);
/* We have to define dbd_discon_all method for mysqlEmb driver at least
to be able to stop embedded server properly */
Expand Down

0 comments on commit 8bf3b8c

Please sign in to comment.