[PATCH] COPY vs \copy HINT
От | Craig Ringer |
---|---|
Тема | [PATCH] COPY vs \copy HINT |
Дата | |
Msg-id | CAMsr+YEqtD97qPEzQDqrCt5QiqPbWP_X4hmvy2pQzWC0GWiyPA@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: [PATCH] COPY vs \copy HINT
|
Список | pgsql-hackers |
Hi all
--
I see this sort of question quite a bit:
where the user wonders why
COPY gemeenten
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
Вложения
В списке pgsql-hackers по дате отправления: