Re: More probs with BLOBs

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Neanderthelle Jones *EXTERN*" <elle(at)view(dot)net(dot)au>, "PGSQL Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: More probs with BLOBs
Date: 2012-08-16 10:10:36
Message-ID: D960CB61B694CF459DCFB4B0128514C20841A261@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Neanderthelle Jones wrote:
> We are getting a strange thing happening if the lo_export(attr, path)
> destination is a fifo.
>
> First, in the normal case, there is output to the file but also
> feedback to stdout (or somewhere, appearing on the VT screen) of the
> number 1.
>
> -----------
> 1
> (1 row)
>
> Now, if the destination file is a fifo and a psql -c command is given
> from the shell to lo_export(attr, '/path/to/fifo') we don't get that
> feedback, but then a cat of the fifo to a normal file (cat fifo >
> file) writes the BLOB content to the destination file but also sends
>
> -----------
> 1
> (1 row)
>
> (or just "1" with psql -t) to the console, apparently (not stderr).
>
> So it seems to us that the lo_export output can't be piped (via a
> named pipe) to another process that reads from the pipe and expects
> the valid BLOB contents.
>
> Beyond my understanding. What is happening here, and can the echoing
> to the fifo be avoided? Ideas, anyone?
>
> (PostgreSQL 9.1.2, Linux 2.6.29.)

It works fine here (9.1.3 on 2.4.21):

$ mkfifo fifo && chmod 0777 fifo
$ psql -U postgres
test#> \lo_import '/path/to/some/bmp'
lo_import 47248

test#> \q
$ psql -U postgres -c "SELECT lo_export(47248, '/path/to/fifo')" >out
2>err &
$ cat fifo >f
$ file f
f: PC bitmap data, Windows 3.x format, 173 x 115 x 8
$ cat out
lo_export
-----------
1
(1 row)

The file "err" is empty.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2012-08-16 10:14:17 Re: PG Installer - Licensing Issues
Previous Message sayeed 2012-08-16 09:45:34 Re: You cannot do PITR with streaming replication - true?