diff --git a/src/bin/pgbench/exprparse.y b/src/bin/pgbench/exprparse.y index 66288632d1..f7c56cc6a3 100644 --- a/src/bin/pgbench/exprparse.y +++ b/src/bin/pgbench/exprparse.y @@ -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); diff --git a/src/bin/pgbench/t/002_pgbench_no_server.pl b/src/bin/pgbench/t/002_pgbench_no_server.pl index a2845a583b..51875f99d1 100644 --- a/src/bin/pgbench/t/002_pgbench_no_server.pl +++ b/src/bin/pgbench/t/002_pgbench_no_server.pl @@ -270,6 +270,11 @@ my @script_tests = ( 'endif syntax error', [qr{unexpected argument in command "endif"}], { 'endif-bad.sql' => "\\if 0\n\\endif BAD\n" } + ], + [ + 'hash unexpected #args', + [qr{unexpected number of arguments \(hash\)}], + { 'bad-hash.sql' => "\\set i hash()\n" } ],); for my $t (@script_tests)