src/bin/psql/command.c
static char *
pset_value_string(const char *param, printQueryOpt *popt)
{
	Assert(param != NULL);

	if (strcmp(param, "border") == 0)
		return psprintf("%d", popt->topt.border);
	else if (strcmp(param, "columns") == 0)
		return psprintf("%d", popt->topt.columns);
	else if (strcmp(param, "csv_fieldsep") == 0)
		return pset_quoted_string(popt->topt.csvFieldSep);
	else if (strcmp(param, "expanded") == 0)
		return pstrdup(popt->topt.expanded == 2
					   ? "auto"
					   : pset_bool_string(popt->topt.expanded));
	else if (strcmp(param, "fieldsep") == 0)
		return pset_quoted_string(popt->topt.fieldSep.separator
								  ? popt->topt.fieldSep.separator
								  : "");
	else if (strcmp(param, "fieldsep_zero") == 0)
		return pstrdup(pset_bool_string(popt->topt.fieldSep.separator_zero));
	else if (strcmp(param, "footer") == 0)
		return pstrdup(pset_bool_string(popt->topt.default_footer));
	else if (strcmp(param, "format") == 0)
		return psprintf("%s", _align2string(popt->topt.format));
	else if (strcmp(param, "linestyle") == 0)
		return psprintf("%s", get_line_style(&popt->topt)->name);
	else if (strcmp(param, "null") == 0)
		return pset_quoted_string(popt->nullPrint
								  ? popt->nullPrint
								  : "");
	else if (strcmp(param, "numericlocale") == 0)
		return pstrdup(pset_bool_string(popt->topt.numericLocale));
	else if (strcmp(param, "pager") == 0)
		return psprintf("%d", popt->topt.pager);
	else if (strcmp(param, "pager_min_lines") == 0)
		return psprintf("%d", popt->topt.pager_min_lines);
	else if (strcmp(param, "recordsep") == 0)
		return pset_quoted_string(popt->topt.recordSep.separator
								  ? popt->topt.recordSep.separator
								  : "");
	else if (strcmp(param, "recordsep_zero") == 0)
		return pstrdup(pset_bool_string(popt->topt.recordSep.separator_zero));
	else if (strcmp(param, "tableattr") == 0)
		return popt->topt.tableAttr ? pset_quoted_string(popt->topt.tableAttr) : pstrdup("");
	else if (strcmp(param, "title") == 0)
		return popt->title ? pset_quoted_string(popt->title) : pstrdup("");
	else if (strcmp(param, "tuples_only") == 0)
		return pstrdup(pset_bool_string(popt->topt.tuples_only));
	else if (strcmp(param, "unicode_border_linestyle") == 0)
		return pstrdup(_unicode_linestyle2string(popt->topt.unicode_border_linestyle));
	else if (strcmp(param, "unicode_column_linestyle") == 0)
		return pstrdup(_unicode_linestyle2string(popt->topt.unicode_column_linestyle));
	else if (strcmp(param, "unicode_header_linestyle") == 0)
		return pstrdup(_unicode_linestyle2string(popt->topt.unicode_header_linestyle));
	else
		return pstrdup("ERROR");
}
/*
 * Return a malloc'ed string for the \pset value.
 *
 * Note that for some string parameters, print.c distinguishes between unset
 * and empty string, but for others it doesn't.  This function should produce
 * output that produces the correct setting when fed back into \pset.
 */
Return a malloc'ed string for the \pset value.
Note that for some string parameters, print.c distinguishes between unset
and empty string, but for others it doesn't.  This function should produce
output that produces the correct setting when fed back into \pset.
Return a malloc ' ed string for the \ pset value . Note that for some string parameters print . c distinguishes between unset and empty string but for others it doesn ' t . This function should produce output that produces the correct setting when fed back into \ pset .
static char *
pset_value_string(const char *param, printQueryOpt *popt)
{
	Assert(param != NULL);
	if (strcmp(param, "border") == 0)
		return psprintf("%d", popt->topt.border);
	else if (strcmp(param, "columns") == 0)
		return psprintf("%d", popt->topt.columns);
	else if (strcmp(param, "csv_fieldsep") == 0)
		return pset_quoted_string(popt->topt.csvFieldSep);
	else if (strcmp(param, "expanded") == 0)
		return pstrdup(popt->topt.expanded == 2
					   ? "auto"
					   : pset_bool_string(popt->topt.expanded));
	else if (strcmp(param, "fieldsep") == 0)
		return pset_quoted_string(popt->topt.fieldSep.separator
								  ? popt->topt.fieldSep.separator
								  : "");
	else if (strcmp(param, "fieldsep_zero") == 0)
		return pstrdup(pset_bool_string(popt->topt.fieldSep.separator_zero));
	else if (strcmp(param, "footer") == 0)
		return pstrdup(pset_bool_string(popt->topt.default_footer));
	else if (strcmp(param, "format") == 0)
		return psprintf("%s", _align2string(popt->topt.format));
	else if (strcmp(param, "linestyle") == 0)
		return psprintf("%s", get_line_style(&popt->topt)->name);
	else if (strcmp(param, "null") == 0)
		return pset_quoted_string(popt->nullPrint
								  ? popt->nullPrint
								  : "");
	else if (strcmp(param, "numericlocale") == 0)
		return pstrdup(pset_bool_string(popt->topt.numericLocale));
	else if (strcmp(param, "pager") == 0)
		return psprintf("%d", popt->topt.pager);
	else if (strcmp(param, "pager_min_lines") == 0)
		return psprintf("%d", popt->topt.pager_min_lines);
	else if (strcmp(param, "recordsep") == 0)
		return pset_quoted_string(popt->topt.recordSep.separator
								  ? popt->topt.recordSep.separator
								  : "");
	else if (strcmp(param, "recordsep_zero") == 0)
		return pstrdup(pset_bool_string(popt->topt.recordSep.separator_zero));
	else if (strcmp(param, "tableattr") == 0)
		return popt->topt.tableAttr ? pset_quoted_string(popt->topt.tableAttr) : pstrdup("");
	else if (strcmp(param, "title") == 0)
		return popt->title ? pset_quoted_string(popt->title) : pstrdup("");
	else if (strcmp(param, "tuples_only") == 0)
		return pstrdup(pset_bool_string(popt->topt.tuples_only));
	else if (strcmp(param, "unicode_border_linestyle") == 0)
		return pstrdup(_unicode_linestyle2string(popt->topt.unicode_border_linestyle));
	else if (strcmp(param, "unicode_column_linestyle") == 0)
		return pstrdup(_unicode_linestyle2string(popt->topt.unicode_column_linestyle));
	else if (strcmp(param, "unicode_header_linestyle") == 0)
		return pstrdup(_unicode_linestyle2string(popt->topt.unicode_header_linestyle));
	else
		return pstrdup("ERROR");
}
static char * pset_value_string ( const char * param , printQueryOpt * popt ) { Assert ( param != NULL ) ; if ( strcmp ( param , " " ) == 0 ) return psprintf ( " " , popt -> topt . border ) ; else if ( strcmp ( param , " " ) == 0 ) return psprintf ( " " , popt -> topt . columns ) ; else if ( strcmp ( param , " " ) == 0 ) return pset_quoted_string ( popt -> topt . csvFieldSep ) ; else if ( strcmp ( param , " " ) == 0 ) return pstrdup ( popt -> topt . expanded == 2 ? " " : pset_bool_string ( popt -> topt . expanded ) ) ; else if ( strcmp ( param , " " ) == 0 ) return pset_quoted_string ( popt -> topt . fieldSep . separator ? popt -> topt . fieldSep . separator : " " ) ; else if ( strcmp ( param , " " ) == 0 ) return pstrdup ( pset_bool_string ( popt -> topt . fieldSep . separator_zero ) ) ; else if ( strcmp ( param , " " ) == 0 ) return pstrdup ( pset_bool_string ( popt -> topt . default_footer ) ) ; else if ( strcmp ( param , " " ) == 0 ) return psprintf ( " " , _align2string ( popt -> topt . format ) ) ; else if ( strcmp ( param , " " ) == 0 ) return psprintf ( " " , get_line_style ( & popt -> topt ) -> name ) ; else if ( strcmp ( param , " " ) == 0 ) return pset_quoted_string ( popt -> nullPrint ? popt -> nullPrint : " " ) ; else if ( strcmp ( param , " " ) == 0 ) return pstrdup ( pset_bool_string ( popt -> topt . numericLocale ) ) ; else if ( strcmp ( param , " " ) == 0 ) return psprintf ( " " , popt -> topt . pager ) ; else if ( strcmp ( param , " " ) == 0 ) return psprintf ( " " , popt -> topt . pager_min_lines ) ; else if ( strcmp ( param , " " ) == 0 ) return pset_quoted_string ( popt -> topt . recordSep . separator ? popt -> topt . recordSep . separator : " " ) ; else if ( strcmp ( param , " " ) == 0 ) return pstrdup ( pset_bool_string ( popt -> topt . recordSep . separator_zero ) ) ; else if ( strcmp ( param , " " ) == 0 ) return popt -> topt . tableAttr ? pset_quoted_string ( popt -> topt . tableAttr ) : pstrdup ( " " ) ; else if ( strcmp ( param , " " ) == 0 ) return popt -> title ? pset_quoted_string ( popt -> title ) : pstrdup ( " " ) ; else if ( strcmp ( param , " " ) == 0 ) return pstrdup ( pset_bool_string ( popt -> topt . tuples_only ) ) ; else if ( strcmp ( param , " " ) == 0 ) return pstrdup ( _unicode_linestyle2string ( popt -> topt . unicode_border_linestyle ) ) ; else if ( strcmp ( param , " " ) == 0 ) return pstrdup ( _unicode_linestyle2string ( popt -> topt . unicode_column_linestyle ) ) ; else if ( strcmp ( param , " " ) == 0 ) return pstrdup ( _unicode_linestyle2string ( popt -> topt . unicode_header_linestyle ) ) ; else return pstrdup ( " " ) ; }
Return a malloc'ed string for the \pset value.
Return a malloc ' ed string for the \ pset value .