mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
sum() on int2 and int4 columns now uses an int8, not numeric, accumulator
for speed reasons; its result type also changes to int8. avg() on these datatypes now accumulates the running sum in int8 for speed; but we still deliver the final result as numeric, so that fractional accuracy is preserved. count() now counts and returns in int8, not int4. I am a little nervous about this possibly breaking users' code, but there didn't seem to be a strong sentiment for avoiding the problem. If we get complaints during beta, we can change count back to int4 and add a "count8" aggregate. For that matter, users can do it for themselves with a simple CREATE AGGREGATE command; the int4inc function is still present, so no C hacking is needed. Also added max() and min() aggregates for OID that do proper unsigned comparison, instead of piggybacking on int4 aggregates. initdb forced.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.64 2001/07/11 22:14:01 momjian Exp $ -->
|
||||
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.65 2001/08/14 22:21:58 tgl Exp $ -->
|
||||
|
||||
<chapter id="functions">
|
||||
<title>Functions and Operators</title>
|
||||
@ -3768,7 +3768,7 @@ SELECT NULLIF(value, '(none)') ...
|
||||
<row>
|
||||
<entry>COUNT(*)</entry>
|
||||
<entry>number of input values</entry>
|
||||
<entry>The return value is of type <type>integer</type>.</entry>
|
||||
<entry>The return value is of type <type>bigint</type>.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
@ -3777,7 +3777,7 @@ SELECT NULLIF(value, '(none)') ...
|
||||
Counts the input values for which the value of <replaceable
|
||||
class="parameter">expression</replaceable> is not NULL.
|
||||
</entry>
|
||||
<entry></entry>
|
||||
<entry>The return value is of type <type>bigint</type>.</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
@ -3822,7 +3822,9 @@ SELECT NULLIF(value, '(none)') ...
|
||||
<type>smallint</type>, <type>integer</type>,
|
||||
<type>bigint</type>, <type>real</type>, <type>double
|
||||
precision</type>, <type>numeric</type>, <type>interval</type>.
|
||||
The result is of type <type>numeric</type> for any integer type
|
||||
The result is of type <type>bigint</type> for <type>smallint</type>
|
||||
or <type>integer</type> input, <type>numeric</type> for
|
||||
<type>bigint</type>
|
||||
input, <type>double precision</type> for floating point input,
|
||||
otherwise the same as the input data type.
|
||||
</entry>
|
||||
@ -3836,7 +3838,8 @@ SELECT NULLIF(value, '(none)') ...
|
||||
<primary>variance</primary>
|
||||
</indexterm>
|
||||
The variance is the square of the standard deviation. The
|
||||
supported data types are the same.
|
||||
supported data types and result types are the same as for
|
||||
standard deviation.
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
@ -3848,7 +3851,8 @@ SELECT NULLIF(value, '(none)') ...
|
||||
It should be noted that except for <function>COUNT</function>,
|
||||
these functions return NULL when no rows are selected. In
|
||||
particular, <function>SUM</function> of no rows returns NULL, not
|
||||
zero as one might expect.
|
||||
zero as one might expect. <function>COALESCE</function> may be
|
||||
used to substitute zero for NULL when necessary.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
Reference in New Issue
Block a user