From 8096fe45cee42ce02e602cbea08e969139a77455 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Wed, 26 May 2004 15:26:28 +0000 Subject: The added aggregates are: (1) boolean-and and boolean-or aggregates named bool_and and bool_or. they (SHOULD;-) correspond to standard sql every and some/any aggregates. they do not have the right name as there is a problem with the standard and the parser for some/any. Tom also think that the standard name is misleading because NULL are ignored. Also add 'every' aggregate. (2) bitwise integer aggregates named bit_and and bit_or for int2, int4, int8 and bit types. They are not standard, but I find them useful. I needed them once. The patches adds: - 2 new very short strict functions for boolean aggregates in src/backed/utils/adt/bool.c, src/include/utils/builtins.h and src/include/catalog/pg_proc.h - the new aggregates declared in src/include/catalog/pg_proc.h and src/include/catalog/pg_aggregate.h - some documentation and validation about these new aggregates. Fabien COELHO --- doc/src/sgml/func.sgml | 113 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index d95c5aa7527..3ead1346796 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,5 +1,5 @@ @@ -7553,6 +7553,76 @@ SELECT pg_type_is_visible('myschema.widget'::regtype); the average (arithmetic mean) of all input values + + + + bit_and + + bit_and(expression) + + + smallint, integer, bigint or + bit, + + + same as argument data type. + + the bitwise-and of all non-null input values, or null if empty + + + + + + + bit_or + + bit_or(expression) + + + smallint, integer, bigint or + bit, + + + same as argument data type. + + the bitwise-or of all non-null input values, or null if empty. + + + + + + + bool_and + + bool_and(expression) + + + bool + + + bool + + true if all input values are true, otherwise false. + Also known as bool_and. + + + + + + + bool_or + + bool_or(expression) + + + bool + + + bool + + true if at least one input value is true, otherwise false + + count(*) @@ -7570,6 +7640,24 @@ SELECT pg_type_is_visible('myschema.widget'::regtype); + + + + every + + every(expression) + + + bool + + + bool + + true if all input values are true, otherwise false. + Also known as bool_and. + + + max(expression) any numeric, string, or date/time type @@ -7660,6 +7748,29 @@ SELECT pg_type_is_visible('myschema.widget'::regtype); used to substitute zero for null when necessary. + + + ANY + + + SOME + + + Boolean aggregates bool_and and + bool_or correspond to standard SQL aggregates + every and any or + some. + As for any and some, + it seems that there is an ambiguity built into the standard syntax: + +SELECT b1 = ANY((SELECT b2 FROM t2 ...)) FROM t1 ...; + + Here ANY can be considered both as leading + to a subquery or as an aggregate if the select expression returns 1 row. + Thus the standard name cannot be given to these aggregates. + + + Users accustomed to working with other SQL database management -- cgit v1.2.3