Author: turnstep
Date: Thu Dec 2 06:58:30 2010
New Revision: 14560
Modified:
DBD-Pg/trunk/dbdimp.c
DBD-Pg/trunk/t/02attribs.t
Log:
Fix the setting of pg_enable_utf8.
Adjust test to accept all data from UTF8 database as potentially utf8
Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c (original)
+++ DBD-Pg/trunk/dbdimp.c Thu Dec 2 06:58:30 2010
@@ -859,8 +859,9 @@
#ifdef is_utf8_string
else if (strEQ("pg_enable_utf8", key)) {
- imp_dbh->pg_enable_utf8 = newval!=0 ? DBDPG_TRUE :
DBDPG_FALSE;
- /* Turning on does nothing now, but explicit off will
force is_utf8 off! */
+ /* Turning on has no effect now, but an explicit off
will force utf8 off */
+ imp_dbh->pg_enable_utf8 = (SvOK(valuesv) && 0 ==
(unsigned)SvIV(valuesv))
+ ? DBDPG_FALSE : DBDPG_TRUE;
if (imp_dbh->pg_enable_utf8 == DBDPG_FALSE) {
imp_dbh->is_utf8 = DBDPG_FALSE;
}
@@ -1066,8 +1067,7 @@
fieldname = PQfname(imp_sth->result, fields);
sv_fieldname = newSVpv(fieldname,0);
#ifdef is_utf8_string
- if (is_high_bit_set(aTHX_ (unsigned char
*)fieldname, strlen(fieldname)) && is_utf8_string((unsigned char *)fieldname,
strlen(fieldname)))
- SvUTF8_on(sv_fieldname);
+ SvUTF8_on(sv_fieldname);
#endif
(void)av_store(av, fields, sv_fieldname);
}
Modified: DBD-Pg/trunk/t/02attribs.t
==============================================================================
--- DBD-Pg/trunk/t/02attribs.t (original)
+++ DBD-Pg/trunk/t/02attribs.t Thu Dec 2 06:58:30 2010
@@ -435,14 +435,14 @@
my ($id, $name) = $sth->fetchrow_array();
ok (Encode::is_utf8($name), $t);
- $t='Unicode (utf8) data returned from database is not corrupted';
+ $t='Unicode (utf8) data returned from UTF8 database is not corrupted';
is (length($name), 4, $t);
- $t='ASCII text returned from database does not have utf8 bit set';
+ $t='ASCII text returned from UTF8 database does have utf8 bit set';
$sth->finish();
$sth->execute(1);
my ($id2, $name2) = $sth->fetchrow_array();
- ok (!Encode::is_utf8($name2), $t);
+ ok (Encode::is_utf8($name2), $t);
$sth->finish();
}