From 0079547bcbedff2a653204571c3cda22c35907d4 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Fri, 14 May 2004 21:42:30 +0000 Subject: 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. --- doc/src/sgml/errcodes.sgml | 7 ++++++- doc/src/sgml/func.sgml | 12 +++++++++++- doc/src/sgml/xfunc.sgml | 16 ++++++++-------- 3 files changed, 25 insertions(+), 10 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/errcodes.sgml b/doc/src/sgml/errcodes.sgml index 2f211f462e8..295c41ffad8 100644 --- a/doc/src/sgml/errcodes.sgml +++ b/doc/src/sgml/errcodes.sgml @@ -1,4 +1,4 @@ - + <productname>PostgreSQL</productname> Error Codes @@ -310,6 +310,11 @@ INTERVAL FIELD OVERFLOW + +2201G +INVALID ARGUMENT FOR WIDTH BUCKET FUNCTION + + 22018 INVALID CHARACTER VALUE FOR CAST diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 1dde8b59a3c..6fd36fe77bc 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,5 +1,5 @@ @@ -751,6 +751,16 @@ PostgreSQL documentation 42.43 + + width_bucket(op numeric, b1 numeric, b2 numeric, count integer) + integer + return the bucket to which operand would + be assigned in an equidepth histogram with count + buckets, an upper bound of b1, and a lower bound + of b2 + width_bucket(5.35, 0.024, 10.06, 5) + 3 + diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index a3c24a1c4c1..ed2a502c69e 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -1,5 +1,5 @@ @@ -56,7 +56,7 @@ $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.82 2004/05/10 22:44:43 tgl Exp $ - It's easiest to define SQL + It's easiest to define SQL functions, so we'll start by discussing those. Most of the concepts presented for SQL 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 $ Throughout this chapter, it can be useful to look at the reference - page of the CREATE FUNCTION command to - understand the examples better. - Some examples from this chapter - can be found in funcs.sql - and funcs.c in the src/tutorial - directory in the PostgreSQL source distribution. + page of the command to + understand the examples better. Some examples from this chapter + can be found in funcs.sql and + funcs.c in the src/tutorial + directory in the PostgreSQL source + distribution. -- cgit v1.2.3