Array behavior

Поиск
Список
Период
Сортировка
От Steve Crawford
Тема Array behavior
Дата
Msg-id 20021126165502.BE94A103C7@polaris.pinpointresearch.com
обсуждение исходный текст
Список 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

В списке pgsql-general по дате отправления:

Предыдущее
От: "scott.marlowe"
Дата:
Сообщение: Re: Migrating DAta from MSSQL to postgre
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: pgsql-function called twice in the same second ->