1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +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

@ -935,14 +935,15 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<row>
<entry><literal><function>abs(<replaceable>a</>)</></></>
<entry>same as <replaceable>a</></>
<entry>integer or double absolute value</>
<entry>absolute value</>
<entry><literal>abs(-17)</></>
<entry><literal>17</></>
</row>
<row>
<entry><literal><function>debug(<replaceable>a</>)</></></>
<entry>same as <replaceable>a</> </>
<entry>print to <systemitem>stderr</systemitem> the given argument</>
<entry>print <replaceable>a</> to <systemitem>stderr</systemitem>,
and return <replaceable>a</></>
<entry><literal>debug(5432.1)</></>
<entry><literal>5432.1</></>
</row>
@ -961,23 +962,23 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<entry><literal>9</></>
</row>
<row>
<entry><literal><function>max(<replaceable>i</> [, <replaceable>...</> ] )</></></>
<entry>integer</>
<entry>maximum value</>
<entry><literal>max(5, 4, 3, 2)</></>
<entry><literal><function>greatest(<replaceable>a</> [, <replaceable>...</> ] )</></></>
<entry>double if any <replaceable>a</> is double, else integer</>
<entry>largest value among arguments</>
<entry><literal>greatest(5, 4, 3, 2)</></>
<entry><literal>5</></>
</row>
<row>
<entry><literal><function>min(<replaceable>i</> [, <replaceable>...</> ] )</></></>
<entry>integer</>
<entry>minimum value</>
<entry><literal>min(5, 4, 3, 2)</></>
<entry><literal>2</></>
<entry><literal><function>least(<replaceable>a</> [, <replaceable>...</> ] )</></></>
<entry>double if any <replaceable>a</> is double, else integer</>
<entry>smallest value among arguments</>
<entry><literal>least(5, 4, 3, 2.1)</></>
<entry><literal>2.1</></>
</row>
<row>
<entry><literal><function>pi()</></></>
<entry>double</>
<entry>value of the PI constant</>
<entry>value of the constant PI</>
<entry><literal>pi()</></>
<entry><literal>3.14159265358979323846</></>
</row>