From: | "Dawid Kuroczko" <qnex42(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Possible TODO item: copy to/from pipe |
Date: | 2006-06-01 08:42:41 |
Message-ID: | 758d5e7f0606010142h7b0f63a1g54ad174ddb1fe56@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 5/31/06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> After re-reading what I just wrote to Andreas about how compression of
> COPY data would be better done outside the backend than inside, it
> struck me that we are missing a feature that's fairly common in Unix
> programs. Perhaps COPY ought to have the ability to pipe its output
> to a shell command, or read input from a shell command. Maybe something
> like
>
> COPY mytable TO '| gzip >/home/tgl/mytable.dump.gz';
>
> (I'm not wedded to the above syntax, it's just an off-the-cuff thought.)
>
> Of course psql would need the same capability, since the server-side
> copy would still be restricted to superusers.
>
> You can accomplish COPY piping now through psql, but it's a bit awkward:
>
> psql -c "COPY mytable TO stdout" mydb | gzip ...
>
> Thoughts? Is this worth doing, or is the psql -c approach good enough?
You can accomplish it now with help of FIFOs, like
\! mkfifo /tmp/psqlfifo
\! chmod 666 /tmp/psqlfifo
-- I know 666 is a dangerous number. ;)
\! gzip -9 < /tmp/psqlfifo > /tmp/psqlcopy.gz
COPY foo TO '/tmp/psqlfifo';
...though ability to pipe "directly" is desirable feature.
Regards,
Dawid
From | Date | Subject | |
---|---|---|---|
Next Message | Hannu Krosing | 2006-06-01 09:16:37 | Re: session id and global storage |
Previous Message | David Hoksza | 2006-06-01 08:10:38 | Re: session id and global storage |