Re: csv format for psql

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: csv format for psql
Дата
Msg-id cd6020e3-fe39-4fdb-ba14-554d39d37c16@manitou-mail.org
обсуждение исходный текст
Ответ на Re: csv format for psql  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: csv format for psql
Список pgsql-hackers
    David G. Johnston wrote:

> I'm not following - if recordsep is not something that would
> interpreted as a newline then the file we output would have not
> structural newlines.
> It might have data newlines but those would be quoted.

They would be, but I don't quite understand the point
in your first sentence.
All I'm saying is that setting recordsep to '\r\n' does
not achieve the goal of obtaining CRLF line endings.

Here's an example with the unaligned mode, linux host:

(psql -At -P recordsep=$'\r\n' << EOF
  select E'A\nB' union E'C\nD';
EOF
) | hexdump -C

The result is:
00000000  41 0a 42 0d 0a 43 0a 44  0a      |A.B..C.D.|

The expectation of CRLF line endings is that every LF would be
preceded by CR, but here we get that only for 1 LF out of 4. That's
useless.

It's not a bug. We asked for a CRLF to separate our two
records and that's exactly what we got, no more no less.

In csv output, the difference would be that there would a double quote
character before A and after B, and before C and after D but otherwise
it would be the same mix of LF and CRLF.

I think that the point of recordsep in unaligned mode is you can set it
to something that never appears in the data, especially when embedded
newlines might be in the data. In CSV this is solved differently so
we don't need it.

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: PQHost() undefined behavior if connecting string contains bothhost and hostaddr types
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: PATCH: Unlogged tables re-initialization tests