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

Rename pgbench min/max to least/greatest, and fix handling of double args.

These functions behave like the backend's least/greatest functions,
not like min/max, so the originally-chosen names invite confusion.
Per discussion, rename to least/greatest.

I also took it upon myself to make them return double if any input is
double.  The previous behavior of silently coercing all inputs to int
surely does not meet the principle of least astonishment.

Copy-edit some of the other new functions' documentation, too.
This commit is contained in:
Tom Lane
2016-05-05 14:51:00 -04:00
parent c311f78873
commit 7a622b2731
4 changed files with 69 additions and 36 deletions

View File

@ -131,7 +131,7 @@ make_op(yyscan_t yyscanner, const char *operator,
* List of available functions:
* - fname: function name
* - nargs: number of arguments
* -1 is a special value for min & max meaning #args >= 1
* -1 is a special value for least & greatest meaning #args >= 1
* - tag: function identifier from PgBenchFunction enum
*/
static const struct
@ -162,10 +162,10 @@ static const struct
"abs", 1, PGBENCH_ABS
},
{
"min", -1, PGBENCH_MIN
"least", -1, PGBENCH_LEAST
},
{
"max", -1, PGBENCH_MAX
"greatest", -1, PGBENCH_GREATEST
},
{
"debug", 1, PGBENCH_DEBUG
@ -274,7 +274,7 @@ make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args)
expr_yyerror_more(yyscanner, "unexpected number of arguments",
PGBENCH_FUNCTIONS[fnumber].fname);
/* check at least one arg for min & max */
/* check at least one arg for least & greatest */
if (PGBENCH_FUNCTIONS[fnumber].nargs == -1 &&
elist_length(args) == 0)
expr_yyerror_more(yyscanner, "at least one argument expected",