Rajesh Kumar Mallah <[EMAIL PROTECTED]> 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
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match