Please explain to me this behavior.
This SQL finds elements where ids (type is array::bigint
) is empty.
SELECT * FROM rises WHERE ids = '{}'
-- finds, e.g., 9 rows
This SQL finds no rows:
SELECT * FROM rises WHERE array_length(ids, 1) = 0
--finds always 0 rows
But this SQL can find non-empty arrays
SELECT * FROM rises WHERE array_length(ids, 1) > 0
--finds, e.g., 15 rows
Initialization:
CREATE TABLE rises(
id bigserial,
d1 bigint DEFAULT 0,
ids bigint[] DEFAULT '{}',
PRIMARY KEY (id));
Why array_length
can find non-empty arrays but it doesn't work for empty arrays?