git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b810473)
intarray: return empty zero-dimensional array for an empty array
Sat, 7 Sep 2013 15:44:33 +0000 (11:44 -0400)
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


diff --git a/contrib/intarray/_int_tool.c b/contrib/intarray/_int_tool.c
index 863557672ee33e612b1a8780f8bb8df1cdbb7a20..fc462b20766054cff68fb6e0b345db58a77eacc8 100644 (file)
--- 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;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /