Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DBD-Oracle CPAN distribution.

Report information
The Basics
Id: 92134
Status: resolved
Priority: 0/
Queue: DBD-Oracle

People
Owner: Nobody in particular
Requestors: spiceman [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.68
Fixed in: 1.70



Subject: Values are decoded but the hash keys aren't when using ->fetchrow_hashref()
I don't know what else can I provide to help debug this. #!/usr/bin/env perl use strict; use warnings; use feature qw/:5.10/; use DBI; use Data::Dumper; use Encode qw/is_utf8 decode/; use utf8; $Data::Dumper::Useqq = 1; { no warnings 'redefine'; sub Data::Dumper::qquote { my $s = shift; return "'$s'"; } } binmode STDOUT, ":utf8"; $ENV{NLS_LANG} = "Japanese_Japan.AL32UTF8"; my $dbh = DBI->connect("dbi:Oracle://1.1.1.1:1521/orcl", "DBUSER", "DBPASS") or die $@; my $sth = $dbh->prepare(q|SELECT * FROM DFW_M20M WHERE "名称1" = '調達区分'|); $sth->execute(); my $data = $sth->fetchrow_hashref; for my $key ( keys %$data ) { say "key (", (is_utf8($key) ? 1 : 0), "): ", $key; say "decoded : ", decode("utf8", $key); say "value(", (is_utf8($data->{$key}) ? 1 : 0), "): ", $data->{$key}; } __DATA__ key (0): å��称2 decoded : 名称2 value(1): key (0): å��称K2 decoded : 名称K2 value(1): 22 key (0): FILLER decoded : FILLER value(1): key (0): å��称K1 decoded : 名称K1 value(1): 00 key (0): å��称1 decoded : 名称1 value(1): 調達区分
On Tue Jan 14 05:01:21 2014, SPICEMAN wrote: Show quoted text
> I don't know what else can I provide to help debug this. > > > #!/usr/bin/env perl > > use strict; > use warnings; > use feature qw/:5.10/; > use DBI; > use Data::Dumper; > use Encode qw/is_utf8 decode/; > use utf8; > > $Data::Dumper::Useqq = 1; > > { > no warnings 'redefine'; > sub Data::Dumper::qquote { > my $s = shift; > return "'$s'"; > } > } > > binmode STDOUT, ":utf8"; > > $ENV{NLS_LANG} = "Japanese_Japan.AL32UTF8"; > > my $dbh = DBI->connect("dbi:Oracle://1.1.1.1:1521/orcl", "DBUSER", > "DBPASS") or die $@; > my $sth = $dbh->prepare(q|SELECT * FROM DFW_M20M WHERE "名称1" = > '調達区分'|); > > $sth->execute(); > > my $data = $sth->fetchrow_hashref; > > for my $key ( keys %$data ) { > say "key (", (is_utf8($key) ? 1 : 0), "): ", $key; > say "decoded : ", decode("utf8", $key); > say "value(", (is_utf8($data->{$key}) ? 1 : 0), "): ", $data-
> >{$key};
> } > > > __DATA__ > > key (0): å��称2 > decoded : 名称2 > value(1): > key (0): å��称K2 > decoded : 名称K2 > value(1): 22 > key (0): FILLER > decoded : FILLER > value(1): > key (0): å��称K1 > decoded : 名称K1 > value(1): 00 > key (0): å��称1 > decoded : 名称1 > value(1): 調達区分
Spiceman confirmed the following patch fixes the issue he reported. There may be a better way to do this as name_sv is already stored in the fbh i.e., I didn't notice NAME duplicated the char string in name and originally decoded the name_sv created when the column is described. diff --git a/dbdimp.c b/dbdimp.c index c913133..74f5b97 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -4341,10 +4341,20 @@ dbd_st_FETCH_attrib(SV *sth, imp_sth_t *imp_sth, SV *key if (kl==4 && strEQ(key, "NAME")) { AV *av = newAV(); - retsv = newRV(sv_2mortal((SV*)av)); - while(--i >= 0) - av_store(av, i, newSVpv((char*)imp_sth->fbh[i].name,0)); + SV *x; + retsv = newRV(sv_2mortal((SV*)av)); + while(--i >= 0) { + x = newSVpv((char*)imp_sth->fbh[i].name,0); + if (CSFORM_IMPLIES_UTF8(SQLCS_IMPLICIT)) { +#ifdef sv_utf8_decode + sv_utf8_decode(x); +#else + SvUTF8_on(x); +#endif + } + av_store(av, i, x); + } } else if (kl==11 && strEQ(key, "ParamValues")) { HV *pvhv = newHV(); Martin -- Martin J. Evans Wetherby, UK