diff -NBaur DBD-mysql-3.0006/dbdimp.c DBD-mysql-3.0006_utf8/dbdimp.c
--- DBD-mysql-3.0006/dbdimp.c 2006-06-10 00:47:26.000000000 +0100
+++ DBD-mysql-3.0006_utf8/dbdimp.c 2006-08-10 17:38:43.000000000 +0100
@@ -1379,6 +1380,22 @@
}
#endif
+
+ /* UTF8 */
+#if defined(sv_utf8_decode) && MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
+
+ if ((svp = hv_fetch(hv, "mysql_enable_utf8", 17, FALSE)) && *svp) {
+ /* Do not touch imp_dbh->enable_utf8 as we are called earlier
+ * than it is set and mysql_options() must be before:
+ * mysql_real_connect()
+ */
+ mysql_options(sock, MYSQL_SET_CHARSET_NAME,
+ (SvTRUE(*svp) ? "utf8" : "latin1"));
+ }
+#endif
+ /* END OF UTF8 */
+
+
#if defined(DBD_MYSQL_WITH_SSL) && !defined(DBD_MYSQL_EMBEDDED) && \
(defined(CLIENT_SSL) || (MYSQL_VERSION_ID >= 40000))
if ((svp = hv_fetch(hv, "mysql_ssl", 9, FALSE)) && *svp)
@@ -1579,6 +1596,12 @@
/* Safer we flip this to TRUE perl side if we detect a mod_perl env. */
imp_dbh->auto_reconnect = FALSE;
+ /* UTF8 */
+#if defined(sv_utf8_decode) && MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
+ imp_dbh->enable_utf8 = FALSE; /* initialize mysql_enable_utf8 */
+#endif
+ /* END OF UTF8 */
+
if (!my_login(dbh, imp_dbh))
{
do_error(dbh, mysql_errno(&imp_dbh->mysql),
@@ -1897,6 +1920,16 @@
else if (kl == 31 && strEQ(key,"mysql_unsafe_bind_type_guessing"))
imp_dbh->bind_type_guessing = SvIV(valuesv);
+
+ /* UTF8 */
+#if defined(sv_utf8_decode) && MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
+ else if (kl == 17 && strEQ(key, "mysql_enable_utf8")){
+ imp_dbh->enable_utf8 = bool_value;
+ }
+#endif
+
+ /* END OF UTF8 */
+
else
return FALSE; /* Unknown key */
@@ -1987,6 +2020,15 @@
const char* msg = mysql_error(&imp_dbh->mysql);
result= sv_2mortal(newSVpv(msg, strlen(msg)));
}
+
+ /* UTF8 */
+#if defined(sv_utf8_decode) && MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
+ else if (kl == strlen("enable_utf8") && strEQ(key, "enable_utf8")){
+ result = sv_2mortal(newSViv(imp_dbh->enable_utf8));
+ }
+#endif
+ /* END OF UTF8 */
+
break;
case 'd':
@@ -2787,6 +2829,7 @@
MYSQL_ROW cols;
imp_sth_fbh_t *fbh;
+
#if MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
MYSQL_BIND *bind;
#endif
@@ -2923,6 +2966,12 @@
if (dbis->debug >= 2)
PerlIO_printf(DBILOGFP, "st_fetch string data %s\n", fbh->data);
sv_setpvn(sv, fbh->data, fbh->length);
+ /* UTF8 */
+#ifdef sv_utf8_decode
+ if(imp_dbh->enable_utf8)
+ sv_utf8_decode(sv);
+#endif
+ /* END OF UTF8 */
break;
default:
@@ -2974,6 +3023,12 @@
{ --len; }
}
sv_setpvn(sv, col, len);
+ /* UTF8 */
+#ifdef sv_utf8_decode
+ if(imp_dbh->enable_utf8)
+ sv_utf8_decode(sv);
+#endif
+ /* END OF UTF8 */
}
else
(void) SvOK_off(sv); /* Field is NULL, return undef */
@@ -3930,6 +3985,13 @@
ptr= SvPV(str, len);
result= newSV(len*2+3);
+
+ /* UTF8 */
+#ifdef SvUTF8
+ if (SvUTF8(str)) SvUTF8_on(result);
+#endif
+ /* END OF UTF8 */
+
sptr= SvPVX(result);
*sptr++ = '\'';
diff -NBaur DBD-mysql-3.0006/dbdimp.h DBD-mysql-3.0006_utf8/dbdimp.h
--- DBD-mysql-3.0006/dbdimp.h 2006-05-17 23:29:40.000000000 +0100
+++ DBD-mysql-3.0006_utf8/dbdimp.h 2006-08-10 14:49:24.000000000 +0100
@@ -139,6 +139,12 @@
*/
int use_server_side_prepare;
int has_autodetect_prepare;
+
+ /* UTF8 */
+#if defined(sv_utf8_decode) && MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
+ bool enable_utf8;
+#endif
+ /* END OF UTF8 */
};
diff -NBaur DBD-mysql-3.0006/INSTALL.html DBD-mysql-3.0006_utf8/INSTALL.html
--- DBD-mysql-3.0006/INSTALL.html 2006-06-10 17:46:45.000000000 +0100
+++ DBD-mysql-3.0006_utf8/INSTALL.html 2006-08-10 17:49:54.000000000 +0100
@@ -2,7 +2,7 @@
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title>INSTALL - How to install and configure DBD::mysql</title>
-<link rev="made" href="mailto:root@b28.apple.com" />
+<link rev="made" href="mailto:root@localhost" />
</head>
<body style="background-color: white">
diff -NBaur DBD-mysql-3.0006/lib/DBD/mysql.pm DBD-mysql-3.0006_utf8/lib/DBD/mysql.pm
--- DBD-mysql-3.0006/lib/DBD/mysql.pm 2006-06-10 17:45:40.000000000 +0100
+++ DBD-mysql-3.0006_utf8/lib/DBD/mysql.pm 2006-08-10 17:40:08.000000000 +0100
@@ -9,7 +9,7 @@
use Carp ();
@ISA = qw(DynaLoader);
-$VERSION = '3.0006';
+$VERSION = '3.0006_utf8';
bootstrap DBD::mysql $VERSION;
@@ -952,6 +952,20 @@
It is possible to set/unset the C<mysql_use_result> attribute after
creation of statement handle. See below.
+=item mysql_enable_utf8
+
+This attribute determines whether DBD::mysql should assume strings
+stored in the database are utf8. This feature defaults to off.
+
+When set, a data retrieved from a textual column type (char, varchar,
+etc) will have the UTF-8 flag turned on if necessary. This enables
+character semantics on that string.
+
+Additionally, turning on this flag tells MySQL that incoming data should
+be treated as UTF-8. This will only take effect if used as part of the
+call to connect().
+
+This option is experimental and may change in future versions.
=head1 STATEMENT HANDLES
diff -NBaur DBD-mysql-3.0006/META.yml DBD-mysql-3.0006_utf8/META.yml
--- DBD-mysql-3.0006/META.yml 2006-06-10 17:46:45.000000000 +0100
+++ DBD-mysql-3.0006_utf8/META.yml 2006-08-10 17:49:54.000000000 +0100
@@ -1,7 +1,7 @@
#
http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: DBD-mysql
-version: 3.0006
+version: 3.0006_utf8
version_from: lib/DBD/mysql.pm
installdirs: site
requires:
diff -NBaur DBD-mysql-3.0006/t/._prepare_noerror.t DBD-mysql-3.0006_utf8/t/._prepare_noerror.t
--- DBD-mysql-3.0006/t/._prepare_noerror.t 2006-05-03 19:42:43.000000000 +0100
+++ DBD-mysql-3.0006_utf8/t/._prepare_noerror.t 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
- Mac OS X 2 R BINAhDmp
\ No newline at end of file