[Rt-commit] rt branch, 4.2/mysql-database-names, created. rt-4.2.9-61-g4cf6c91
Alex Vandiver
alexmv at bestpractical.com
Wed Dec 31 13:49:08 EST 2014
The branch, 4.2/mysql-database-names has been created
at 4cf6c915e218ce90f8c32fdb09a9f8536be50551 (commit)
- Log -----------------------------------------------------------------
commit 4cf6c915e218ce90f8c32fdb09a9f8536be50551
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Dec 31 02:11:00 2014 -0500
Support arbitrary database names
Fixes: I#7568
diff --git a/configure.ac b/configure.ac
index 26fb8e9..1bcf2ba 100755
--- a/configure.ac
+++ b/configure.ac
@@ -231,16 +231,6 @@ AC_MSG_CHECKING([if database name is set])
[ AC_MSG_ERROR([no. database name is not set]) ]
)
-AS_IF([ test "$DB_TYPE" = "mysql" ],
- [ AC_MSG_CHECKING([if database name is valid])
- AS_IF([ echo $DB_DATABASE | $PERL -e 'exit(1) if <> =~ /-/'],
- [ AC_MSG_RESULT([yes]) ],
- [ AC_MSG_ERROR([no. database name ($DB_DATABASE) contains '-' which is not valid for mysql]) ]
- )
- ]
- )
-
-
dnl Dependencies for testing and developing RT
AC_ARG_WITH(developer,[],RT_DEVELOPER=$withval,RT_DEVELOPER="0")
AC_ARG_ENABLE(developer,
diff --git a/etc/acl.mysql b/etc/acl.mysql
index 7e56e97..26e27fb 100644
--- a/etc/acl.mysql
+++ b/etc/acl.mysql
@@ -12,7 +12,7 @@ sub acl {
RT->Logger->warn("DatabaseUser is root. Skipping...");
return;
}
- $db_name =~ s/([_%])/\\$1/g;
+ $db_name =~ s/([_%\\])/\\$1/g;
return (
"GRANT SELECT,INSERT,CREATE,INDEX,UPDATE,DELETE
ON `$db_name`.*
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 29802ad..673c772 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -365,7 +365,7 @@ sub CreateDatabase {
$status = $dbh->do("CREATE DATABASE $db_name WITH ENCODING='UNICODE' TEMPLATE template0");
}
elsif ( $db_type eq 'mysql' ) {
- $status = $dbh->do("CREATE DATABASE $db_name DEFAULT CHARACTER SET utf8");
+ $status = $dbh->do("CREATE DATABASE `$db_name` DEFAULT CHARACTER SET utf8");
}
else {
$status = $dbh->do("CREATE DATABASE $db_name");
@@ -406,6 +406,9 @@ sub DropDatabase {
$path = "$RT::VarPath/$path" unless substr($path, 0, 1) eq '/';
unlink $path or return (0, "Couldn't remove '$path': $!");
return (1);
+ } elsif ( $db_type eq 'mysql' ) {
+ $dbh->do("DROP DATABASE `$db_name`")
+ or return (0, $DBI::errstr);
} else {
$dbh->do("DROP DATABASE ". $db_name)
or return (0, $DBI::errstr);
-----------------------------------------------------------------------
More information about the rt-commit
mailing list