| Line | Hits | Source | Commit |
| 148 |
- |
slashUsage(unsigned short int pager) |
- |
| 149 |
- |
{ |
- |
| 150 |
- |
PQExpBufferData buf; |
- |
| 151 |
- |
int nlcount; |
- |
| 152 |
- |
FILE *output; |
- |
| 153 |
- |
char *currdb; |
- |
| 154 |
- |
|
- |
| 155 |
- |
currdb = PQdb(pset.db); |
- |
| 156 |
- |
|
- |
| 157 |
- |
/* |
- |
| 158 |
- |
* To avoid counting the output lines manually, build the output in "buf" |
- |
| 159 |
- |
* and then count them. |
- |
| 160 |
- |
*/ |
- |
| 161 |
- |
initPQExpBuffer(&buf); |
- |
| 162 |
- |
|
- |
| 163 |
- |
HELP0("General\n"); |
- |
| 164 |
- |
HELP0(" \\copyright show PostgreSQL usage and distribution terms\n"); |
- |
| 165 |
- |
HELP0(" \\crosstabview [COLUMNS] execute query and display result in crosstab\n"); |
- |
| 166 |
- |
HELP0(" \\errverbose show most recent error message at maximum verbosity\n"); |
- |
| 167 |
- |
HELP0(" \\g [(OPTIONS)] [FILE] execute query (and send result to file or |pipe);\n" |
- |
| 168 |
- |
" \\g with no arguments is equivalent to a semicolon\n"); |
- |
| 169 |
- |
HELP0(" \\gdesc describe result of query, without executing it\n"); |
- |
| 170 |
- |
HELP0(" \\gexec execute query, then execute each value in its result\n"); |
- |
| 171 |
- |
HELP0(" \\gset [PREFIX] execute query and store result in psql variables\n"); |
- |
| 172 |
- |
HELP0(" \\gx [(OPTIONS)] [FILE] as \\g, but forces expanded output mode\n"); |
- |
| 173 |
- |
HELP0(" \\q quit psql\n"); |
- |
| 174 |
- |
HELP0(" \\restrict RESTRICT_KEY\n" |
- |
| 175 |
- |
" enter restricted mode with provided key\n"); |
- |
| 176 |
- |
HELP0(" \\unrestrict RESTRICT_KEY\n" |
- |
| 177 |
- |
" exit restricted mode if key matches\n"); |
- |
| 178 |
- |
HELP0(" \\watch [[i=]SEC] [c=N] [m=MIN]\n" |
- |
| 179 |
- |
" execute query every SEC seconds, up to N times,\n" |
- |
| 180 |
- |
" stop if less than MIN rows are returned\n"); |
- |
| 181 |
- |
HELP0("\n"); |
- |
| 182 |
- |
|
- |
| 183 |
- |
HELP0("Help\n"); |
- |
| 184 |
- |
|
- |
| 185 |
- |
HELP0(" \\? [commands] show help on backslash commands\n"); |
- |
| 186 |
- |
HELP0(" \\? options show help on psql command-line options\n"); |
- |
| 187 |
- |
HELP0(" \\? variables show help on special variables\n"); |
- |
| 188 |
- |
HELP0(" \\h [NAME] help on syntax of SQL commands, * for all commands\n"); |
- |
| 189 |
- |
HELP0("\n"); |
- |
| 190 |
- |
|
- |
| 191 |
- |
HELP0("Query Buffer\n"); |
- |
| 192 |
- |
HELP0(" \\e [FILE] [LINE] edit the query buffer (or file) with external editor\n"); |
- |
| 193 |
- |
HELP0(" \\ef [FUNCNAME [LINE]] edit function definition with external editor\n"); |
- |
| 194 |
- |
HELP0(" \\ev [VIEWNAME [LINE]] edit view definition with external editor\n"); |
- |
| 195 |
- |
HELP0(" \\p show the contents of the query buffer\n"); |
- |
| 196 |
- |
HELP0(" \\r reset (clear) the query buffer\n"); |
- |
| 197 |
- |
#ifdef USE_READLINE |
- |
| 198 |
- |
HELP0(" \\s [FILE] display history or save it to file\n"); |
- |
| 199 |
- |
#endif |
- |
| 200 |
- |
HELP0(" \\w FILE write query buffer to file\n"); |
- |
| 201 |
- |
HELP0("\n"); |
- |
| 202 |
- |
|
- |
| 203 |
- |
HELP0("Input/Output\n"); |
- |
| 204 |
- |
HELP0(" \\copy ... perform SQL COPY with data stream to the client host\n"); |
- |
| 205 |
- |
HELP0(" \\echo [-n] [STRING] write string to standard output (-n for no newline)\n"); |
- |
| 206 |
- |
HELP0(" \\i FILE execute commands from file\n"); |
- |
| 207 |
- |
HELP0(" \\ir FILE as \\i, but relative to location of current script\n"); |
- |
| 208 |
- |
HELP0(" \\o [FILE] send all query results to file or |pipe\n"); |
- |
| 209 |
- |
HELP0(" \\qecho [-n] [STRING] write string to \\o output stream (-n for no newline)\n"); |
- |
| 210 |
- |
HELP0(" \\warn [-n] [STRING] write string to standard error (-n for no newline)\n"); |
- |
| 211 |
- |
HELP0("\n"); |
- |
| 212 |
- |
|
- |
| 213 |
- |
HELP0("Conditional\n"); |
- |
| 214 |
- |
HELP0(" \\if EXPR begin conditional block\n"); |
- |
| 215 |
- |
HELP0(" \\elif EXPR alternative within current conditional block\n"); |
- |
| 216 |
- |
HELP0(" \\else final alternative within current conditional block\n"); |
- |
| 217 |
- |
HELP0(" \\endif end conditional block\n"); |
- |
| 218 |
- |
HELP0("\n"); |
- |
| 219 |
- |
|
- |
| 220 |
- |
HELP0("Informational\n"); |
- |
| 221 |
- |
HELP0(" (options: S = show system objects, x = expanded mode, + = additional detail)\n"); |
- |
| 222 |
1 |
HELP0(" \\d[Sx+] list tables, views, sequences, and property graphs\n"); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 223 |
1 |
HELP0(" \\d[S+] NAME describe table, view, sequence, index, or property graph\n"); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 224 |
- |
HELP0(" \\da[Sx] [PATTERN] list aggregates\n"); |
- |
| 225 |
- |
HELP0(" \\dA[x+] [PATTERN] list access methods\n"); |
- |
| 226 |
- |
HELP0(" \\dAc[x+] [AMPTRN [TYPEPTRN]] list operator classes\n"); |
- |
| 227 |
- |
HELP0(" \\dAf[x+] [AMPTRN [TYPEPTRN]] list operator families\n"); |
- |
| 228 |
- |
HELP0(" \\dAo[x+] [AMPTRN [OPFPTRN]] list operators of operator families\n"); |
- |
| 229 |
- |
HELP0(" \\dAp[x+] [AMPTRN [OPFPTRN]] list support functions of operator families\n"); |
- |
| 230 |
- |
HELP0(" \\db[x+] [PATTERN] list tablespaces\n"); |
- |
| 231 |
- |
HELP0(" \\dc[Sx+] [PATTERN] list conversions\n"); |
- |
| 232 |
- |
HELP0(" \\dconfig[x+] [PATTERN] list configuration parameters\n"); |
- |
| 233 |
- |
HELP0(" \\dC[x+] [PATTERN] list casts\n"); |
- |
| 234 |
- |
HELP0(" \\dd[Sx] [PATTERN] show object descriptions not displayed elsewhere\n"); |
- |
| 235 |
- |
HELP0(" \\dD[Sx+] [PATTERN] list domains\n"); |
- |
| 236 |
- |
HELP0(" \\ddp[x] [PATTERN] list default privileges\n"); |
- |
| 237 |
- |
HELP0(" \\dE[Sx+] [PATTERN] list foreign tables\n"); |
- |
| 238 |
- |
HELP0(" \\des[x+] [PATTERN] list foreign servers\n"); |
- |
| 239 |
- |
HELP0(" \\det[x+] [PATTERN] list foreign tables\n"); |
- |
| 240 |
- |
HELP0(" \\deu[x+] [PATTERN] list user mappings\n"); |
- |
| 241 |
- |
HELP0(" \\dew[x+] [PATTERN] list foreign-data wrappers\n"); |
- |
| 242 |
- |
HELP0(" \\df[anptw][Sx+] [FUNCPTRN [TYPEPTRN ...]]\n" |
- |
| 243 |
- |
" list [only agg/normal/procedure/trigger/window] functions\n"); |
- |
| 244 |
- |
HELP0(" \\dF[x+] [PATTERN] list text search configurations\n"); |
- |
| 245 |
- |
HELP0(" \\dFd[x+] [PATTERN] list text search dictionaries\n"); |
- |
| 246 |
- |
HELP0(" \\dFp[x+] [PATTERN] list text search parsers\n"); |
- |
| 247 |
- |
HELP0(" \\dFt[x+] [PATTERN] list text search templates\n"); |
- |
| 248 |
- |
HELP0(" \\dg[Sx+] [PATTERN] list roles\n"); |
- |
| 249 |
1 |
HELP0(" \\dG[Sx+] [PATTERN] list property graphs\n"); |
86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 250 |
- |
HELP0(" \\di[Sx+] [PATTERN] list indexes\n"); |
- |
| 251 |
- |
HELP0(" \\dl[x+] list large objects, same as \\lo_list\n"); |
- |
| 252 |
- |
HELP0(" \\dL[Sx+] [PATTERN] list procedural languages\n"); |
- |
| 253 |
- |
HELP0(" \\dm[Sx+] [PATTERN] list materialized views\n"); |
- |
| 254 |
- |
HELP0(" \\dn[Sx+] [PATTERN] list schemas\n"); |
- |
| 255 |
- |
HELP0(" \\do[Sx+] [OPPTRN [TYPEPTRN [TYPEPTRN]]]\n" |
- |
| 256 |
- |
" list operators\n"); |
- |
| 257 |
- |
HELP0(" \\dO[Sx+] [PATTERN] list collations\n"); |
- |
| 258 |
- |
HELP0(" \\dp[Sx] [PATTERN] list table, view, and sequence access privileges\n"); |
- |
| 259 |
- |
HELP0(" \\dP[itnx+] [PATTERN] list [only index/table] partitioned relations [n=nested]\n"); |
- |
| 260 |
- |
HELP0(" \\drds[x] [ROLEPTRN [DBPTRN]]\n" |
- |
| 261 |
- |
" list per-database role settings\n"); |
- |
| 262 |
- |
HELP0(" \\drg[Sx] [PATTERN] list role grants\n"); |
- |
| 263 |
- |
HELP0(" \\dRp[x+] [PATTERN] list replication publications\n"); |
- |
| 264 |
- |
HELP0(" \\dRs[x+] [PATTERN] list replication subscriptions\n"); |
- |
| 265 |
- |
HELP0(" \\ds[Sx+] [PATTERN] list sequences\n"); |
- |
| 266 |
- |
HELP0(" \\dt[Sx+] [PATTERN] list tables\n"); |
- |
| 267 |
- |
HELP0(" \\dT[Sx+] [PATTERN] list data types\n"); |
- |
| 268 |
- |
HELP0(" \\du[Sx+] [PATTERN] list roles\n"); |
- |
| 269 |
- |
HELP0(" \\dv[Sx+] [PATTERN] list views\n"); |
- |
| 270 |
- |
HELP0(" \\dx[x+] [PATTERN] list extensions\n"); |
- |
| 271 |
- |
HELP0(" \\dX[x] [PATTERN] list extended statistics\n"); |
- |
| 272 |
- |
HELP0(" \\dy[x+] [PATTERN] list event triggers\n"); |
- |
| 273 |
- |
HELP0(" \\l[x+] [PATTERN] list databases\n"); |
- |
| 274 |
- |
HELP0(" \\sf[+] FUNCNAME show a function's definition\n"); |
- |
| 275 |
- |
HELP0(" \\sv[+] VIEWNAME show a view's definition\n"); |
- |
| 276 |
- |
HELP0(" \\z[Sx] [PATTERN] same as \\dp\n"); |
- |
| 277 |
- |
HELP0("\n"); |
- |
| 278 |
- |
|
- |
| 279 |
- |
HELP0("Large Objects\n"); |
- |
| 280 |
- |
HELP0(" \\lo_export LOBOID FILE write large object to file\n"); |
- |
| 281 |
- |
HELP0(" \\lo_import FILE [COMMENT]\n" |
- |
| 282 |
- |
" read large object from file\n"); |
- |
| 283 |
- |
HELP0(" \\lo_list[x+] list large objects\n"); |
- |
| 284 |
- |
HELP0(" \\lo_unlink LOBOID delete a large object\n"); |
- |
| 285 |
- |
HELP0("\n"); |
- |
| 286 |
- |
|
- |
| 287 |
- |
HELP0("Formatting\n"); |
- |
| 288 |
- |
HELP0(" \\a toggle between unaligned and aligned output mode\n"); |
- |
| 289 |
- |
HELP0(" \\C [STRING] set table title, or unset if none\n"); |
- |
| 290 |
- |
HELP0(" \\f [STRING] show or set field separator for unaligned query output\n"); |
- |
| 291 |
- |
HELPN(" \\H toggle HTML output mode (currently %s)\n", |
- |
| 292 |
- |
ON(pset.popt.topt.format == PRINT_HTML)); |
- |
| 293 |
- |
HELP0(" \\pset [NAME [VALUE]] set table output option\n" |
- |
| 294 |
- |
" see \"\\? variables\" for valid options\n"); |
- |
| 295 |
- |
HELPN(" \\t [on|off] show only rows (currently %s)\n", |
- |
| 296 |
- |
ON(pset.popt.topt.tuples_only)); |
- |
| 297 |
- |
HELP0(" \\T [STRING] set HTML <table> tag attributes, or unset if none\n"); |
- |
| 298 |
- |
HELPN(" \\x [on|off|auto] toggle expanded output (currently %s)\n", |
- |
| 299 |
- |
pset.popt.topt.expanded == 2 ? _("auto") : ON(pset.popt.topt.expanded)); |
- |
| 300 |
- |
HELP0("\n"); |
- |
| 301 |
- |
|
- |
| 302 |
- |
HELP0("Connection\n"); |
- |
| 303 |
- |
if (currdb) |
- |
| 304 |
- |
HELPN(" \\c[onnect] {[DBNAME|- USER|- HOST|- PORT|-] | conninfo}\n" |
- |
| 305 |
- |
" connect to new database (currently \"%s\")\n", |
- |
| 306 |
- |
currdb); |
- |
| 307 |
- |
else |
- |
| 308 |
- |
HELP0(" \\c[onnect] {[DBNAME|- USER|- HOST|- PORT|-] | conninfo}\n" |
- |
| 309 |
- |
" connect to new database (currently no connection)\n"); |
- |
| 310 |
- |
HELP0(" \\conninfo display information about current connection\n"); |
- |
| 311 |
- |
HELP0(" \\encoding [ENCODING] show or set client encoding\n"); |
- |
| 312 |
- |
HELP0(" \\password [USERNAME] securely change the password for a user\n"); |
- |
| 313 |
- |
HELP0("\n"); |
- |
| 314 |
- |
|
- |
| 315 |
- |
HELP0("Operating System\n"); |
- |
| 316 |
- |
HELP0(" \\cd [DIR] change the current working directory\n"); |
- |
| 317 |
- |
HELP0(" \\getenv PSQLVAR ENVVAR fetch environment variable\n"); |
- |
| 318 |
- |
HELP0(" \\setenv NAME [VALUE] set or unset environment variable\n"); |
- |
| 319 |
- |
HELPN(" \\timing [on|off] toggle timing of commands (currently %s)\n", |
- |
| 320 |
- |
ON(pset.timing)); |
- |
| 321 |
- |
HELP0(" \\! [COMMAND] execute command in shell or start interactive shell\n"); |
- |
| 322 |
- |
HELP0("\n"); |
- |
| 323 |
- |
|
- |
| 324 |
- |
HELP0("Variables\n"); |
- |
| 325 |
- |
HELP0(" \\prompt [TEXT] NAME prompt user to set internal variable\n"); |
- |
| 326 |
- |
HELP0(" \\set [NAME [VALUE]] set internal variable, or list all if no parameters\n"); |
- |
| 327 |
- |
HELP0(" \\unset NAME unset (delete) internal variable\n"); |
- |
| 328 |
- |
HELP0("\n"); |
- |
| 329 |
- |
|
- |
| 330 |
- |
HELP0("Extended Query Protocol\n"); |
- |
| 331 |
- |
HELP0(" \\bind [PARAM]... set query parameters\n"); |
- |
| 332 |
- |
HELP0(" \\bind_named STMT_NAME [PARAM]...\n" |
- |
| 333 |
- |
" set query parameters for an existing prepared statement\n"); |
- |
| 334 |
- |
HELP0(" \\close_prepared STMT_NAME\n" |
- |
| 335 |
- |
" close an existing prepared statement\n"); |
- |
| 336 |
- |
HELP0(" \\endpipeline exit pipeline mode\n"); |
- |
| 337 |
- |
HELP0(" \\flush flush output data to the server\n"); |
- |
| 338 |
- |
HELP0(" \\flushrequest send request to the server to flush its output buffer\n"); |
- |
| 339 |
- |
HELP0(" \\getresults [NUM_RES] read NUM_RES pending results, or all if no argument\n"); |
- |
| 340 |
- |
HELP0(" \\parse STMT_NAME create a prepared statement\n"); |
- |
| 341 |
- |
HELP0(" \\sendpipeline send an extended query to an ongoing pipeline\n"); |
- |
| 342 |
- |
HELP0(" \\startpipeline enter pipeline mode\n"); |
- |
| 343 |
- |
HELP0(" \\syncpipeline add a synchronisation point to an ongoing pipeline\n"); |
- |
| 344 |
- |
|
- |
| 345 |
- |
/* Now we can count the lines. */ |
- |
| 346 |
- |
nlcount = 0; |
- |
| 347 |
- |
for (const char *ptr = buf.data; *ptr; ptr++) |
- |
| 348 |
- |
{ |
- |
| 349 |
- |
if (*ptr == '\n') |
- |
| 350 |
- |
nlcount++; |
- |
| 351 |
- |
} |
- |
| 352 |
- |
|
- |
| 353 |
- |
/* And dump the output, with appropriate pagination. */ |
- |
| 354 |
- |
output = PageOutput(nlcount, pager ? &(pset.popt.topt) : NULL); |
- |
| 355 |
- |
|
- |
| 356 |
- |
fputs(buf.data, output); |
- |
| 357 |
- |
|
- |
| 358 |
- |
ClosePager(output); |
- |
| 359 |
- |
|
- |
| 360 |
- |
termPQExpBuffer(&buf); |
- |
| 361 |
- |
} |
- |