From 496a78f616b10c1c5c4bd0398021232e9bffa77e Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sat, 18 Nov 2006 23:10:11 +0000 Subject: Bug 304550: Bugzilla should always store data in MySQL as UTF-8 Patch By Max Kanat-Alexander r=LpSolit, a=justdave --- Bugzilla/DB/Schema/Mysql.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'Bugzilla/DB/Schema') diff --git a/Bugzilla/DB/Schema/Mysql.pm b/Bugzilla/DB/Schema/Mysql.pm index 0069dcc7f..d7cd708a2 100644 --- a/Bugzilla/DB/Schema/Mysql.pm +++ b/Bugzilla/DB/Schema/Mysql.pm @@ -129,7 +129,9 @@ sub _get_create_table_ddl { my($self, $table) = @_; - return($self->SUPER::_get_create_table_ddl($table) . ' TYPE = MYISAM'); + my $charset = Bugzilla->dbh->bz_db_is_utf8 ? "CHARACTER SET utf8" : ''; + return($self->SUPER::_get_create_table_ddl($table) + . " ENGINE = MYISAM $charset"); } #eosub--_get_create_table_ddl #------------------------------------------------------------------------------ @@ -150,6 +152,16 @@ sub _get_create_index_ddl { } #eosub--_get_create_index_ddl #-------------------------------------------------------------------- +sub get_create_database_sql { + my ($self, $name) = @_; + # We only create as utf8 if we have no params (meaning we're doing + # a new installation) or if the utf8 param is on. + my $create_utf8 = Bugzilla->params->{'utf8'} + || !defined Bugzilla->params->{'utf8'}; + my $charset = $create_utf8 ? "CHARACTER SET utf8" : ''; + return ("CREATE DATABASE $name $charset"); +} + # MySQL has a simpler ALTER TABLE syntax than ANSI. sub get_alter_column_ddl { my ($self, $table, $column, $new_def, $set_nulls_to) = @_; -- cgit v1.2.3-24-g4f1b