1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-25 01:02:05 +03:00

Fix handling of pgbench's hash when no argument is provided

Depending on the platform used, this can cause a crash in the worst
case, or an unhelpful error message, so fail gracefully.

Author: Fabien Coelho
Discussion: https://postgr.es/m/alpine.DEB.2.21.1807262302550.29874@lancre
Backpatch: 11-, where hash() has been added in pgbench.
This commit is contained in:
Michael Paquier
2018-07-27 13:43:36 +09:00
parent c606f10ff8
commit c2e5f60db1
2 changed files with 21 additions and 1 deletions

View File

@ -467,7 +467,7 @@ make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args)
/* hash functions with optional seed argument */
case PGBENCH_NARGS_HASH:
if (len > 2)
if (len < 1 || len > 2)
expr_yyerror_more(yyscanner, "unexpected number of arguments",
PGBENCH_FUNCTIONS[fnumber].fname);