Skip to content

Commit 3048450

Browse files
committed
Use array_contains_nulls instead of ARR_HASNULL on user-supplied arrays.
This applies the fix for bug #5784 to remaining places where we wish to reject nulls in user-supplied arrays. In all these places, there's no reason not to allow a null bitmap to be present, so long as none of the current elements are actually null. I did not change some other places where we are looking at system catalog entries or aggregate transition values, as the presence of a null bitmap in such an array would be suspicious.
1 parent 361418b commit 3048450

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

contrib/cube/cube.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ cube_a_f8_f8(PG_FUNCTION_ARGS)
187187
double *dur,
188188
*dll;
189189

190-
if (ARR_HASNULL(ur) || ARR_HASNULL(ll))
190+
if (array_contains_nulls(ur) || array_contains_nulls(ll))
191191
ereport(ERROR,
192192
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
193193
errmsg("cannot work with arrays containing NULLs")));
@@ -228,7 +228,7 @@ cube_a_f8(PG_FUNCTION_ARGS)
228228
int size;
229229
double *dur;
230230

231-
if (ARR_HASNULL(ur))
231+
if (array_contains_nulls(ur))
232232
ereport(ERROR,
233233
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
234234
errmsg("cannot work with arrays containing NULLs")));
@@ -262,7 +262,7 @@ cube_subset(PG_FUNCTION_ARGS)
262262
i;
263263
int *dx;
264264

265-
if (ARR_HASNULL(idx))
265+
if (array_contains_nulls(idx))
266266
ereport(ERROR,
267267
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
268268
errmsg("cannot work with arrays containing NULLs")));

contrib/ltree/_ltree_gist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
9292
ereport(ERROR,
9393
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
9494
errmsg("array must be one-dimensional")));
95-
if (ARR_HASNULL(val))
95+
if (array_contains_nulls(val))
9696
ereport(ERROR,
9797
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
9898
errmsg("array must not contain nulls")));
@@ -538,7 +538,7 @@ _arrq_cons(ltree_gist *key, ArrayType *_query)
538538
ereport(ERROR,
539539
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
540540
errmsg("array must be one-dimensional")));
541-
if (ARR_HASNULL(_query))
541+
if (array_contains_nulls(_query))
542542
ereport(ERROR,
543543
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
544544
errmsg("array must not contain nulls")));

contrib/ltree/_ltree_op.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ array_iterator(ArrayType *la, PGCALL2 callback, void *param, ltree **found)
5252
ereport(ERROR,
5353
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
5454
errmsg("array must be one-dimensional")));
55-
if (ARR_HASNULL(la))
55+
if (array_contains_nulls(la))
5656
ereport(ERROR,
5757
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
5858
errmsg("array must not contain nulls")));
@@ -152,7 +152,7 @@ _lt_q_regex(PG_FUNCTION_ARGS)
152152
ereport(ERROR,
153153
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
154154
errmsg("array must be one-dimensional")));
155-
if (ARR_HASNULL(_query))
155+
if (array_contains_nulls(_query))
156156
ereport(ERROR,
157157
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
158158
errmsg("array must not contain nulls")));
@@ -310,7 +310,7 @@ _lca(PG_FUNCTION_ARGS)
310310
ereport(ERROR,
311311
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
312312
errmsg("array must be one-dimensional")));
313-
if (ARR_HASNULL(la))
313+
if (array_contains_nulls(la))
314314
ereport(ERROR,
315315
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
316316
errmsg("array must not contain nulls")));

contrib/ltree/lquery_op.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ lt_q_regex(PG_FUNCTION_ARGS)
348348
ereport(ERROR,
349349
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
350350
errmsg("array must be one-dimensional")));
351-
if (ARR_HASNULL(_query))
351+
if (array_contains_nulls(_query))
352352
ereport(ERROR,
353353
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
354354
errmsg("array must not contain nulls")));

contrib/ltree/ltree_gist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ arrq_cons(ltree_gist *key, ArrayType *_query)
606606
ereport(ERROR,
607607
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
608608
errmsg("array must be one-dimensional")));
609-
if (ARR_HASNULL(_query))
609+
if (array_contains_nulls(_query))
610610
ereport(ERROR,
611611
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
612612
errmsg("array must not contain nulls")));

src/backend/utils/adt/arrayfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4700,7 +4700,7 @@ array_fill_internal(ArrayType *dims, ArrayType *lbs,
47004700
errmsg("wrong range of array subscripts"),
47014701
errdetail("Lower bound of dimension array must be one.")));
47024702

4703-
if (ARR_HASNULL(dims))
4703+
if (array_contains_nulls(dims))
47044704
ereport(ERROR,
47054705
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
47064706
errmsg("dimension values cannot be null")));
@@ -4732,7 +4732,7 @@ array_fill_internal(ArrayType *dims, ArrayType *lbs,
47324732
errmsg("wrong range of array subscripts"),
47334733
errdetail("Lower bound of dimension array must be one.")));
47344734

4735-
if (ARR_HASNULL(lbs))
4735+
if (array_contains_nulls(lbs))
47364736
ereport(ERROR,
47374737
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
47384738
errmsg("dimension values cannot be null")));

src/backend/utils/adt/arrayutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ ArrayGetIntegerTypmods(ArrayType *arr, int *n)
213213
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
214214
errmsg("typmod array must be one-dimensional")));
215215

216-
if (ARR_HASNULL(arr))
216+
if (array_contains_nulls(arr))
217217
ereport(ERROR,
218218
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
219219
errmsg("typmod array must not contain nulls")));

src/backend/utils/adt/tsrank.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ getWeights(ArrayType *win)
408408
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
409409
errmsg("array of weight is too short")));
410410

411-
if (ARR_HASNULL(win))
411+
if (array_contains_nulls(win))
412412
ereport(ERROR,
413413
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
414414
errmsg("array of weight must not contain nulls")));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy