diff options
author | Tom Lane | 2018-11-26 20:18:55 +0000 |
---|---|---|
committer | Tom Lane | 2018-11-26 20:18:55 +0000 |
commit | aa2ba50c2c13dd35a95a91638aa0a2b88c6df1eb (patch) | |
tree | 70dfa44c60d6697895151a176345c98c682a2df5 /src/bin/psql/help.c | |
parent | 9a98984f4999b80435bcdcddf90bf9f3e5fc9df0 (diff) |
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/[email protected]
Diffstat (limited to 'src/bin/psql/help.c')
-rw-r--r-- | src/bin/psql/help.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 586aebddd3d..2e9fe760eb3 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -68,7 +68,7 @@ usage(unsigned short int pager) * Keep this line count in sync with the number of lines printed below! * Use "psql --help=options | wc" to count correctly. */ - output = PageOutput(61, pager ? &(pset.popt.topt) : NULL); + output = PageOutput(62, pager ? &(pset.popt.topt) : NULL); fprintf(output, _("psql is the PostgreSQL interactive terminal.\n\n")); fprintf(output, _("Usage:\n")); @@ -108,6 +108,7 @@ usage(unsigned short int pager) fprintf(output, _("\nOutput format options:\n")); fprintf(output, _(" -A, --no-align unaligned table output mode\n")); + fprintf(output, _(" --csv CSV (Comma-Separated Values) table output mode\n")); fprintf(output, _(" -F, --field-separator=STRING\n" " field separator for unaligned output (default: \"%s\")\n"), DEFAULT_FIELD_SEP); @@ -167,7 +168,7 @@ slashUsage(unsigned short int pager) * Use "psql --help=commands | wc" to count correctly. It's okay to count * the USE_READLINE line even in builds without that. */ - output = PageOutput(125, pager ? &(pset.popt.topt) : NULL); + output = PageOutput(126, pager ? &(pset.popt.topt) : NULL); fprintf(output, _("General\n")); fprintf(output, _(" \\copyright show PostgreSQL usage and distribution terms\n")); @@ -272,11 +273,12 @@ slashUsage(unsigned short int pager) fprintf(output, _(" \\H toggle HTML output mode (currently %s)\n"), ON(pset.popt.topt.format == PRINT_HTML)); fprintf(output, _(" \\pset [NAME [VALUE]] set table output option\n" - " (NAME := {border|columns|expanded|fieldsep|fieldsep_zero|\n" - " footer|format|linestyle|null|numericlocale|pager|\n" - " pager_min_lines|recordsep|recordsep_zero|tableattr|title|\n" - " tuples_only|unicode_border_linestyle|\n" - " unicode_column_linestyle|unicode_header_linestyle})\n")); + " (border|columns|csv_fieldsep|expanded|fieldsep|\n" + " fieldsep_zero|footer|format|linestyle|null|\n" + " numericlocale|pager|pager_min_lines|recordsep|\n" + " recordsep_zero|tableattr|title|tuples_only|\n" + " unicode_border_linestyle|unicode_column_linestyle|\n" + " unicode_header_linestyle)\n")); fprintf(output, _(" \\t [on|off] show only rows (currently %s)\n"), ON(pset.popt.topt.tuples_only)); fprintf(output, _(" \\T [STRING] set HTML <table> tag attributes, or unset if none\n")); |