diff --git a/src/bin/pgbench/exprparse.y b/src/bin/pgbench/exprparse.y
index 66288632d118d5469fcf0e24ec9e408ef61a2488..f7c56cc6a31f0e5c5067626c73ff5de6a88902e6 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 aa47710ace5a3cf9801fec2da4923c2e1c35319e..e82d3cb2429ea5459088699df5c873e0121dc19d 100644
--- a/src/bin/pgbench/t/002_pgbench_no_server.pl
+++ b/src/bin/pgbench/t/002_pgbench_no_server.pl
@@ -266,6 +266,26 @@ my @script_tests = (
 		'endif syntax error',
 		[qr{unexpected argument in command "endif"}],
 		{ 'endif-bad.sql' => "\\if 0\n\\endif BAD\n" }
+	],
+	[
+		'not enough arguments for least',
+		[qr{at least one argument expected \(least\)}],
+		{ 'bad-least.sql' => "\\set i least()\n" }
+	],
+	[
+		'not enough arguments for greatest',
+		[qr{at least one argument expected \(greatest\)}],
+		{ 'bad-greatest.sql' => "\\set i greatest()\n" }
+	],
+	[
+		'not enough arguments for hash',
+		[qr{unexpected number of arguments \(hash\)}],
+		{ 'bad-hash-1.sql' => "\\set i hash()\n" }
+	],
+	[
+		'too many arguments for hash',
+		[qr{unexpected number of arguments \(hash\)}],
+		{ 'bad-hash-2.sql' => "\\set i hash(1,2,3)\n" }
 	],);
 
 for my $t (@script_tests)