MCPcopy Create free account
hub / github.com/apache/cloudberry / usage

Function usage

src/bin/psql/help.c:47–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45#define ON(var) (var ? _("on") : _("off"))
46
47void
48usage(unsigned short int pager)
49{
50 const char *env;
51 const char *user;
52 char *errstr;
53 FILE *output;
54
55 /* Find default user, in case we need it. */
56 user = getenv("PGUSER");
57 if (!user)
58 {
59 user = get_user_name(&errstr);
60 if (!user)
61 {
62 pg_log_fatal("%s", errstr);
63 exit(EXIT_FAILURE);
64 }
65 }
66
67 /*
68 * Keep this line count in sync with the number of lines printed below!
69 * Use "psql --help=options | wc" to count correctly.
70 */
71 output = PageOutput(63, pager ? &(pset.popt.topt) : NULL);
72
73 fprintf(output, _("psql is the PostgreSQL interactive terminal (Cloudberry version).\n\n"));
74 fprintf(output, _("Usage:\n"));
75 fprintf(output, _(" psql [OPTION]... [DBNAME [USERNAME]]\n\n"));
76
77 fprintf(output, _("General options:\n"));
78 /* Display default database */
79 env = getenv("PGDATABASE");
80 if (!env)
81 env = user;
82 fprintf(output, _(" -c, --command=COMMAND run only single command (SQL or internal) and exit\n"));
83 fprintf(output, _(" -d, --dbname=DBNAME database name to connect to (default: \"%s\")\n"), env);
84 fprintf(output, _(" -f, --file=FILENAME execute commands from file, then exit\n"));
85 fprintf(output, _(" -l, --list list available databases, then exit\n"));
86 fprintf(output, _(" -v, --set=, --variable=NAME=VALUE\n"
87 " set psql variable NAME to VALUE\n"
88 " (e.g., -v ON_ERROR_STOP=1)\n"));
89 fprintf(output, _(" -V, --version output version information, then exit\n"));
90 fprintf(output, _(" -X, --no-psqlrc do not read startup file (~/.psqlrc)\n"));
91 fprintf(output, _(" -1 (\"one\"), --single-transaction\n"
92 " execute as a single transaction (if non-interactive)\n"));
93 fprintf(output, _(" -?, --help[=options] show this help, then exit\n"));
94 fprintf(output, _(" --help=commands list backslash commands, then exit\n"));
95 fprintf(output, _(" --help=variables list special variables, then exit\n"));
96
97 fprintf(output, _("\nInput and output options:\n"));
98 fprintf(output, _(" -a, --echo-all echo all input from script\n"));
99 fprintf(output, _(" -b, --echo-errors echo failed commands\n"));
100 fprintf(output, _(" -e, --echo-queries echo commands sent to server\n"));
101 fprintf(output, _(" -E, --echo-hidden display queries that internal commands generate\n"));
102 fprintf(output, _(" -L, --log-file=FILENAME send session log to file\n"));
103 fprintf(output, _(" --ignore-log-file do not log psql:filename prefix in log file\n"));
104 fprintf(output, _(" -n, --no-readline disable enhanced command line editing (readline)\n"));

Callers 3

mainFunction · 0.70
parse_psql_optionsFunction · 0.70

Calls 3

get_user_nameFunction · 0.85
PageOutputFunction · 0.85
ClosePagerFunction · 0.85

Tested by

no test coverage detected