Single-argument variant for array_length and friends?

From: Brendan Jurd <direvus(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Single-argument variant for array_length and friends?
Date: 2013-03-21 00:38:30
Message-ID: CADxJZo0QaLybPfdMHGbG0TVwCc8xUcRzxJ7_hjrDQ+=kKjR8bg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2013-03-21 00:51:39 Re: Ignore invalid indexes in pg_dump
Previous Message Noah Misch 2013-03-21 00:32:24 Re: find libxml2 using pkg-config