postgres.git / summary / log / commit / refs

commit    c155f654b4f755b4111bd9adb60559fe22526a10
Author:   Bruce Momjian <bruce@momjian.us>
Date:     Sat Sep 07 15:44:33 2013 +0000
First released in: 9.4.0

    intarray:  return empty zero-dimensional array for an empty array
    
    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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/intarray/_int_tool.c b/contrib/intarray/_int_tool.c index 863557672ee..fc462b20766 100644 --- a/contrib/intarray/_int_tool.c +++ b/contrib/intarray/_int_tool.c @@ -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; [parent: b8104730c8ea]