375{
377 int nlcount;
379
380 /*
381 * To avoid counting the output lines manually, build the output in "buf"
382 * and then count them.
383 */
385
386 HELP0(
"List of specially treated variables\n\n");
387
388 HELP0(
"psql variables:\n");
390 HELP0(
" psql --set=NAME=VALUE\n or \\set NAME VALUE inside psql\n\n");
391
392 HELP0(
" AUTOCOMMIT\n"
393 " if set, successful SQL commands are automatically committed\n");
394 HELP0(
" COMP_KEYWORD_CASE\n"
395 " determines the case used to complete SQL key words\n"
396 " [lower, upper, preserve-lower, preserve-upper]\n");
398 " the currently connected database name\n");
400 " controls what input is written to standard output\n"
401 " [all, errors, none, queries]\n");
402 HELP0(
" ECHO_HIDDEN\n"
403 " if set, display internal queries executed by backslash commands;\n"
404 " if set to \"noexec\", just show them without execution\n");
406 " current client character set encoding\n");
408 " \"true\" if last query failed, else \"false\"\n");
409 HELP0(
" FETCH_COUNT\n"
410 " the number of result rows to fetch and display at a time (0 = unlimited)\n");
411 HELP0(
" HIDE_TABLEAM\n"
412 " if set, table access methods are not displayed\n");
413 HELP0(
" HIDE_TOAST_COMPRESSION\n"
414 " if set, compression methods are not displayed\n");
415 HELP0(
" HISTCONTROL\n"
416 " controls command history [ignorespace, ignoredups, ignoreboth]\n");
418 " file name used to store the command history\n");
420 " maximum number of commands to store in the command history\n");
422 " the currently connected database server host\n");
424 " number of EOFs needed to terminate an interactive session\n");
426 " value of the last affected OID\n");
427 HELP0(
" LAST_ERROR_MESSAGE\n"
428 " LAST_ERROR_SQLSTATE\n"
429 " message and SQLSTATE of last error, or empty string and \"00000\" if none\n");
430 HELP0(
" ON_ERROR_ROLLBACK\n"
431 " if set, an error doesn't stop a transaction (uses implicit savepoints)\n");
432 HELP0(
" ON_ERROR_STOP\n"
433 " stop batch execution after error\n");
435 " server port of the current connection\n");
437 " specifies the standard psql prompt\n");
439 " specifies the prompt used when a statement continues from a previous line\n");
441 " specifies the prompt used during COPY ... FROM STDIN\n");
443 " run quietly (same as -q option)\n");
445 " number of rows returned or affected by last query, or 0\n");
446 HELP0(
" SERVER_VERSION_NAME\n"
447 " SERVER_VERSION_NUM\n"
448 " server's version (in short string or numeric format)\n");
449 HELP0(
" SHELL_ERROR\n"
450 " \"true\" if the last shell command failed, \"false\" if it succeeded\n");
451 HELP0(
" SHELL_EXIT_CODE\n"
452 " exit status of the last shell command\n");
453 HELP0(
" SHOW_ALL_RESULTS\n"
454 " show all results of a combined query (\\;) instead of only the last\n");
455 HELP0(
" SHOW_CONTEXT\n"
456 " controls display of message context fields [never, errors, always]\n");
457 HELP0(
" SINGLELINE\n"
458 " if set, end of line terminates SQL commands (same as -S option)\n");
459 HELP0(
" SINGLESTEP\n"
460 " single-step mode (same as -s option)\n");
462 " SQLSTATE of last query, or \"00000\" if no error\n");
464 " the currently connected database user\n");
466 " controls verbosity of error reports [default, verbose, terse, sqlstate]\n");
468 " VERSION_NAME\n"
469 " VERSION_NUM\n"
470 " psql's version (in verbose string, short string, or numeric format)\n");
471 HELPN(
" WATCH_INTERVAL\n"
472 " number of seconds \\watch waits between executions (default %s)\n",
474
475 HELP0(
"\nDisplay settings:\n");
477 HELP0(
" psql --pset=NAME[=VALUE]\n or \\pset NAME [VALUE] inside psql\n\n");
478
480 " border style (number)\n");
482 " target width for the wrapped format\n");
483 HELP0(
" expanded (or x)\n"
484 " expanded output [on, off, auto]\n");
486 " field separator for unaligned output (default \"%s\")\n",
488 HELP0(
" fieldsep_zero\n"
489 " set field separator for unaligned output to a zero byte\n");
491 " enable or disable display of the table footer [on, off]\n");
493 " set output format [unaligned, aligned, wrapped, html, asciidoc, ...]\n");
495 " set the border line drawing style [ascii, old-ascii, unicode]\n");
497 " set the string to be printed in place of a null value\n");
498 HELP0(
" numericlocale\n"
499 " enable display of a locale-specific character to separate groups of digits\n");
501 " control when an external pager is used [yes, no, always]\n");
503 " record (line) separator for unaligned output\n");
504 HELP0(
" recordsep_zero\n"
505 " set record separator for unaligned output to a zero byte\n");
506 HELP0(
" tableattr (or T)\n"
507 " specify attributes for table tag in html format, or proportional\n"
508 " column widths for left-aligned data types in latex-longtable format\n");
510 " set the table title for subsequently printed tables\n");
511 HELP0(
" tuples_only\n"
512 " if set, only actual table data is shown\n");
513 HELP0(
" unicode_border_linestyle\n"
514 " unicode_column_linestyle\n"
515 " unicode_header_linestyle\n"
516 " set the style of Unicode line drawing [single, double]\n");
517 HELP0(
" xheader_width\n"
518 " set the maximum width of the header for expanded output\n"
519 " [full, column, page, integer value]\n");
520
521 HELP0(
"\nEnvironment variables:\n");
523
524#ifndef WIN32
525 HELP0(
" NAME=VALUE [NAME=VALUE] psql ...\n or \\setenv NAME [VALUE] inside psql\n\n");
526#else
527 HELP0(
" set NAME=VALUE\n psql ...\n or \\setenv NAME [VALUE] inside psql\n\n");
528#endif
529
531 " number of columns for wrapped format\n");
533 " same as the application_name connection parameter\n");
534 HELP0(
" PGDATABASE\n"
535 " same as the dbname connection parameter\n");
537 " same as the host connection parameter\n");
538 HELP0(
" PGPASSFILE\n"
539 " password file name\n");
540 HELP0(
" PGPASSWORD\n"
541 " connection password (not recommended)\n");
543 " same as the port connection parameter\n");
545 " same as the user connection parameter\n");
546 HELP0(
" PSQL_EDITOR, EDITOR, VISUAL\n"
547 " editor used by the \\e, \\ef, and \\ev commands\n");
548 HELP0(
" PSQL_EDITOR_LINENUMBER_ARG\n"
549 " how to specify a line number when invoking the editor\n");
550 HELP0(
" PSQL_HISTORY\n"
551 " alternative location for the command history file\n");
552 HELP0(
" PSQL_PAGER, PAGER\n"
553 " name of external pager program\n");
554#ifndef WIN32
555 HELP0(
" PSQL_WATCH_PAGER\n"
556 " name of external pager program used for \\watch\n");
557#endif
559 " alternative location for the user's .psqlrc file\n");
561 " shell used by the \\! command\n");
563 " directory for temporary files\n");
564
565 /* Now we can count the lines. */
566 nlcount = 0;
567 for (
const char *ptr =
buf.data; *ptr; ptr++)
568 {
569 if (*ptr == '\n')
570 nlcount++;
571 }
572
573 /* And dump the output, with appropriate pagination. */
575
577
579
581}
#define DEFAULT_FIELD_SEP
#define DEFAULT_WATCH_INTERVAL