diff options
Diffstat (limited to 'src/bin/psql')
| -rw-r--r-- | src/bin/psql/command.c | 41 | ||||
| -rw-r--r-- | src/bin/psql/help.c | 10 | ||||
| -rw-r--r-- | src/bin/psql/prompt.c | 11 | ||||
| -rw-r--r-- | src/bin/psql/tab-complete.in.c | 3 | 
4 files changed, 60 insertions, 5 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index cc602087db2..4a2976dddf0 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -2709,7 +2709,8 @@ exec_command_pset(PsqlScanState scan_state, bool active_branch)  			int			i;  			static const char *const my_list[] = { -				"border", "columns", "csv_fieldsep", "expanded", "fieldsep", +				"border", "columns", "csv_fieldsep", +				"display_false", "display_true", "expanded", "fieldsep",  				"fieldsep_zero", "footer", "format", "linestyle", "null",  				"numericlocale", "pager", "pager_min_lines",  				"recordsep", "recordsep_zero", @@ -5300,6 +5301,26 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)  		}  	} +	/* 'false' display */ +	else if (strcmp(param, "display_false") == 0) +	{ +		if (value) +		{ +			free(popt->falsePrint); +			popt->falsePrint = pg_strdup(value); +		} +	} + +	/* 'true' display */ +	else if (strcmp(param, "display_true") == 0) +	{ +		if (value) +		{ +			free(popt->truePrint); +			popt->truePrint = pg_strdup(value); +		} +	} +  	/* field separator for unaligned text */  	else if (strcmp(param, "fieldsep") == 0)  	{ @@ -5474,6 +5495,20 @@ printPsetInfo(const char *param, printQueryOpt *popt)  			   popt->topt.csvFieldSep);  	} +	/* show boolean 'false' display */ +	else if (strcmp(param, "display_false") == 0) +	{ +		printf(_("Boolean false display is \"%s\".\n"), +			   popt->falsePrint ? popt->falsePrint : "f"); +	} + +	/* show boolean 'true' display */ +	else if (strcmp(param, "display_true") == 0) +	{ +		printf(_("Boolean true display is \"%s\".\n"), +			   popt->truePrint ? popt->truePrint : "t"); +	} +  	/* show field separator for unaligned text */  	else if (strcmp(param, "fieldsep") == 0)  	{ @@ -5743,6 +5778,10 @@ pset_value_string(const char *param, printQueryOpt *popt)  		return psprintf("%d", popt->topt.columns);  	else if (strcmp(param, "csv_fieldsep") == 0)  		return pset_quoted_string(popt->topt.csvFieldSep); +	else if (strcmp(param, "display_false") == 0) +		return pset_quoted_string(popt->falsePrint ? popt->falsePrint : "f"); +	else if (strcmp(param, "display_true") == 0) +		return pset_quoted_string(popt->truePrint ? popt->truePrint : "t");  	else if (strcmp(param, "expanded") == 0)  		return pstrdup(popt->topt.expanded == 2  					   ? "auto" diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index ed00c36695e..6ae1a9940de 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -290,9 +290,9 @@ slashUsage(unsigned short int pager)  	HELPN("  \\H                     toggle HTML output mode (currently %s)\n",  		  ON(pset.popt.topt.format == PRINT_HTML));  	HELP0("  \\pset [NAME [VALUE]]   set table output option\n" -		  "                         (border|columns|csv_fieldsep|expanded|fieldsep|\n" -		  "                         fieldsep_zero|footer|format|linestyle|null|\n" -		  "                         numericlocale|pager|pager_min_lines|recordsep|\n" +		  "                         (border|columns|csv_fieldsep|display_false|display_true|\n" +		  "                         expanded|fieldsep|fieldsep_zero|footer|format|linestyle|\n" +		  "                         null|numericlocale|pager|pager_min_lines|recordsep|\n"  		  "                         recordsep_zero|tableattr|title|tuples_only|\n"  		  "                         unicode_border_linestyle|unicode_column_linestyle|\n"  		  "                         unicode_header_linestyle|xheader_width)\n"); @@ -480,6 +480,10 @@ helpVariables(unsigned short int pager)  		  "    border style (number)\n");  	HELP0("  columns\n"  		  "    target width for the wrapped format\n"); +	HELP0("  display_false\n" +		  "    set the string to be printed in place of a boolean 'false'\n"); +	HELP0("  display_true\n" +		  "    set the string to be printed in place of a boolean 'true'\n");  	HELP0("  expanded (or x)\n"  		  "    expanded output [on, off, auto]\n");  	HELPN("  fieldsep\n" diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c index b08d7328fbf..59a2ceee07a 100644 --- a/src/bin/psql/prompt.c +++ b/src/bin/psql/prompt.c @@ -34,6 +34,7 @@   * %P - pipeline status: on, off or abort   * %> - database server port number   * %n - database user name + * %S - search_path   * %s - service   * %/ - current database   * %~ - like %/ but "~" when database name equals user name @@ -167,6 +168,16 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)  					if (pset.db)  						strlcpy(buf, session_username(), sizeof(buf));  					break; +					/* search_path */ +				case 'S': +					if (pset.db) +					{ +						const char *sp = PQparameterStatus(pset.db, "search_path"); + +						/* Use ? for versions that don't report search_path. */ +						strlcpy(buf, sp ? sp : "?", sizeof(buf)); +					} +					break;  					/* service name */  				case 's':  					{ diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 36ea6a4d557..0b7b3aead7c 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -5478,7 +5478,8 @@ match_previous_words(int pattern_id,  	else if (TailMatchesCS("\\password"))  		COMPLETE_WITH_QUERY(Query_for_list_of_roles);  	else if (TailMatchesCS("\\pset")) -		COMPLETE_WITH_CS("border", "columns", "csv_fieldsep", "expanded", +		COMPLETE_WITH_CS("border", "columns", "csv_fieldsep", +						 "display_false", "display_true", "expanded",  						 "fieldsep", "fieldsep_zero", "footer", "format",  						 "linestyle", "null", "numericlocale",  						 "pager", "pager_min_lines",  | 
