From: | James Orr <james(at)lrgmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: bytea on windows perl client |
Date: | 2002-07-17 17:00:00 |
Message-ID: | 200207171300.01423.james@lrgmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Hi Tom,
On Wednesday 17 July 2002 12:08 pm, Tom Lane wrote:
> James Orr <james(at)lrgmail(dot)com> 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 getting
> > 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
control characters etc. The one from windows seems to be all text like so
...
\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 = $dbh->prepare("SELECT logo FROM logos ORDER BY random() LIMIT
1");
$image_sth->execute();
my $image = $image_sth->fetchall_arrayref->[0]->[0];
$image_sth->finish();
$dbh->disconnect();
print "Content-type: image/png\n\n";
print $image;
exit;
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2002-07-17 17:06:09 | Re: bytea on windows perl client |
Previous Message | Tom Lane | 2002-07-17 16:08:59 | Re: bytea on windows perl client |