Skip to content

Commit ed7e686

Browse files
committed
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
1 parent 8e7912e commit ed7e686

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/bin/psql/command.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4521,13 +4521,16 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
45214521
popt->topt.expanded_header_width_type = PRINT_XHEADER_PAGE;
45224522
else
45234523
{
4524-
popt->topt.expanded_header_width_type = PRINT_XHEADER_EXACT_WIDTH;
4525-
popt->topt.expanded_header_exact_width = atoi(value);
4526-
if (popt->topt.expanded_header_exact_width == 0)
4524+
int intval = atoi(value);
4525+
4526+
if (intval == 0)
45274527
{
45284528
pg_log_error("\\pset: allowed xheader_width values are \"%s\" (default), \"%s\", \"%s\", or a number specifying the exact width", "full", "column", "page");
45294529
return false;
45304530
}
4531+
4532+
popt->topt.expanded_header_width_type = PRINT_XHEADER_EXACT_WIDTH;
4533+
popt->topt.expanded_header_exact_width = intval;
45314534
}
45324535
}
45334536

@@ -4660,8 +4663,9 @@ do_pset(const char *param, const char *value, printQueryOpt *popt, bool quiet)
46604663
/* set minimum lines for pager use */
46614664
else if (strcmp(param, "pager_min_lines") == 0)
46624665
{
4663-
if (value)
4664-
popt->topt.pager_min_lines = atoi(value);
4666+
if (value &&
4667+
!ParseVariableNum(value, "pager_min_lines", &popt->topt.pager_min_lines))
4668+
return false;
46654669
}
46664670

46674671
/* disable "(x rows)" footer */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy