diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c
index ad55c3c..16744ac 100644
--- a/contrib/pgbench/pgbench.c
+++ b/contrib/pgbench/pgbench.c
@@ -1570,6 +1570,16 @@ top:
}
snprintf(res, sizeof(res), INT64_FORMAT, ope1 / ope2);
}
+ else if (strcmp(argv[3], "%") == 0)
+ {
+ if (ope2 == 0)
+ {
+ fprintf(stderr, "%s: division by zero in modulo\n", argv[0]);
+ st->ecnt++;
+ return true;
+ }
+ snprintf(res, sizeof(res), INT64_FORMAT, ope1 % ope2);
+ }
else
{
fprintf(stderr, "%s: unsupported operator %s\n", argv[0], argv[3]);
diff --git a/doc/src/sgml/pgbench.sgml b/doc/src/sgml/pgbench.sgml
index b7d88f3..9a6ee3b 100644
--- a/doc/src/sgml/pgbench.sgml
+++ b/doc/src/sgml/pgbench.sgml
@@ -735,7 +735,7 @@ pgbench options> dbname>
Each operand> is either an integer constant or a
:>variablename> reference to a variable
having an integer value. The operator> can be
- +>, ->, *>, or />.
+ +>, ->, *>, %> or />.