Skip to content

Commit 608d843

Browse files
committed
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.
1 parent 1aac2c8 commit 608d843

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/backend/utils/adt/arrayfuncs.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.74 2002/03/01 22:17:10 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.75 2002/03/02 00:34:24 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -839,7 +839,8 @@ array_get_slice(ArrayType *array,
839839
int i,
840840
ndim,
841841
*dim,
842-
*lb;
842+
*lb,
843+
*newlb;
843844
int fixedDim[1],
844845
fixedLb[1];
845846
char *arraydataptr;
@@ -911,7 +912,14 @@ array_get_slice(ArrayType *array,
911912
newarray->ndim = ndim;
912913
newarray->flags = 0;
913914
memcpy(ARR_DIMS(newarray), span, ndim * sizeof(int));
914-
memcpy(ARR_LBOUND(newarray), lowerIndx, ndim * sizeof(int));
915+
/*
916+
* Lower bounds of the new array are set to 1. Formerly (before 7.3)
917+
* we copied the given lowerIndx values ... but that seems confusing.
918+
*/
919+
newlb = ARR_LBOUND(newarray);
920+
for (i = 0; i < ndim; i++)
921+
newlb[i] = 1;
922+
915923
array_extract_slice(ndim, dim, lb, arraydataptr, elmlen,
916924
lowerIndx, upperIndx, ARR_DATA_PTR(newarray));
917925

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy