Re: array_length(anyarray)
От
Florian Pflug
Тема
Re: array_length(anyarray)
Дата
Msg-id
A694F58D-3B48-478A-8694-B4DA0109517E@phlo.org
Ответ на
Re: array_length(anyarray) (Jim Nasby)
Список
Дерево обсуждения
array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) David Fetter <david@fetter.org>
Re: array_length(anyarray) Pavel Stehule <pavel.stehule@gmail.com>
Re: array_length(anyarray) Dean Rasheed <dean.a.rasheed@gmail.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Dean Rasheed <dean.a.rasheed@gmail.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Dean Rasheed <dean.a.rasheed@gmail.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Dean Rasheed <dean.a.rasheed@gmail.com>
Re: array_length(anyarray) Dean Rasheed <dean.a.rasheed@gmail.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Pavel Stehule <pavel.stehule@gmail.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Pavel Stehule <pavel.stehule@gmail.com>
Re: array_length(anyarray) Robert Haas <robertmhaas@gmail.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Pavel Stehule <pavel.stehule@gmail.com>
Re: array_length(anyarray) Florian Pflug <fgp@phlo.org>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Jim Nasby <jim@nasby.net>
Re: array_length(anyarray) Florian Pflug <fgp@phlo.org>
Re: array_length(anyarray) Merlin Moncure <mmoncure@gmail.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Dean Rasheed <dean.a.rasheed@gmail.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Merlin Moncure <mmoncure@gmail.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Merlin Moncure <mmoncure@gmail.com>
Re: array_length(anyarray) Florian Pflug <fgp@phlo.org>
Re: array_length(anyarray) Merlin Moncure <mmoncure@gmail.com>
Re: array_length(anyarray) Florian Pflug <fgp@phlo.org>
Re: array_length(anyarray) Andrew Dunstan <andrew@dunslane.net>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) Andrew Dunstan <andrew@dunslane.net>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
Re: array_length(anyarray) David Johnston <polobo@yahoo.com>
Re: array_length(anyarray) Marko Tiikkaja <marko@joh.to>
On Jan9, 2014, at 23:26 , Jim Nasby wrote: > On 1/9/14, 11:08 AM, Marko Tiikkaja wrote: >> On 1/9/14 5:44 PM, Florian Pflug wrote: >>> On Jan9, 2014, at 14:57 , Dean Rasheed wrote: >>>> On 19 December 2013 08:05, Pavel Stehule 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(). >> >> Problem is, if you're operating on an array which could have a lower bound that isn't 1, why would you look at the length in the first place? You can't access any elements by index, you'd need to look at array_lower(). You can't iterate over the array by index, you'd need to do array_lower() .. array_lower() + array_length(), which doesn't make sense. And then there's the myriad of stuff you can do with unnest() without actually having to look at the length. Same goes for multi-dimensional arrays: you have even less things you can do there with only a length. >> >> So if we give up these constraints, we also make this function completely useless. > > I'm generally opposed to creating code that doesn't support the full featureset of something (in this case, array_lower()<>1). But in this case I hope we can all agree that allowing the user to set an arbitrary array lower bound was an enormous mistake. No doubt. > While we might not be able to ever completely remove that behavior, I find the idea of throwing an error to be highly enticing. > > Plus, as Marko said, this function is pretty useless for non-1-based arrays. That I doubt, but... > I do agree that the name is probably too generic for this though. this one is actually my main complaint. The name needs to very clearly mark such a function as dealing only with a subset of all possible arrays. Otherwise we'll just add to the confusion, not avoid it. best regards, Florian Pflug
В списке pgsql-hackers по дате отправления