Yury Zhuravlev <u.zhuravlev@postgrespro.ru> writes:
> New patch version in attachment.
I've committed this with a number of revisions, mostly but not entirely
cosmetic. Worthy of note:
* I did not like the way you were inserting the replacement subscript
values:
+ arrays = (AnyArrayType *)DatumGetArrayTypeP(array_source);
+ indexexpr = AARR_LBOUND(arrays)[i] + AARR_DIMS(arrays)[i] - 1;
If the source array is toasted, this causes an extra detoast operation
for *each* omitted subscript. That could be pretty high overhead for
a large array. The best way to avoid that is to postpone the actual
substitution of the replacement subscript values into array_get_slice
and array_set_slice; which complicates their APIs a bit more, but those
were pretty long argument lists already.
* Having done that, there was no very good reason for the blanket
prohibition on using omitted subscripts in the slice-set case. We only
really need to fail if we're constructing the array from scratch, when
we don't have any existing subscript limits to substitute.
regards, tom lane