Thread: BUG #15983: pg_dump converts CRLF to LF
The following bug has been logged on the website: Bug reference: 15983 Logged by: James Inform Email address: james.inform@pharmapp.de PostgreSQL version: 11.5 Operating system: Mac / Linux Description: When using "pg_dump --inserts" to generate insert statements in my dump file, all line feeds (LF and CRLF) in e.g. text fields are converted to LF. After importing the dump file using psql, all CRLF are gone and I have LF everywhere. So in fact pg_dump -> psql for backup/restore changes my data. This way I am loosing information that is necessary for applications that expect CRLF and not LF in the data they get from PostgreSQL. Btw. when not using --inserts in pg_dump then everything works fine and \r\n is used in the copy command for CRLF. So, I think we have to opportunities: 1. Fix this behaviour for --inserts option 2. State the behaviour in the manual, so that it is clear for every user.
PG Bug reporting form <noreply@postgresql.org> writes: > When using "pg_dump --inserts" to generate insert statements in my dump > file, all line feeds (LF and CRLF) in e.g. text fields are converted to > LF. Can't reproduce that here: the dump is correctly re-imported when I read it in psql, either with \i or with "-f". In the --inserts form, the newlines are just going to appear verbatim in the dump file, so they are very vulnerable to *other* tools deciding to convert them, and I speculate that that's what happened to your file. We could protect against that perhaps by dumping such strings using E'...\r\n...', but that would be entirely unportable to other DBMSes. Since the only real use-case for --inserts mode (IMO anyway) is to transfer data to other DBMSes, that doesn't seem like a win. regards, tom lane