diff --git a/.travis.yml b/.travis.yml index 679fb422..feeaf7d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -125,8 +125,8 @@ matrix: # - perl: "5.20" # env: DB=MariaDB VERSION=10.2.5 # mariadb_config bug: https://jira.mariadb.org/browse/MDEV-15820 -# - perl: "5.20" -# env: DB=MariaDB VERSION=10.3.9 + - perl: "5.20" + env: DB=MariaDB VERSION=10.3.11 - perl: "5.20" env: CONC_DB=MySQL CONC_VERSION=6.0.0-beta - perl: "5.20" @@ -261,7 +261,17 @@ before_script: export DBD_MYSQL_CONFIG="skip" ; fi ; elif [ -n "$DB" ]; then - export DBD_MYSQL_CONFIG="$SANDBOX_HOME/msb/my sql_config" ; + if [ "$DB" = "MariaDB" ]; then + mariadb_config="$SANDBOX_HOME/binary/${VERSION}/bin/mariadb_config" ; + if [ -e $mariadb_config ]; then + export DBD_MYSQL_CONFIG=$mariadb_config; + else + echo "$mariadb_config does not exist, falling back to my sql_config" ; + export DBD_MYSQL_CONFIG="$SANDBOX_HOME/msb/my sql_config" ; + fi + else + export DBD_MYSQL_CONFIG="$SANDBOX_HOME/msb/my sql_config" ; + fi else export DBD_MYSQL_FORCE_EMBEDDED=1 ; fi diff --git a/Makefile.PL b/Makefile.PL index 634811f1..a1b38f6e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -617,10 +617,11 @@ sub Configure { $str =~ s/\-L\"(.*?)\"/-L$1/sg; # Separate libs from ldflags + # Ignore static libs like libgnutls.a as reported by MariaDB's mysql_config if ($param eq 'libs') { my (@libs, @ldflags); for (split ' ', $str) { - if (/^-[Ll]/ || /^[^\-]/) { push @libs, $_ } + if (/^-[Ll]/ || /^[^\-]/) { push @libs, $_ unless /\.a$/ } else { push @ldflags, $_ } } $str = "@libs"; @@ -628,6 +629,13 @@ sub Configure { $source->{ldflags} = "mysql_config"; } + if ($command =~ /10.3/) { + # MariaDB's mysql_config/mariadb_config reports the compile time + # locations, not the install location. This results in issues for + # dbdeployer etc. where these are not the same. + my $installdir = substr(dirname($opt->{'mysql_config'}), 1, -4); + $str =~ s#usr/local/mysql#$installdir#g; + } $opt->{$param} = $str; $source->{$param} = "mysql_config"; return; diff --git a/dbdimp.c b/dbdimp.c index b0399d94..6e1c6a19 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -4055,7 +4055,12 @@ int dbd_describe(SV* sth, imp_sth_t* imp_sth) break; default: +#if MYSQL_VERSION_ID > 100300 + // https://jira.mariadb.org/browse/MDEV-18143 + buffer->buffer_length= fields[i].max_length ? fields[i].max_length : 2; +#else buffer->buffer_length= fields[i].max_length ? fields[i].max_length : 1; +#endif Newz(908, fbh->data, buffer->buffer_length, char); buffer->buffer= (char *) fbh->data; } @@ -5313,6 +5318,16 @@ int mysql_db_reconnect(SV* h) else imp_dbh= (imp_dbh_t*) imp_xxh; + /* reconnect a closed connection, used in do() for implicit reconnect */ + if (!DBIc_has(imp_dbh, DBIcf_ACTIVE) && DBIc_has(imp_dbh, DBIcf_AutoCommit)) { + if (my_login(aTHX_ h, imp_dbh)) { + DBIc_ACTIVE_on(imp_dbh); + DBIc_set(imp_dbh, DBIcf_AutoCommit, TRUE); + return TRUE; + } + return FALSE; + } + if (mysql_errno(imp_dbh->pmysql) != CR_SERVER_GONE_ERROR && mysql_errno(imp_dbh->pmysql) != CR_SERVER_LOST) /* Other error */ diff --git a/mysql.xs b/mysql.xs index 861d7911..72e37f5b 100644 --- a/mysql.xs +++ b/mysql.xs @@ -272,6 +272,9 @@ do(dbh, statement, attr=Nullsv, ...) MYSQL_BIND *bind= NULL; #endif ASYNC_CHECK_XS(dbh); + if ((!DBIc_has(imp_dbh, DBIcf_ACTIVE)) && + (!mysql_db_reconnect(dbh))) + XSRETURN_UNDEF; #if MYSQL_VERSION_ID >= MULTIPLE_RESULT_SET_VERSION while (mysql_next_result(imp_dbh->pmysql)==0) { diff --git a/t/15reconnect.t b/t/15reconnect.t index c470a1a3..78dca704 100644 --- a/t/15reconnect.t +++ b/t/15reconnect.t @@ -16,7 +16,7 @@ eval {$dbh = DBI->connect($test_dsn, $test_user, $test_password, if ($@) { plan skip_all => "no database connection"; } -plan tests => 8 * 2; +plan tests => 13 * 2; for my $mysql_server_prepare (0, 1) { $dbh= DBI->connect("$test_dsn;mysql_server_prepare=$mysql_server_prepare;mysql_server_prepare_disable_fallback=1", $test_user, $test_password, @@ -38,5 +38,13 @@ ok($dbh->do("SELECT 1"), "implicitly reconnecting handle with 'do'"); ok($dbh->{Active}, "checking for reactivated handle"); -$dbh->disconnect(); +ok(!($dbh->{AutoCommit} = 0), "disabling autocommit"); + +ok($dbh->disconnect(), "disconnecting active handle"); + +ok(!$dbh->{Active}, "checking for inactive handle"); + +ok(!$dbh->do("SELECT 1"), "implicitly reconnecting handle with 'do'"); + +ok(!$dbh->{Active}, "checking for reactivated handle"); } diff --git a/t/57trackgtid.t b/t/57trackgtid.t index 8b7de243..5304148e 100644 --- a/t/57trackgtid.t +++ b/t/57trackgtid.t @@ -17,6 +17,10 @@ if ($@) { "no database connection"; } +if ($dbh->{mysql_serverversion} > 100000) { + plan skip_all => "GTID tracking is not available on MariaDB"; +} + if ($dbh->{mysql_serverversion} < 50000) { plan skip_all => "You must have MySQL version 5.0.0 and greater for this test to run"; }