Skip Menu |

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

Report information
The Basics
Id: 102245
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: greg [...] turnstep.com
Requestors: moritz [...] bunkus.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Warnings and errors don't have the UTF-8 flag turned on
Date: Fri, 20 Feb 2015 12:18:26 +0100
To: bug-DBD-Pg [...] rt.cpan.org
From: Moritz Bunkus <moritz [...] bunkus.org>
Hey, warnings and errors issued by DBD::Pg v3.5.0 don't have their UTF-8 flag turned on even if the connection itself has UTF-8 turned on. With the following test case the unmodified warnings and errors don't appear correct on the screen (this is with a PostgreSQL DB whose encoding is de_DE.UTF-8). The wrongly encoded messages look something like this: Warning not decoded: DBD::Pg::db do failed: FEHLER: Relation „qweqweqwe“ existiert nicht LINE 1: SELECT asdasd FROM qweqweqwe ^ at ./perl1.pl line 49. instead of Warning decoded: DBD::Pg::db do failed: FEHLER: Relation „qweqweqwe“ existiert nicht LINE 1: SELECT asdasd FROM qweqweqwe ^ at ./perl1.pl line 49. (The meaning is: relation qweqweqwe does not exist) UTF-8 does work on the connection in general, that's what the selectrow_array() line aims to prove. Decoding the warnings and errors does work, but there's no way to distinguish between DBD::Pg's warnings/errors and those produced by other parts of the program. Example program: use utf8; use strict; use DBI; use Encode; binmode STDIN, ':utf8'; binmode STDOUT, ':utf8'; binmode STDERR, ':utf8'; $SIG{__WARN__} = sub { my $w = join ' ', @_; print "Warning not decoded: $w\n"; print "Warning decoded: " . Encode::decode('UTF-8', $w) . "\n"; }; $SIG{__DIE__} = sub { my $w = join ' ', @_; print "Error not decoded: $w\n"; print "Error decoded: " . Encode::decode('UTF-8', $w) . "\n"; }; my $dbh = DBI->connect('dbi:Pg:database=mbkivilinet;host=localhost', 'postgres', '', { pg_enable_utf8 => 1 }) or die; my ($val) = $dbh->selectrow_array("SELECT 'hallöle'"); print "Value: $val\n"; $dbh->do("SELECT asdasd FROM qweqweqwe"); $dbh->{RaiseError} = 1; $dbh->do("SELECT asdasd FROM qweqweqwe"); $dbh->disconnect; Kind regards, mosu
Download (untitled)
application/pgp-signature 819b

Message body not shown because it is not plain text.

Thank you for the report, we will look into this.
Ugh, this dosn't look good. Near as I can tell, both DBI and Perl itelf are consipiring against us. DBD::Pg *does* set the UTF-8 flag. However, DBI then slings it around into new SVs without copying the flag. Further, it calls croak( which seems to not handle SVs at all! Will dig into that latter point and confirm.
So apparently Perl 5.14 has a croak_sv which in theory will do the right thing. We would also need to fix DBI so it keeps the flag when copying DBIc_ERRMSG to the sv named "msg". Going to mark this as stalled for now. One of us should probably raise a DBI ticket. :)
Subject: Re: [rt.cpan.org #102245] Warnings and errors don't have the UTF-8 flag turned on
Date: Fri, 27 Feb 2015 09:06:55 +0100
To: Greg Sabino Mullane via RT <bug-DBD-Pg [...] rt.cpan.org>
From: Moritz Bunkus <moritz [...] bunkus.org>
Hey, thanks for looking into this. I could certainly raise a ticket with DBI, but I lack the knowledge about Perl's C interface in order to describe the problem correctly. All I could do is copy & paste both my and your analysis from this bug, and I'm not sure that would be the best way to go. Therefore I'd prefer you raising that ticket. Thanks. Kind regards, mosu
Download (untitled)
application/pgp-signature 819b

Message body not shown because it is not plain text.

Created DBI ticket #102404
Closing this as resolved: the relevant bits are now part of DBI 1.639.