[interchange] Move MYSQL_ENABLE_UTF8 to a connection-level attribute

David Christensen interchange-cvs at icdevgroup.org
Fri Apr 16 16:04:36 UTC 2010

commit d591b9aebcffea2e3e81ed6faadbfeaae4dac3bd
Author: David Christensen <david at endpoint.com>
Date:   Fri Apr 16 11:04:12 2010 -0500

    Move MYSQL_ENABLE_UTF8 to a connection-level attribute
    When MYSQL_ENABLE_UTF8 is set, it currently does not provide the
    mysql_enable_utf8 parameter to the DBI->connect call; instead it's
    part of the DBI handle attributes that get set on an already-created
    From the docs for DBD::mysql, mysql_enable_utf8 needs to be set on
    connect, otherwise there are additional steps one needs to take to get
    the results returned in UTF8 (primarily issuing a $dbh->do("SET NAMES
    utf8") on the opened handle).
    With this change, when the catalog.cfg defines MYSQL_ENABLE_UTF8, the
    mysql_enable_utf8 => 1 attribute will be included in the hash of
    options returned by Vend::Table::DBI::find_dsn.  This will not occur
    unless said DatabaseDefault/Database attribute is defined.
    This corrects a bug when using MySQL with MV_UTF8 mode, as with the
    old behavior the UTF8 flag would be set on the values returned from
    the database, but they would not have been transferred in UTF8, but
    instead with the server's default character set (likely latin1).  The
    normal way to get around this issue when setting the $dbh attribute
    manually is to issue a $dbh->do("SET NAMES utf8"), which has the
    effect of setting the client's connection and results character sets
    to UTF8.
    This has the possibility of introducing some changes in application
    behavior, but since MYSQL_ENABLE_UTF8 is generally turned on in
    conjunction with MV_UTF8 mode, this is not judged to be a big risk.
    If existing user code was already working around this bug by issuing
    its own $dbh->do("SET NAMES utf8"), this will continue to work,
    essentially becoming a no-op.

 lib/Vend/Table/DBI.pm |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/lib/Vend/Table/DBI.pm b/lib/Vend/Table/DBI.pm
index 2fe8309..05a8433 100644
--- a/lib/Vend/Table/DBI.pm
+++ b/lib/Vend/Table/DBI.pm
@@ -56,6 +56,7 @@ my %Cattr = ( qw(
 					RAISEERROR     	RaiseError
 					PRINTERROR     	PrintError
 					AUTOCOMMIT     	AutoCommit
+					MYSQL_ENABLE_UTF8 mysql_enable_utf8
 				) );
 my @Cattr = keys %Cattr;

More information about the interchange-cvs mailing list