Re: csv format for psql

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: csv format for psql
Дата
Msg-id 5013.1543264631@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: csv format for psql  ("Daniel Verite" <daniel@manitou-mail.org>)
Ответы Re: csv format for psql  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: csv format for psql  ("Daniel Verite" <daniel@manitou-mail.org>)
Список pgsql-hackers
"Daniel Verite" <daniel@manitou-mail.org> writes:
>> A proposed fix is attached. print_csv_vertical() is left unchanged
>> because it's not possible currently to end up with \. alone
>> on a line with the expanded display

> On second thought, it is possible
> postgres=# \pset format csv
> Output format is csv.
> postgres=# \pset fieldsep_csv '.'
> Field separator for CSV is ".".
> postgres=# \x
> Expanded display is on.
> postgres=# select '' as "\" ;
> \.

Ugh.  There's more to that than meets the eye; consider also

\pset csv_fieldsep '.'
select '\' as d1, '' as d2;

or the reverse case where we set the fieldsep to '\' and then
emit a second field containing '.'.

I think that the approach you're using doesn't really scale to handle
all these cases sanely, so what I did instead was just to make
csv_print_field force field quoting if any of these cases could
possibly apply.  That will result in excess quoting in some
cases, but I think that's fine, since they're all pretty uncommon.

(BTW, it seems only chance that the server's CSV mode isn't also
subject to this case, but since it always quotes empty fields,
I think we're OK there.)

Pushed with that correction and some other last-minute review.

            regards, tom lane


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

Предыдущее
От: Sergei Kornilov
Дата:
Сообщение: Re: pgsql: Integrate recovery.conf into postgresql.conf
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: pgsql: Integrate recovery.conf into postgresql.conf