On 10 January 2014 00:36, Marko Tiikkaja <ma...@joh.to> wrote: > On 1/10/14, 1:20 AM, Merlin Moncure wrote: >> >> I'm piling on: it's not clear at all to me why you've special cased >> this to lower_bound=1. First of all, there are other reasons to check >> length than iteration. >
Yes, I agree. A length function that returned 0 for empty arrays would be far from useless. > > Can you point me to some examples? > The example I see all the time is code like if array_length(nodes, 1) < 5 then ... do something ... then you realise (or not as the case may be) that this doesn't work for empty arrays, and have to remember to wrap it in a coalesce call. Simply being able to write if cardinality(nodes) < 5 then ... do something ... is not just shorter, easier to type and easier to read, it is far less likely to be the source of subtle bugs. Regards, Dean -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers