Commit 608d843e authored by Tom Lane's avatar Tom Lane

Array slice extraction should produce a result array with index lower

bounds of 1, not the lower bound subscripts of the original slice.
Per bug report from Andre Holzner, 1-Feb-02.
parent 1aac2c85
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.74 2002/03/01 22:17:10 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.75 2002/03/02 00:34:24 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -839,7 +839,8 @@ array_get_slice(ArrayType *array, ...@@ -839,7 +839,8 @@ array_get_slice(ArrayType *array,
int i, int i,
ndim, ndim,
*dim, *dim,
*lb; *lb,
*newlb;
int fixedDim[1], int fixedDim[1],
fixedLb[1]; fixedLb[1];
char *arraydataptr; char *arraydataptr;
...@@ -911,7 +912,14 @@ array_get_slice(ArrayType *array, ...@@ -911,7 +912,14 @@ array_get_slice(ArrayType *array,
newarray->ndim = ndim; newarray->ndim = ndim;
newarray->flags = 0; newarray->flags = 0;
memcpy(ARR_DIMS(newarray), span, ndim * sizeof(int)); memcpy(ARR_DIMS(newarray), span, ndim * sizeof(int));
memcpy(ARR_LBOUND(newarray), lowerIndx, ndim * sizeof(int)); /*
* Lower bounds of the new array are set to 1. Formerly (before 7.3)
* we copied the given lowerIndx values ... but that seems confusing.
*/
newlb = ARR_LBOUND(newarray);
for (i = 0; i < ndim; i++)
newlb[i] = 1;
array_extract_slice(ndim, dim, lb, arraydataptr, elmlen, array_extract_slice(ndim, dim, lb, arraydataptr, elmlen,
lowerIndx, upperIndx, ARR_DATA_PTR(newarray)); lowerIndx, upperIndx, ARR_DATA_PTR(newarray));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment