mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Implement the width_bucket() function, per SQL2003. This commit only adds
a variant of the function for the 'numeric' datatype; it would be possible to add additional variants for other datatypes, but I haven't done so yet. This commit includes regression tests and minimal documentation; if we want developers to actually use this function in applications, we'll probably need to document what it does more fully.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/errcodes.sgml,v 1.4 2004/05/14 18:04:02 neilc Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/errcodes.sgml,v 1.5 2004/05/14 21:42:27 neilc Exp $ -->
|
||||
|
||||
<appendix id="errcodes-appendix">
|
||||
<title><productname>PostgreSQL</productname> Error Codes</title>
|
||||
@ -310,6 +310,11 @@
|
||||
<entry>INTERVAL FIELD OVERFLOW</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal>2201G</literal></entry>
|
||||
<entry>INVALID ARGUMENT FOR WIDTH BUCKET FUNCTION</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal>22018</literal></entry>
|
||||
<entry>INVALID CHARACTER VALUE FOR CAST</entry>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.201 2004/05/10 22:44:42 tgl Exp $
|
||||
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.202 2004/05/14 21:42:27 neilc Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
@ -751,6 +751,16 @@ PostgreSQL documentation
|
||||
<entry><literal>42.43</literal></entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><literal><function>width_bucket</function>(<parameter>op</parameter> <type>numeric</type>, <parameter>b1</parameter> <type>numeric</type>, <parameter>b2</parameter> <type>numeric</type>, <parameter>count</parameter> <type>integer</type>)</literal></entry>
|
||||
<entry><type>integer</type></entry>
|
||||
<entry>return the bucket to which <parameter>operand</> would
|
||||
be assigned in an equidepth histogram with <parameter>count</>
|
||||
buckets, an upper bound of <parameter>b1</>, and a lower bound
|
||||
of <parameter>b2</></entry>
|
||||
<entry><literal>width_bucket(5.35, 0.024, 10.06, 5)</literal></entry>
|
||||
<entry><literal>3</literal></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.82 2004/05/10 22:44:43 tgl Exp $
|
||||
$PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.83 2004/05/14 21:42:27 neilc Exp $
|
||||
-->
|
||||
|
||||
<sect1 id="xfunc">
|
||||
@ -56,7 +56,7 @@ $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.82 2004/05/10 22:44:43 tgl Exp $
|
||||
</para>
|
||||
|
||||
<para>
|
||||
It's easiest to define <acronym>SQL</acronym>
|
||||
It's easiest to define <acronym>SQL</acronym>
|
||||
functions, so we'll start by discussing those.
|
||||
Most of the concepts presented for <acronym>SQL</acronym> functions
|
||||
will carry over to the other types of functions.
|
||||
@ -64,12 +64,12 @@ $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.82 2004/05/10 22:44:43 tgl Exp $
|
||||
|
||||
<para>
|
||||
Throughout this chapter, it can be useful to look at the reference
|
||||
page of the <command>CREATE FUNCTION</command> command to
|
||||
understand the examples better.
|
||||
Some examples from this chapter
|
||||
can be found in <filename>funcs.sql</filename>
|
||||
and <filename>funcs.c</filename> in the <filename>src/tutorial</>
|
||||
directory in the <productname>PostgreSQL</productname> source distribution.
|
||||
page of the <xref linkend="sql-createfunction"> command to
|
||||
understand the examples better. Some examples from this chapter
|
||||
can be found in <filename>funcs.sql</filename> and
|
||||
<filename>funcs.c</filename> in the <filename>src/tutorial</>
|
||||
directory in the <productname>PostgreSQL</productname> source
|
||||
distribution.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
|
Reference in New Issue
Block a user