1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

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.
This commit is contained in:
Tom Lane
2002-03-02 00:34:24 +00:00
parent 1aac2c852a
commit 608d843e61

View File

@ -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,
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,
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));