Array behavior

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Array behavior
Date: 2002-11-26 16:55:02
Message-ID: 20021126165502.BE94A103C7@polaris.pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have an application that seems an ideal candidate for arrays. A table will
contain a unique key and general info (timestamp, origin, etc.) along with
some collected data (data text[]).

The data collected in a single sample could contain zero or more elements
(strings of up to 32 characters), the number of elements is not known in
advance and, items (elements) can be skipped (though for analysis and data
delivery purposes data[3] in one tuple will always correspond to data[3] in
another tuple).

The current (7.2.3) behavior appears to allow me to insert items with one or
more array elements and query on an element (say data[15]) without worrying
that some of the data may only have 3 elements (Postgres returns an empty
string for data[15] in that case). This works well for me.

Question 1: Is this behavior explicitly documented somewhere and can I expect
this to continue to be the behavior of arrays in the future? I have a strong
preference to write code to specifications and not to "something that I
discovered that turns out to be a future fix on someone's todo list".

Question 2: Is there a Postgres function that returns the number of elements
in an array (or another simple method of determining that information)?

Cheers,
Steve

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-11-26 17:04:33 Re: pgsql-function called twice in the same second ->
Previous Message jose antonio leo 2002-11-26 16:25:20 Re: the "SORT" late very much.