public inbox for [email protected]
help / color / mirror / Atom feedFrom: Erwin Brandstetter <[email protected]>
To: pgsql-docs <[email protected]>
Subject: count() counts ROW values that are NULL
Date: Fri, 18 Mar 2022 21:58:15 +0100
Message-ID: <CAGHENJ6fxanftiWOf9-ZJKA4bQ5v97YH0YWzDKfv6Mvw8ZPtkg@mail.gmail.com> (raw)
https://www.postgresql.org/docs/current/functions-aggregate.html#FUNCTIONS-AGGREGATE-TABLE
The manual says:
count ( "any" ) → bigint
>
> Computes the number of input rows in which the input value is not null.
>
But ROW values or composite types that "are null" are counted, anyway. See:
*db<>fiddle [here](
https://dbfiddle.uk/?rdbms=postgres_14&fiddle=7364f3f582322ac687b39c677826a074)*
Feels like a bug, but I cannot imagine how this would have slipped
everybody's attention for so long. It should at least be documented. Maybe:
Computes the number of input rows in which the input value is not a plain
NULL value. (Composite or ROW values count in any case - even if value IS
NULL evaluates to true.)
Regards
Erwin
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: count() counts ROW values that are NULL
In-Reply-To: <CAGHENJ6fxanftiWOf9-ZJKA4bQ5v97YH0YWzDKfv6Mvw8ZPtkg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox