Обсуждение: pgsql: Add CSV table output mode in psql.

Поиск
Список
Период
Сортировка

pgsql: Add CSV table output mode in psql.

От
Tom Lane
Дата:
Add CSV table output mode in psql.

"\pset format csv", or --csv, selects comma-separated values table format.
This is compliant with RFC 4180, except that we aren't too picky about
whether the record separator is LF or CRLF; also, the user may choose a
field separator other than comma.

This output format is directly compatible with the server's COPY CSV
format, and will also be useful as input to other programs.  It's
considerably safer for that purpose than the old recommendation to
use "unaligned" format, since the latter couldn't handle data
containing the field separator character.

Daniel Vérité, reviewed by Fabien Coelho and David Fetter, some
tweaking by me

Discussion: https://postgr.es/m/a8de371e-006f-4f92-ab72-2bbe3ee78f03@manitou-mail.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/aa2ba50c2c13dd35a95a91638aa0a2b88c6df1eb

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml     |  98 +++++++++++++++++++++------
src/bin/psql/command.c             |  39 ++++++++++-
src/bin/psql/help.c                |  16 +++--
src/bin/psql/settings.h            |   1 +
src/bin/psql/startup.c             |   7 ++
src/bin/psql/tab-complete.c        |   5 +-
src/fe_utils/print.c               | 131 ++++++++++++++++++++++++++++++++++++-
src/include/fe_utils/print.h       |   2 +
src/test/regress/expected/psql.out |  89 +++++++++++++++++++++++++
src/test/regress/sql/psql.sql      |  48 ++++++++++++++
10 files changed, 402 insertions(+), 34 deletions(-)