Bug #26010 UTF8-Flag not set with flag mysql_enable_utf8 and column collation utf8_bin
Submitted: 1 Feb 2007 15:10 Modified: 20 Mar 2007 14:13
Reporter: Sven Neuhaus Email Updates:
Status: Closed Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S3 (Non-critical)
Version:4.003 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[1 Feb 2007 15:10] Sven Neuhaus
Description:
When retrieving data from a column with collation utf8_bin, the utf8-flag does not get set.
It works correctly with the collations utf8_general_ci and utf8_unicode_ci.

How to repeat:
perl script:

use DBI;
my $dbh = DBI->connect($dsn, $user, $pass, { mysql_enable_utf8 => 1 });
$dbh->do("SET NAMES utf8");
$dbh->do("SET CHARACTER SET utf8");
my $sth = $dbh->prepare(q{
  SELECT name /* column with collation utf8_bin */
  FROM author
});
$sth->execute();
my $r = $sth->fetch;
print "not utf8" if ! utf8::is_utf8( $r->[0] );
$sth->finish;
$dbh->disconnect;

Suggested fix:
alter behaviour so utf8-flag also gets set for Columns with utf8_bin collation.

Ugly workaround:

Pick one of the working collations during select:
  SELECT name COLLATE utf8_general_ci AS name
  FROM author
[2 Feb 2007 11:08] Sveta Smirnova
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments to the original bug instead.

Thank you for your interest in MySQL.

I tried your test with string "not utf8\n" if ! utf8::is_utf8( $r->[0] );" replaced with "not utf8\n" if ! utf8::valid( $r->[0] ); and this code showed me $r->[0] is valid utf8. So problem is utf8 flag wasn't set. Because it I marked this one as duplicate of Bug #18904
[2 Feb 2007 11:29] Sven Neuhaus
Thank you for the quick response.

I disagree with the "dupe" marking:
Bug #18904 was the feature request. It should be marked "resolved" because the feature has been implemented since version 3.0007_2.

This is merely a bug in the implementation.
What does the (internal) function utf8::valid() have to do with this bug?
[9 Feb 2007 13:16] Sveta Smirnova
I've seen your bug report in CPAN at http://rt.cpan.org/Public/Bug/Display.html?id=24738

Add cross-link here too.
[20 Mar 2007 14:13] Sven Neuhaus
Fixed in upcoming version 4.004

See http://rt.cpan.org/Public/Bug/Display.html?id=24738 for details.