Single-argument variant for array_length and friends? - Mailing list pgsql-hackers

From Brendan Jurd
Subject Single-argument variant for array_length and friends?
Date
Msg-id CADxJZo0QaLybPfdMHGbG0TVwCc8xUcRzxJ7_hjrDQ+=kKjR8bg@mail.gmail.com
Whole thread Raw
Responses Re: Single-argument variant for array_length and friends?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi hackers,

While I was working on my empty array patch I was frequently irritated
by the absence of an array_length(anyarray).  The same goes for
array_upper and array_lower.  Most of the time when I work with
arrays, they are 1-D, and it's inelegant to having to specify which
dimension I mean when there is only one to choose from.

The question I have (and would appreciate your input on) is how such
single-argument variants should behave when operating on an array with
multiple dimensions?

I see a few different options:

a) throw an error like "Dimension argument is required for multiple
dimension arrays"

b) assume the user means the final (innermost) dimension

c) assume the user means the first (outermost) dimension

My inclination is towards (c) but I don't use multi-D arrays in
postgres in the field.  Opinions?

Cheers,
BJ



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: find libxml2 using pkg-config
Next
From: Michael Paquier
Date:
Subject: Re: Ignore invalid indexes in pg_dump