pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: postgresql.org@ch.pkts.ca
To: pgsql-bugs@postgresql.org
Subject: BUG #10052: COPY (...) TO 'file' doesn't create file
Date: Wed, 16 Apr 2014 17:54:36 +0000
Message-ID: <20140416175436.17202.83628@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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



view thread (2+ messages)  latest in thread

Message-ID: <20140416175436.17202.83628@wrigleys.postgresql.org>
Permalink:  ../20140416175436.17202.83628@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20140416175436.17202.83628@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: postgresql.org@ch.pkts.ca
  Subject: Re: BUG #10052: COPY (...) TO 'file' doesn't create file
  In-Reply-To: <20140416175436.17202.83628@wrigleys.postgresql.org>
  References: <20140416175436.17202.83628@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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