Add CSV table output mode in psql.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 26 Nov 2018 20:18:55 +0000 (15:18 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 26 Nov 2018 20:18:55 +0000 (15:18 -0500)
commitaa2ba50c2c13dd35a95a91638aa0a2b88c6df1eb
tree70dfa44c60d6697895151a176345c98c682a2df5
parent9a98984f4999b80435bcdcddf90bf9f3e5fc9df0
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
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/command.c
src/bin/psql/help.c
src/bin/psql/settings.h
src/bin/psql/startup.c
src/bin/psql/tab-complete.c
src/fe_utils/print.c
src/include/fe_utils/print.h
src/test/regress/expected/psql.out
src/test/regress/sql/psql.sql