summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB.pm
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-11-19 00:10:11 +0100
committermkanat%bugzilla.org <>2006-11-19 00:10:11 +0100
commit496a78f616b10c1c5c4bd0398021232e9bffa77e (patch)
treefd30d0e1fc1c7789111d43ef5d7ce7dd31baa7de /Bugzilla/DB.pm
parentb8012210e03800d6473d2b19d7cf1beae6d12dc3 (diff)
downloadbugzilla-496a78f616b10c1c5c4bd0398021232e9bffa77e.tar.gz
bugzilla-496a78f616b10c1c5c4bd0398021232e9bffa77e.tar.xz
Bug 304550: Bugzilla should always store data in MySQL as UTF-8
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=justdave
Diffstat (limited to 'Bugzilla/DB.pm')
-rw-r--r--Bugzilla/DB.pm16
1 files changed, 13 insertions, 3 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index cefd361ae..33fdda0d8 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -130,6 +130,10 @@ sub bz_check_requirements {
. bz_locations()->{'localconfig'};
}
+ die("It is not safe to run Bugzilla inside the 'mysql' database.\n"
+ . "Please pick a different value for \$db_name in localconfig.")
+ if $lc->{db_name} eq 'mysql';
+
# Check the existence and version of the DBD that we need.
my $dbd = $db->{dbd};
my $dbd_ver = $db->{dbd_version};
@@ -196,8 +200,14 @@ sub bz_create_database {
print "Creating database $db_name...\n";
# Try to create the DB, and if we fail print a friendly error.
- if (!eval { $dbh->do("CREATE DATABASE $db_name") }) {
- my $error = $dbh->errstr;
+ my $success = eval {
+ my @sql = $dbh->_bz_schema->get_create_database_sql($db_name);
+ # This ends with 1 because this particular do doesn't always
+ # return something.
+ $dbh->do($_) foreach @sql; 1;
+ };
+ if (!$success) {
+ my $error = $dbh->errstr || $@;
chomp($error);
print STDERR "The '$db_name' database could not be created.",
" The error returned was:\n\n $error\n\n",
@@ -221,7 +231,7 @@ sub _get_no_db_connection {
if (!$conn_success) {
my $sql_server = DB_MODULE->{lc($lc->{db_driver})}->{name};
# Can't use $dbh->errstr because $dbh is undef.
- my $error = $DBI::errstr;
+ my $error = $DBI::errstr || $@;
chomp($error);
print STDERR "There was an error connecting to $sql_server:\n\n",
" $error\n\n", _bz_connect_error_reasons();