Re: Array functions, array_length behavior given an empty array

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: oleg(dot)rekin(at)gmail(dot)com, Pg Docs <pgsql-docs(at)lists(dot)postgresql(dot)org>
Subject: Re: Array functions, array_length behavior given an empty array
Date: 2021-11-08 16:38:49
Message-ID: CAFj8pRBvjNxKFxg0b8xMbdtpdmxequ68B+OjobDjp9V+Y7Yhdg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Hi

po 8. 11. 2021 v 13:48 odesílatel PG Doc comments form <
noreply(at)postgresql(dot)org> napsal:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/13/functions-array.html
> Description:
>
> For whom it may concern,
>
> I'd like to propose an extension for `array_length` function description.
>
> Currently, it does not cover the case of an empty array:
>
> https://www.postgresql.org/docs/13/functions-array.html
> Table 9.52. Array Functions. Row 5
>
> The description reads as `Returns the length of the requested array
> dimension.`
>
> For me, an expected result for an empty array would be `0`, but it is
> `NULL`.
> Tested on `PostgreSQL 13.4` with query `SELECT
> ARRAY_LENGTH(ARRAY[]::CHARACTER VARYING[],1);`
>
> I believe, such case deserves to be mentioned in the description and/or in
> examples.
>

you can read related discussion
https://pgsql-hackers.postgresql.narkive.com/lZJQ64dp/array-length-anyarray

Use instead function cardinality

Regards

Pavel Stehule

>
> With best regards,
> Oleg Rekin
>

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message David G. Johnston 2021-11-08 17:11:58 Re: Array functions, array_length behavior given an empty array
Previous Message PG Doc comments form 2021-11-08 11:01:51 Array functions, array_length behavior given an empty array