diff -ru DBD-mysql-4.003/dbdimp.c DBD-mysql-4.003-patched/dbdimp.c
--- DBD-mysql-4.003/dbdimp.c 2007-03-01 16:47:26.000000000 +0100
+++ DBD-mysql-4.003-patched/dbdimp.c 2007-03-12 15:31:01.000000000 +0100
@@ -3647,7 +3647,12 @@
sv_setpvn(sv, col, len);
/* UTF8 */
#if defined(sv_utf8_decode) && MYSQL_VERSION_ID >=SERVER_PREPARE_VERSION
+
+#if MYSQL_VERSION_ID >= FIELD_CHARSETNR_VERSION
+ if (imp_dbh->enable_utf8 && fields[i].charsetnr != 63) /* see bottom of:
http://www.mysql.org/doc/refman/5.0/en/c-api-datatypes.html */
+#else
if (imp_dbh->enable_utf8 && !(fields[i].flags & BINARY_FLAG))
+#endif
sv_utf8_decode(sv);
#endif
/* END OF UTF8 */
diff -ru DBD-mysql-4.003/dbdimp.h DBD-mysql-4.003-patched/dbdimp.h
--- DBD-mysql-4.003/dbdimp.h 2007-03-01 16:47:26.000000000 +0100
+++ DBD-mysql-4.003-patched/dbdimp.h 2007-03-12 15:26:26.000000000 +0100
@@ -36,6 +36,7 @@
#define NEW_DATATYPE_VERSION 50003
#define SSL_VERIFY_VERSION 50023
#define MYSQL_VERSION_5_0 50001
+#define FIELD_CHARSETNR_VERSION 40101 /* should equivalent to 4.1.0 */
/* This is to avoid the ugly #ifdef mess in dbdimp.c */
#if MYSQL_VERSION_ID < SQL_STATE_VERSION
#define mysql_sqlstate(svsock) (NULL)
Only in DBD-mysql-4.003-patched: .#mysql.xs
Only in DBD-mysql-4.003-patched: #mysql.xs#
Only in DBD-mysql-4.003-patched/t: mysql.mtest
diff -ru DBD-mysql-4.003/t/utf8.t DBD-mysql-4.003-patched/t/utf8.t
--- DBD-mysql-4.003/t/utf8.t 2007-01-06 20:07:23.000000000 +0100
+++ DBD-mysql-4.003-patched/t/utf8.t 2007-03-12 14:20:11.000000000 +0100
@@ -102,7 +102,7 @@
# Create a new table; In an ideal world, it'd be more sensible to
# make the whole database UTF8...
#
- $query = "CREATE TABLE $table (name VARCHAR(64) CHARACTER SET utf8, bincol BLOB, shape GEOMETRY)";
+ $query = "CREATE TABLE $table (name VARCHAR(64) CHARACTER SET utf8, bincol BLOB, shape GEOMETRY, binutf VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_bin)";
Test($state or $dbh->do($query))
or ErrMsgF("Cannot create table: Error %s.\n", $dbh->errstr);
@@ -126,11 +126,11 @@
Test( $state or ( $dbh->{ mysql_enable_utf8 } ) )
or ErrMsg( "mysql_enable_utf8 didn't survive connect()\n" );
- $query = qq{INSERT INTO $table (name, bincol, shape) VALUES (?,?, GeomFromText('Point(132865 501937)'))};
- Test( $state or $dbh->do( $query, {}, $utf8_str,$blob ) )
+ $query = qq{INSERT INTO $table (name, bincol, shape, binutf) VALUES (?,?, GeomFromText('Point(132865 501937)'), ?)};
+ Test( $state or $dbh->do( $query, {}, $utf8_str,$blob, $utf8_str ) )
or ErrMsgF( "INSERT failed: query $query, error %s.\n", $dbh->errstr );
- $query = "SELECT name,bincol,asbinary(shape) FROM $table LIMIT 1";
+ $query = "SELECT name,bincol,asbinary(shape), binutf FROM $table LIMIT 1";
Test( $state or ($sth = $dbh->prepare( $query ) ) )
or ErrMsgF( "prepare failed: query $query, error %s.\n", $dbh->errstr );
@@ -143,7 +143,13 @@
# Finally, check that we got back UTF-8 correctly.
Test( $state or ($ref->[0] eq $utf8_str) )
- or ErrMsgF( "got back '$ref->[0]' instead of '$utf8_str'.\n" );
+ or ErrMsgF( "got back '$ref->[0]' instead of '$utf8_str' (normal utf8 collation).\n" );
+
+ # same as above for utf8_bin column
+ Test( $state or ($ref->[3] eq $utf8_str) )
+ or ErrMsgF( "got back '$ref->[3]' instead of '$utf8_str' (binary utf8 collation).\n" );
+
+
if (eval "use Encode;") {
# Check for utf8 flag