index 5c7e0f9c02d4400b578552beb6c091573f6c6b54..7a6ca392484250d5d10e79cdbab4d035a056ffce 100644 (file)
which <parameter>operand</parameter> falls in a histogram
having <parameter>count</parameter> equal-width buckets spanning the
range <parameter>low</parameter> to <parameter>high</parameter>.
- Returns <literal>0</literal>
+ The buckets have inclusive lower bounds and exclusive upper bounds.
+ Returns <literal>0</literal> for an input less
+ than <parameter>low</parameter>,
or <literal><parameter>count</parameter>+1</literal> for an input
- outside that range.
+ greater than or equal to <parameter>high</parameter>.
+ If <parameter>low</parameter> > <parameter>high</parameter>,
+ the behavior is mirror-reversed, with bucket <literal>1</literal>
+ now being the one just below <parameter>low</parameter>, and the
+ inclusive bounds now being on the upper side.
</para>
<para>
<literal>width_bucket(5.35, 0.024, 10.06, 5)</literal>
<returnvalue>3</returnvalue>
+ </para>
+ <para>
+ <literal>width_bucket(9, 10, 0, 10)</literal>
+ <returnvalue>2</returnvalue>
</para></entry>
</row>
@@ -1757,8 +1767,8 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
<para>
Returns the number of the bucket in
which <parameter>operand</parameter> falls given an array listing the
- lower bounds of the buckets. Returns <literal>0</literal> for an
- input less than the first lower
+ inclusive lower bounds of the buckets.
+ Returns <literal>0</literal> for an input less than the first lower
bound. <parameter>operand</parameter> and the array elements can be
of any type having standard comparison operators.
The <parameter>thresholds</parameter> array <emphasis>must be
index 63bb0f227729ec9c757a5c510fdd2b59b40ad545..9b7e0af4badf698e5404ff396aa934e427705048 100644 (file)
* in the histogram. width_bucket() returns an integer indicating the
* bucket number that 'operand' belongs to in an equiwidth histogram
* with the specified characteristics. An operand smaller than the
- * lower bound is assigned to bucket 0. An operand greater than the
- * upper bound is assigned to an additional bucket (with number
+ * lower bound is assigned to bucket 0. An operand greater than or equal
+ * to the upper bound is assigned to an additional bucket (with number
* count+1). We don't allow "NaN" for any of the float8 inputs, and we
* don't allow either of the histogram bounds to be +/- infinity.
*/
index e5f2551bf0451a682e9404520d63fecf78482839..f6aeaff7c0eeffcfa46bfb51f37efb798b899821 100644 (file)
* in the histogram. width_bucket() returns an integer indicating the
* bucket number that 'operand' belongs to in an equiwidth histogram
* with the specified characteristics. An operand smaller than the
- * lower bound is assigned to bucket 0. An operand greater than the
- * upper bound is assigned to an additional bucket (with number
- * count+1). We don't allow "NaN" for any of the numeric arguments.
+ * lower bound is assigned to bucket 0. An operand greater than or equal
+ * to the upper bound is assigned to an additional bucket (with number
+ * count+1). We don't allow "NaN" for any of the numeric inputs, and we
+ * don't allow either of the histogram bounds to be +/- infinity.
*/
Datum
width_bucket_numeric(PG_FUNCTION_ARGS)