Re: array_length(anyarray)
От | Florian Pflug |
---|---|
Тема | Re: array_length(anyarray) |
Дата | |
Msg-id | 938B40F2-5CB2-4740-A557-532E1090AC2E@phlo.org обсуждение исходный текст |
Ответ на | Re: array_length(anyarray) (Dean Rasheed <dean.a.rasheed@gmail.com>) |
Ответы |
Re: array_length(anyarray)
|
Список | pgsql-hackers |
On Jan9, 2014, at 14:57 , Dean Rasheed <dean.a.rasheed@gmail.com> wrote: > On 19 December 2013 08:05, Pavel Stehule <pavel.stehule@gmail.com> wrote: >> length should be irrelevant to fact so array starts from 1, 0 or anything >> else > > Yes, this should just return the number of elements, and 0 for an empty array. +1. Anything that complains about arrays whose lower bound isn't 1 really needs a *way* less generic name than array_length(). > > How it should behave for multi-dimensional arrays is less clear, but > I'd argue that it should return the total number of elements, i.e. > cardinality('{{1,2},{3,4}}'::int[][]) = 4. That would make it > consistent with the choices we've already made for unnest() and > ordinality: > - cardinality(foo) = (select count(*) from unnest(foo)). > - unnest with ordinality would always result in ordinals in the range > [1, cardinality]. +1 best regards, Florian Pflug
В списке pgsql-hackers по дате отправления: