Revision 33bef43e
Von Moritz Bunkus vor fast 10 Jahren hinzugefügt
SL/DBUpgrade2/Base.pm | ||
---|---|---|
11 | 11 |
use File::Copy (); |
12 | 12 |
use File::Path (); |
13 | 13 |
use List::MoreUtils qw(uniq); |
14 |
use version; |
|
14 | 15 |
|
15 | 16 |
use Rose::Object::MakeMethods::Generic ( |
16 | 17 |
scalar => [ qw(dbh myconfig) ], |
... | ... | |
57 | 58 |
sub db_errstr { |
58 | 59 |
my ($self, $handle) = @_; |
59 | 60 |
|
61 |
# DBD::Pg before 2.16.1 doesn't set the UTF-8 flag for error |
|
62 |
# messages even if the connection has UTF-8 enabled. Therefore we |
|
63 |
# have to convert it to Perl's internal encoding ourselves. See |
|
64 |
# https://rt.cpan.org/Public/Bug/Display.html?id=53854 |
|
65 |
|
|
60 | 66 |
my $error = $handle ? $handle->errstr : $self->dbh->errstr; |
61 | 67 |
|
68 |
return $error if version->new("$DBD::Pg::VERSION")->numify >= version->new("2.16.1")->numify; |
|
62 | 69 |
return Encode::decode('utf-8', $error); |
63 | 70 |
} |
64 | 71 |
|
... | ... | |
256 | 263 |
=item C<db_errstr [$handle]> |
257 | 264 |
|
258 | 265 |
Returns the last database from C<$handle> error message encoded in |
259 |
Perl's internal encoding. The PostgreSQL DBD leaves the UTF-8 flag off |
|
260 |
for error messages even if the C<pg_enable_utf8> attribute is set. |
|
266 |
Perl's internal encoding. The PostgreSQL DBD before 2.16.1 leaves the |
|
267 |
UTF-8 flag off for error messages even if the C<pg_enable_utf8> |
|
268 |
attribute is set. For older versions the error string is already |
|
269 |
encoded correctly and is left unchanged. |
|
261 | 270 |
|
262 | 271 |
C<$handle> is optional and can be one of three things: |
263 | 272 |
|
Auch abrufbar als: Unified diff
DBUpgrade: Fehlermeldungen richtig in Perls Encoding übersetzen
DBD::Pg vor Version 2.16.1 hat das UTF-8-Flag bei Fehlermeldungen nicht
gesetzt, auch wenn die Datenbankverbindung UTF-8 geflaggt war. Daher
musste bei früheren Version von DBD::Pg kivitendo die Fehlermeldung
selber ins richtige Encoding umwandeln.
Das darf bei neueren Versionen natürlich nicht mehr gemacht werden.