Hi,
I just want to let you know about a strange behaviour I recently stumbled
upon.
For some outlandish reason on some of our servers we have DBD::Pg Version
2.99_2 installed (Seemed that it solved some problems in that time).

When reading file names with e.g. Umlauts from a directory, either via
readdir() or glob() and storing them in a db these strings are not
correctly returned from the DB. This does not appear when the strings are
ordinary Perl Strings.

Here is a little script, that illustrates the issue:

All tests pass with 2.19.3 and fail with 2.99_2


#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Test::More;
use DBI;
use DBD::Pg;

=cut SQL

CREATE TABLE test (
  id serial NOT NULL PRIMARY KEY
  , data varchar(256)
  , text TEXT );

=cut

my $DSN = 'dbi:Pg:dbname=tester;host=mars.fotofinder.net';
my $dbh = DBI->connect($DSN, 'fotofinder', 'odarn', {});
my $select = $dbh->prepare("select * from test where id = ?");
my $insert = $dbh->prepare( "insert into test (data, text) VALUES (?,?)" );

Test::More::diag($DBD::Pg::VERSION);
my @filenames = ( "./files/Köln", "æ©Liedel" ); #works

#doesn't work as expected:
#opendir (DIR, "./files");
#@filenames = readdir(DIR);

#nor this:
@filenames = glob("./files/*");

foreach my $file (@filenames) {
  next if ( $file =~ /CVS/ );

  my $one = {
    data => $DBD::Pg::VERSION,
    text => $file,
  };
  $insert->execute( $one->{'data'}, $one->{'text'} );
  $one->{'id'} = $dbh->selectcol_arrayref("SELECT lastval()")->[0];

  my $res = $dbh->selectall_arrayref($select, {Slice => {}},
$one->{'id'})->[0];
  Test::More::cmp_ok( $res->{'text'}, "eq", $one->{'text'} );

}

Test::More::done_testing();


Attached is a file with a German Umlaut in it's name.

Hope that helps

-- 
-- 
mit freundlichem Gruß,

Frank Wesemann
Fotofinder GmbH         USt-IdNr. DE812854514
Software Entwicklung    Web: http://www.fotofinder.com/
Potsdamer Str. 96       Tel: +49 30 25 79 28 90
10785 Berlin            Fax: +49 30 25 79 28 999

Sitz: Berlin
Amtsgericht Berlin Charlottenburg (HRB 73099)
Geschäftsführer: Ali Paczensky
some content

Reply via email to