pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #10052: COPY (...) TO 'file' doesn't create file
2+ messages / 2 participants
[nested] [flat]

* BUG #10052: COPY (...) TO 'file' doesn't create file
@ 2014-04-16 17:54  postgresql.org@ch.pkts.ca
  0 siblings, 1 reply; 2+ messages in thread

From: postgresql.org@ch.pkts.ca @ 2014-04-16 17:54 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      10052
Logged by:          PFudd
Email address:      postgresql.org@ch.pkts.ca
PostgreSQL version: 9.2.8
Operating system:   CentOS 6.5
Description:        

In psql, this command works:
#   copy (select * from history) to STDOUT;
It prints 957 lines to stdout.

However, if I do:
#   copy (select * from history) to '/tmp/foo.txt';
it prints
   COPY 957
but doesn't create the file /tmp/foo.txt.

If the filename is changed to 'foo.txt' it says:
   ERROR:  relative path not allowed for COPY to file
so we know that it's at least looking at the filename critically.

If the filename is changed to /tmp/foo.txt without the single quotes, it
says:
    ERROR:  syntax error at or near "/"
as expected.

It doesn't matter if I'm doing this as a regular user or as the root user.

Using strace, it can be seen there was no attempt to stat or open that
filename for writing:

# env PGPASSWORD=password strace -fo/tmp/strace.log psql -h 1.2.3.4 -U
username -c "copy (select * from history where num=5) to '/tmp/foo.txt'"
analyzer_local

# cat /tmp/foo.txt
cat: /tmp/foo.txt: No such file or directory

# grep -c foo.txt /tmp/strace.log
0

This was tried with psql 9.2.8 and psql 9.1.13, connecting to a server
running 9.2.4.



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #10052: COPY (...) TO 'file' doesn't create file
@ 2014-04-16 18:28  Bruce Momjian <bruce@momjian.us>
  parent: postgresql.org@ch.pkts.ca
  0 siblings, 0 replies; 2+ messages in thread

From: Bruce Momjian @ 2014-04-16 18:28 UTC (permalink / raw)
  To: postgresql.org@ch.pkts.ca; +Cc: pgsql-bugs

On Wed, Apr 16, 2014 at 05:54:36PM +0000, postgresql.org@ch.pkts.ca wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      10052
> Logged by:          PFudd
> Email address:      postgresql.org@ch.pkts.ca
> PostgreSQL version: 9.2.8
> Operating system:   CentOS 6.5
> Description:        
> 
> In psql, this command works:
> #   copy (select * from history) to STDOUT;
> It prints 957 lines to stdout.
> 
> However, if I do:
> #   copy (select * from history) to '/tmp/foo.txt';
> it prints
>    COPY 957
> but doesn't create the file /tmp/foo.txt.

Uh, you realize that is a file on the server, not on the client.  You
might want to try psql's \copy.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2014-04-16 18:28 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-04-16 17:54 BUG #10052: COPY (...) TO 'file' doesn't create file postgresql.org@ch.pkts.ca
2014-04-16 18:28 ` Bruce Momjian <bruce@momjian.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox