pgsql: Add bit_count SQL function

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add bit_count SQL function
Date: 2021-03-23 09:39:01
Message-ID: E1lOdV7-0003lB-Pb@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)fetter(dot)org>
Discussion: https://www.postgresql.org/message-id/flat/20201230105535(dot)GJ13234(at)fetter(dot)org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a6715af1e72da289474011be1e2d536f991eda34

Modified Files
--------------
doc/src/sgml/func.sgml | 40 +++++++++++++++++++++++++++++++++++
src/backend/utils/adt/varbit.c | 14 ++++++++++++
src/backend/utils/adt/varlena.c | 11 ++++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 6 ++++++
src/test/regress/expected/bit.out | 13 ++++++++++++
src/test/regress/expected/strings.out | 6 ++++++
src/test/regress/sql/bit.sql | 4 ++++
src/test/regress/sql/strings.sql | 2 ++
9 files changed, 97 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2021-03-23 10:51:01 pgsql: pgcrypto: Check for error return of px_cipher_decrypt()
Previous Message Peter Geoghegan 2021-03-23 06:34:47 Re: pgsql: Add per-index stats information in verbose logs of autovacuum