aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2023-05-19 20:19:28 +0200
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2023-05-19 20:19:28 +0200
commited7e686a031e5b9469e0813af2f513dfdd77560b (patch)
treec5295833ca686397c685b37a463c4eb59a2dbba8 /src
parent8e7912e73da008862180112cc6ba4d0aa5fa955d (diff)
downloadpostgresql-ed7e686a031e5b9469e0813af2f513dfdd77560b.tar.gz
postgresql-ed7e686a031e5b9469e0813af2f513dfdd77560b.zip
psql: Tweak xheader_width and pager_min_lines input parsing
Don't throw away the previous value when an invalid value is proposed. Discussion: https://postgr.es/m/20230519110205.updpbjiuqgbox6gp@alvherre.pgsql
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/command.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 95b304aaf68..ab3f4e49204 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -4521,13 +4521,16 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
popt->topt.expanded_header_width_type = PRINT_XHEADER_PAGE;
else
{
- popt->topt.expanded_header_width_type = PRINT_XHEADER_EXACT_WIDTH;
- popt->topt.expanded_header_exact_width = atoi(value);
- if (popt->topt.expanded_header_exact_width == 0)
+ int intval = atoi(value);
+
+ if (intval == 0)
{
pg_log_error("\\pset: allowed xheader_width values are \"%s\" (default), \"%s\", \"%s\", or a number specifying the exact width", "full", "column", "page");
return false;
}
+
+ popt->topt.expanded_header_width_type = PRINT_XHEADER_EXACT_WIDTH;
+ popt->topt.expanded_header_exact_width = intval;
}
}
@@ -4660,8 +4663,9 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
/* set minimum lines for pager use */
else if (strcmp(param, "pager_min_lines") == 0)
{
- if (value)
- popt->topt.pager_min_lines = atoi(value);
+ if (value &&
+ !ParseVariableNum(value, "pager_min_lines", &popt->topt.pager_min_lines))
+ return false;
}
/* disable "(x rows)" footer */