Received: from james.webteknics.com (65-85-235-195.client.dsl.net [65.85.235.195]) by postgresql.org (Postfix) with ESMTP id C096447585D for ; Wed, 17 Jul 2002 12:57:45 -0400 (EDT) Received: from localhost (localhost [[UNIX: localhost]]) by james.webteknics.com (8.11.6/8.11.6) id g6HH03902557; Wed, 17 Jul 2002 13:00:03 -0400 Content-Type: text/plain; charset="iso-8859-1" From: James Orr To: Tom Lane Subject: Re: bytea on windows perl client Date: Wed, 17 Jul 2002 13:00:00 -0400 User-Agent: KMail/1.4.1 Cc: pgsql-interfaces@postgresql.org References: <200207171201.25600.james@lrgmail.com> <14471.1026922139@sss.pgh.pa.us> In-Reply-To: <14471.1026922139@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200207171300.01423.james@lrgmail.com> X-Archive-Number: 200207/101 X-Sequence-Number: 2910 Hi Tom, On Wednesday 17 July 2002 12:08 pm, Tom Lane wrote: > James Orr writes: > > I have some code which runs fine on linux. It simply pulls a png from a > > bytea column and displays it. > > > > Now I need to get it running on windows. We have installed ActiveState > > perl with the DBI module and downloaded and installed the DBD-Pg binary. > > Connections to the database are working fine, but the png file is getti= ng > > corrupted. > > > > Anybody know the work-around? > > I'd bet money that the problem is a newline conversion issue --- you > could check by noticing whether the PNG signature (first 8 bytes of the > file) comes back correctly or not. The signature is designed to get > changed if it's fed through any of the standard kinds of newline > conversion (\n -> \r\n, for example). OK, if I load the output into vi. The one from linux contains a bunch of= =20 control characters etc. The one from windows seems to be all text like so= =20 ... \211PNG\015\012\000 and so on. Here is my actual perl script: #! /usr/bin/perl -w use DBI; require 'common.pl'; my $dbh; initdb(\$dbh); # Get the logos my $image_sth =3D $dbh->prepare("SELECT logo FROM logos ORDER BY random() L= IMIT=20 1"); $image_sth->execute(); my $image =3D $image_sth->fetchall_arrayref->[0]->[0]; $image_sth->finish(); $dbh->disconnect(); print "Content-type: image/png\n\n"; print $image; exit;