FROM 'D:\CBS_woningcijfers_2014.csv'
DELIMITER ';' CSV
fails with
ERROR: could not open file "D:\CBS_woningcijfers_2014.csv" for reading: No such file or directory'
and as usual, it's because the path is on their local host not the Pg server.
I think we should emit a HINT here, something like:
ERROR: could not open file "D:\CBS_woningcijfers_2014.csv" for reading: No such file or directory'
HINT: Paths for COPY are on the PostgreSQL server, not the client. You may want psql's \copy or a driver COPY ... FROM STDIN wrapper
as a usability improvement. Trivial patch attached.
I'm not sure how to avoid the need to translate the string multiple times, or if the tooling will automatically flatten them. I haven't bothered with the stat() failure or isdir cases, since they seem less likely to be the cause of users being confused between client and server.
Sample output:
postgres=# COPY x FROM '/tmp/somepath';
ERROR: could not open file "/tmp/somepath" for reading: No such file or directory
HINT: Paths for COPY are on the PostgreSQL server, not the client. You may want psql's \copy or a driver COPY ... FROM STDIN wrapper
postgres=# COPY x TO '/root/nopermissions';
ERROR: could not open file "/root/nopermissions" for writing: Permission denied
HINT: Paths for COPY are on the PostgreSQL server, not the client. You may want psql's \copy or a driver COPY ... FROM STDIN wrapper
postgres=# COPY x TO 'relpath';
ERROR: relative path not allowed for COPY to file
HINT: Paths for COPY are on the PostgreSQL server, not the client. You may want psql's \copy or a driver COPY ... FROM STDIN wrapper
--