diff options
author | Bruce Momjian <bruce@momjian.us> | 2013-09-07 11:44:33 -0400 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2013-09-07 11:44:33 -0400 |
commit | c155f654b4f755b4111bd9adb60559fe22526a10 (patch) | |
tree | cda3d17422b556034e8a9f28241c933a593a7d98 | |
parent | b8104730c8eae1f81ccbc8673bbd2a3566e660ae (diff) | |
download | postgresql-c155f654b4f755b4111bd9adb60559fe22526a10.tar.gz |
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
-rw-r--r-- | contrib/intarray/_int_tool.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/intarray/_int_tool.c b/contrib/intarray/_int_tool.c index 863557672e..fc462b2076 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; |