intarray: return empty zero-dimensional array for an empty array
authorBruce Momjian <[email protected]>
Sat, 7 Sep 2013 15:44:33 +0000 (11:44 -0400)
committerBruce Momjian <[email protected]>
Sat, 7 Sep 2013 15:44:33 +0000 (11:44 -0400)
Previously a one-dimensional empty array was returned, but its text
representation matched a zero-dimensional array, and there is no way to
dump/reload a one-dimensional empty array.

BACKWARD INCOMPATIBILITY

Per report from elein

contrib/intarray/_int_tool.c

index 863557672ee33e612b1a8780f8bb8df1cdbb7a20..fc462b20766054cff68fb6e0b345db58a77eacc8 100644 (file)
@@ -246,6 +246,13 @@ resize_intArrayType(ArrayType *a, int num)
        int                     nbytes = ARR_DATA_OFFSET(a) + sizeof(int) * num;
        int                     i;
 
+       /* if no elements, return a zero-dimensional array */
+       if (num == 0)
+       {
+               ARR_NDIM(a) = 0;
+               return a;
+       }
+
        if (num == ARRNELEMS(a))
                return a;