public inbox for [email protected]
help / color / mirror / Atom feedFrom: Marcos Pegoraro <[email protected]>
To: Postgres General <[email protected]>
Subject: Length returns NULL ?
Date: Wed, 5 Jun 2024 14:50:26 -0300
Message-ID: <CAB-JLwZmKYDT=0WSkvKHLqaejxWoMjBok3YjUtAtM1U8=N__0g@mail.gmail.com> (raw)
There are some functions called ...length, but only array_length returns
NULL on empty array, why ?
select array_length('{}'::text[],1), -->NULL
jsonb_array_length('[]'), -->0
bit_length(''), -->0
octet_length(''), -->0
length(''), -->0
char_length(''), -->0
length(B''); -->0
I know, it is documented, but the question is, why does it work differently
?
array_length ( anyarray, integer ) → integer
Returns the length of the requested array dimension. (Produces NULL instead
of 0 for empty or missing array dimensions.)
array_length(array[1,2,3], 1) → 3
array_length(array[]::int[], 1) → NULL
array_length(array['text'], 2) → NULL
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: Length returns NULL ?
In-Reply-To: <CAB-JLwZmKYDT=0WSkvKHLqaejxWoMjBok3YjUtAtM1U8=N__0g@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