Right, the file difference is caused by "-At".
On the other side, in order to keep the output message more consistent with other tools, I did a litter bit more
investigationon pg_dump to see how it handles this situation. Here is my findings.
pg_dump using WRITE_ERROR_EXIT to throw the error message when "(bytes_written != size * nmemb)", where
WRITE_ERROR_EXITcalls fatal("could not write to output file: %m") and then "pg_log_generic(PG_LOG_ERROR, __VA_ARGS__)".
Afterran a quick test in the same situation, I got message like below,
$ pg_dump -h localhost -p 5432 -d postgres -t psql_error -f /mnt/ramdisk/file
pg_dump: error: could not write to output file: No space left on device
If I change the error log message like below, where "%m" is used to pass the value of strerror(errno), "could not write
tooutput file:" is copied from function "WRITE_ERROR_EXIT".
- pg_log_error("Error printing tuples");
+ pg_log_error("could not write to output file: %m");
then the output message is something like below, which, I believe, is more consistent with pg_dump.
$ psql -d postgres -t -c "select repeat('111', 1000000)" -o /mnt/ramdisk/file
could not write to output file: No space left on device
$ psql -d postgres -t -c "select repeat('111', 1000000)" > /mnt/ramdisk/file
could not write to output file: No space left on device
Hope the information will help.
David
---
Highgo Software Inc. (Canada)
www.highgo.ca