From 70e3b6464c5029187ec144aa12fc8b77c03f90c8 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sat, 18 Nov 2006 23:54:59 +0000 Subject: Checkin fix for Bug 280633, which didn't work when the utf8 parameter was turned on. --- contrib/recode.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'contrib/recode.pl') diff --git a/contrib/recode.pl b/contrib/recode.pl index 7db01dddf..10a4cbb44 100755 --- a/contrib/recode.pl +++ b/contrib/recode.pl @@ -174,9 +174,17 @@ if (exists $switch{'overrides'}) { my $dbh = Bugzilla->dbh; -# Make the database give us raw bytes. -$dbh->do('SET character_set_results = NULL') - if $dbh->isa('Bugzilla::DB::Mysql'); +if ($dbh->isa('Bugzilla::DB::Mysql')) { + # Get the actual current encoding of the DB. + my $collation_data = $dbh->selectrow_arrayref( + "SHOW VARIABLES LIKE 'character_set_database'"); + my $db_charset = $collation_data->[1]; + # Set our connection encoding to *that* encoding, so that MySQL + # correctly accepts our changes. + $dbh->do("SET NAMES $db_charset"); + # Make the database give us raw bytes. + $dbh->do('SET character_set_results = NULL') +} $dbh->begin_work; -- cgit v1.2.3-24-g4f1b