Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions lib/WeBWorK/DB/Schema/NewSQL/Std.pm
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,25 @@ sub _get_db_info {
my $password = $self->{params}{password};

my %dsn;
if ( $dsn =~ m/^dbi:mariadb:/i ) {
if ($dsn =~ m/^dbi:mariadb:/i || $dsn =~ m/^dbi:mysql:/i) {
# Expect DBI:MariaDB:database=webwork;host=db;port=3306
my ($dbi,$dbtype,$temp1) = split(':',$dsn);
( $dsn{database}, $dsn{host}, $dsn{port} ) = split(';',$temp1);
$dsn{database} =~ s/database=//;
$dsn{host} =~ s/host=// if ( defined $dsn{host} );
$dsn{port} =~ s/port=// if ( defined $dsn{port} );
} elsif ( $dsn =~ m/^dbi:mysql:/i ) {
# This code works for DBD::mysql
# this is an internal function which we probably shouldn't be using here
# but it's quick and gets us what we want (FIXME what about sockets, etc?)
DBD::mysql->_OdbcParse($dsn, \%dsn, ['database', 'host', 'port']);
# or DBI:mysql:database=webwork;host=db;port=3306
# The host and port are optional.
my ($dbi, $dbtype, $dsn_opts) = split(':', $dsn);
while (length($dsn_opts)) {
if ($dsn_opts =~ /^([^=]*)=([^;]*);(.*)$/) {
$dsn{$1} = $2;
$dsn_opts = $3;
} else {
my ($var, $val) = $dsn_opts =~ /^([^=]*)=([^;]*)$/;
$dsn{$var} = $val;
$dsn_opts = '';
}
}
} else {
die "Can't call dump_table or restore_table on a table with a non-MySQL/MariaDB source";
}

die "no database specified in DSN!" unless defined $dsn{database};

my $mysqldump = $self->{params}{mysqldump_path};
Expand Down
27 changes: 15 additions & 12 deletions lib/WeBWorK/Utils/CourseManagement/sql_single.pm
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,21 @@ sub _get_db_info {
my $password = $ce->{database_password};

my %dsn;
if ( $dsn =~ s/^dbi:mariadb://i ) {
my ($dbi,$dbtype,$temp1) = split(':',$dsn);
( $dsn{database}, $dsn{host}, $dsn{port} ) = split(';',$db);
$dsn{database} =~ s/database=//;
$dsn{host} =~ s/host=// if ( defined $dsn{host} );
$dsn{port} =~ s/port=// if ( defined $dsn{port} );
} elsif ( $dsn =~ s/^dbi:mysql://i ) {
# This code works for DBD::mysql
# this is an internal function which we probably shouldn't be using here
# but it's quick and gets us what we want (FIXME what about sockets, etc?)
runtime_use "DBD::mysql";
DBD::mysql->_OdbcParse($dsn, \%dsn, ['database', 'host', 'port']);
if ($dsn =~ m/^dbi:mariadb:/i || $dsn =~ m/^dbi:mysql:/i) {
# Expect DBI:MariaDB:database=webwork;host=db;port=3306
# or DBI:mysql:database=webwork;host=db;port=3306
# The host and port are optional.
my ($dbi, $dbtype, $dsn_opts) = split(':', $dsn);
while (length($dsn_opts)) {
if ($dsn_opts =~ /^([^=]*)=([^;]*);(.*)$/) {
$dsn{$1} = $2;
$dsn_opts = $3;
} else {
my ($var, $val) = $dsn_opts =~ /^([^=]*)=([^;]*)$/;
$dsn{$var} = $val;
$dsn_opts = '';
}
}
} else {
die "Can't call dump_table or restore_table on a table with a non-MySQL/MariaDB source";
}
Expand Down