Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit25c0083

Browse files
committed
Add defenses against nulls-in-arrays to contrib/ltree. Possibly it'd
be useful to actually do something with nulls, rather than reject them,but I'll just close the hole for now.
1 parent1e9a1a7 commit25c0083

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

‎contrib/ltree/_ltree_gist.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ _ltree_compress(PG_FUNCTION_ARGS)
7676
ereport(ERROR,
7777
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
7878
errmsg("array must be one-dimensional")));
79+
if (ARR_HASNULL(val))
80+
ereport(ERROR,
81+
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
82+
errmsg("array must not contain nulls")));
7983

8084
key= (ltree_gist*)palloc(len);
8185
key->len=len;
@@ -518,6 +522,10 @@ _arrq_cons(ltree_gist * key, ArrayType *_query)
518522
ereport(ERROR,
519523
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
520524
errmsg("array must be one-dimensional")));
525+
if (ARR_HASNULL(_query))
526+
ereport(ERROR,
527+
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
528+
errmsg("array must not contain nulls")));
521529

522530
while (num>0)
523531
{

‎contrib/ltree/_ltree_op.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ array_iterator(ArrayType *la, PGCALL2 callback, void *param, ltree ** found)
4747
ereport(ERROR,
4848
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
4949
errmsg("array must be one-dimensional")));
50+
if (ARR_HASNULL(la))
51+
ereport(ERROR,
52+
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
53+
errmsg("array must not contain nulls")));
5054

5155
if (found)
5256
*found=NULL;
@@ -143,6 +147,10 @@ _lt_q_regex(PG_FUNCTION_ARGS)
143147
ereport(ERROR,
144148
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
145149
errmsg("array must be one-dimensional")));
150+
if (ARR_HASNULL(_query))
151+
ereport(ERROR,
152+
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
153+
errmsg("array must not contain nulls")));
146154

147155
while (num>0)
148156
{
@@ -293,6 +301,15 @@ _lca(PG_FUNCTION_ARGS)
293301
ltree**a,
294302
*res;
295303

304+
if (ARR_NDIM(la)!=1)
305+
ereport(ERROR,
306+
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
307+
errmsg("array must be one-dimensional")));
308+
if (ARR_HASNULL(la))
309+
ereport(ERROR,
310+
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
311+
errmsg("array must not contain nulls")));
312+
296313
a= (ltree**)palloc(sizeof(ltree*)*num);
297314
while (num>0)
298315
{

‎contrib/ltree/lquery_op.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ lt_q_regex(PG_FUNCTION_ARGS)
328328
ereport(ERROR,
329329
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
330330
errmsg("array must be one-dimensional")));
331+
if (ARR_HASNULL(_query))
332+
ereport(ERROR,
333+
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
334+
errmsg("array must not contain nulls")));
331335

332336
while (num>0)
333337
{

‎contrib/ltree/ltree_gist.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,10 @@ arrq_cons(ltree_gist * key, ArrayType *_query)
607607
ereport(ERROR,
608608
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
609609
errmsg("array must be one-dimensional")));
610+
if (ARR_HASNULL(_query))
611+
ereport(ERROR,
612+
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
613+
errmsg("array must not contain nulls")));
610614

611615
while (num>0)
612616
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp