Add bit_count SQL function
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 23 Mar 2021 07:45:51 +0000 (08:45 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 23 Mar 2021 09:13:58 +0000 (10:13 +0100)
commita6715af1e72da289474011be1e2d536f991eda34
tree48ae8ef2c5c858baf43611b8a65c4ec22cbe47bf
parent5aed6a1fc214913de9ac69c1717dc64a2483e16d
Add bit_count SQL function

This function for bit and bytea counts the set bits in the bit or byte
string.  Internally, we use the existing popcount functionality.

For the name, after some discussion, we settled on bit_count, which
also exists with this meaning in MySQL, Java, and Python.

Author: David Fetter <david@fetter.org>
Discussion: https://www.postgresql.org/message-id/flat/20201230105535.GJ13234@fetter.org
doc/src/sgml/func.sgml
src/backend/utils/adt/varbit.c
src/backend/utils/adt/varlena.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/test/regress/expected/bit.out
src/test/regress/expected/strings.out
src/test/regress/sql/bit.sql
src/test/regress/sql/strings.sql