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

Commit29d2f86

Browse files
committed
Allow zero-dimensional (ie, empty) arrays in contrib/ltree operations.
The main motivation for changing this is bug #4921, in which it's pointed outthat it's no longer safe to apply ltree operations to the result ofARRAY(SELECT ...) if the sub-select might return no rows. Before 8.3,the ARRAY() construct would return NULL, which might or might not be helpfulbut at least it wouldn't result in an error. Now it returns an empty arraywhich results in a failure for no good reason, since the ltree operationsare all perfectly capable of dealing with zero-element arrays.As far as I can find, these ltree functions are the only places where zeroarray dimensionality is rejected unnecessarily.Back-patch to 8.3 to prevent behavioral regression of queries that workedin older releases.
1 parent673fb4d commit29d2f86

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

‎contrib/ltree/_ltree_gist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/ltree/_ltree_gist.c,v 1.26 2009/06/11 14:48:51 momjian Exp $
2+
* $PostgreSQL: pgsql/contrib/ltree/_ltree_gist.c,v 1.27 2010/02/24 18:02:24 tgl Exp $
33
*
44
*
55
* GiST support for ltree[]
@@ -88,7 +88,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
8888
intnum=ArrayGetNItems(ARR_NDIM(val),ARR_DIMS(val));
8989
ltree*item= (ltree*)ARR_DATA_PTR(val);
9090

91-
if (ARR_NDIM(val)!=1)
91+
if (ARR_NDIM(val)>1)
9292
ereport(ERROR,
9393
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
9494
errmsg("array must be one-dimensional")));
@@ -534,7 +534,7 @@ _arrq_cons(ltree_gist *key, ArrayType *_query)
534534
lquery*query= (lquery*)ARR_DATA_PTR(_query);
535535
intnum=ArrayGetNItems(ARR_NDIM(_query),ARR_DIMS(_query));
536536

537-
if (ARR_NDIM(_query)!=1)
537+
if (ARR_NDIM(_query)>1)
538538
ereport(ERROR,
539539
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
540540
errmsg("array must be one-dimensional")));

‎contrib/ltree/_ltree_op.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/ltree/_ltree_op.c,v 1.13 2009/06/11 14:48:51 momjian Exp $
2+
* $PostgreSQL: pgsql/contrib/ltree/_ltree_op.c,v 1.14 2010/02/24 18:02:24 tgl Exp $
33
*
44
*
55
* op function for ltree[]
@@ -48,7 +48,7 @@ array_iterator(ArrayType *la, PGCALL2 callback, void *param, ltree **found)
4848
intnum=ArrayGetNItems(ARR_NDIM(la),ARR_DIMS(la));
4949
ltree*item= (ltree*)ARR_DATA_PTR(la);
5050

51-
if (ARR_NDIM(la)!=1)
51+
if (ARR_NDIM(la)>1)
5252
ereport(ERROR,
5353
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
5454
errmsg("array must be one-dimensional")));
@@ -148,7 +148,7 @@ _lt_q_regex(PG_FUNCTION_ARGS)
148148
boolres= false;
149149
intnum=ArrayGetNItems(ARR_NDIM(_query),ARR_DIMS(_query));
150150

151-
if (ARR_NDIM(_query)!=1)
151+
if (ARR_NDIM(_query)>1)
152152
ereport(ERROR,
153153
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
154154
errmsg("array must be one-dimensional")));
@@ -306,7 +306,7 @@ _lca(PG_FUNCTION_ARGS)
306306
ltree**a,
307307
*res;
308308

309-
if (ARR_NDIM(la)!=1)
309+
if (ARR_NDIM(la)>1)
310310
ereport(ERROR,
311311
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
312312
errmsg("array must be one-dimensional")));

‎contrib/ltree/lquery_op.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* op function for ltree and lquery
33
* Teodor Sigaev <teodor@stack.net>
4-
* $PostgreSQL: pgsql/contrib/ltree/lquery_op.c,v 1.14 2009/06/11 14:48:51 momjian Exp $
4+
* $PostgreSQL: pgsql/contrib/ltree/lquery_op.c,v 1.15 2010/02/24 18:02:24 tgl Exp $
55
*/
66
#include"postgres.h"
77

@@ -344,7 +344,7 @@ lt_q_regex(PG_FUNCTION_ARGS)
344344
boolres= false;
345345
intnum=ArrayGetNItems(ARR_NDIM(_query),ARR_DIMS(_query));
346346

347-
if (ARR_NDIM(_query)!=1)
347+
if (ARR_NDIM(_query)>1)
348348
ereport(ERROR,
349349
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
350350
errmsg("array must be one-dimensional")));

‎contrib/ltree/ltree_gist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* GiST support for ltree
33
* Teodor Sigaev <teodor@stack.net>
4-
* $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.25 2009/06/11 14:48:51 momjian Exp $
4+
* $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.26 2010/02/24 18:02:24 tgl Exp $
55
*/
66
#include"postgres.h"
77

@@ -602,7 +602,7 @@ arrq_cons(ltree_gist *key, ArrayType *_query)
602602
lquery*query= (lquery*)ARR_DATA_PTR(_query);
603603
intnum=ArrayGetNItems(ARR_NDIM(_query),ARR_DIMS(_query));
604604

605-
if (ARR_NDIM(_query)!=1)
605+
if (ARR_NDIM(_query)>1)
606606
ereport(ERROR,
607607
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
608608
errmsg("array must be one-dimensional")));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp