Re: array_lower /array_prepend doubt

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: array_lower /array_prepend doubt
Дата
Msg-id 400EBEF0.6060005@joeconway.com
обсуждение исходный текст
Ответ на Re: array_lower /array_prepend doubt  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: array_lower /array_prepend doubt
Список pgsql-sql
Tom Lane wrote:
> Rajesh Kumar Mallah <mallah@trade-india.com> writes:
>>can anyone explain why
>> SELECT array_lower(array_prepend(0, ARRAY[1,2,3]), 1);
>>returns 0 not 1
> 
> Because array_prepend keeps the subscripts of the existing array
> elements the same.  This was discussed during development of the
> code, but I don't see anything in the documentation that mentions it.
> 

It could perhaps be added to the "Functions and Operators" page for 
arrays, but it is mentioned here:

http://www.postgresql.org/docs/current/static/arrays.html#AEN5183

"When a single element is pushed on to the beginning of a 
one-dimensional array, the result is an array with a lower bound 
subscript equal to the right-hand operand's lower bound subscript, minus 
one. When a single element is pushed on to the end of a one-dimensional 
array, the result is an array retaining the lower bound of the left-hand 
operand. For example:

SELECT array_dims(1 || ARRAY[2,3]);  array_dims ------------  [0:2] (1 row)
 SELECT array_dims(ARRAY[1,2] || 3);  array_dims ------------  [1:3] (1 row)
"

Joe



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: array_lower /array_prepend doubt
Следующее
От: Tom Lane
Дата:
Сообщение: Re: array_lower /array_prepend doubt