Skip to content

Commit 75be9e1

Browse files
authored
Merge pull request #210 from denizzzka/array_lbound
lbound can be any value if array slice was returned
2 parents 2cf9f45 + dd94549 commit 75be9e1

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/dpq2/result.d

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ struct ArrayProperties
503503
{
504504
OidType OID = OidType.Undefined; /// Oid
505505
int[] dimsSize; /// Dimensions sizes info
506+
int[] leftBounds; /// Left bounds of each dimension. Can differ from 1 for slices. Useful to restore coordinates inside of a slice.
506507
size_t nElems; /// Total elements
507508
package size_t dataOffset;
508509

@@ -540,26 +541,21 @@ struct ArrayProperties
540541
dataOffset = ArrayHeader_net.sizeof + Dim_net.sizeof * nDims;
541542

542543
dimsSize = new int[nDims];
544+
leftBounds = new int[nDims];
543545

544546
// Recognize dimensions of array
545547
for( auto i = 0; i < nDims; ++i )
546548
{
547549
Dim_net* d = (cast(Dim_net*) (h + 1)) + i;
548550

549551
const dim_size = bigEndianToNative!int(d.dim_size);
550-
const lbound = bigEndianToNative!int(d.lbound);
552+
leftBounds[i] = bigEndianToNative!int(d.lbound);
551553

552554
if(dim_size < 0)
553555
throw new ValueConvException(ConvExceptionType.CORRUPTED_ARRAY,
554556
"Dimension size is negative ("~to!string(dim_size)~")",
555557
);
556558

557-
// FIXME: What is lbound in postgresql array reply?
558-
if(!(lbound == 1))
559-
throw new ValueConvException(ConvExceptionType.CORRUPTED_ARRAY,
560-
"Please report if you came across this error! lbound=="~to!string(lbound),
561-
);
562-
563559
dimsSize[i] = dim_size;
564560

565561
if(i == 0) // first dimension

0 commit comments

Comments
 (0)