summaryrefslogtreecommitdiff
path: root/contrib/ltree/ltree_gist.c
diff options
context:
space:
mode:
authorTom Lane2010-02-24 18:02:24 +0000
committerTom Lane2010-02-24 18:02:24 +0000
commit29d2f86a312e0c2060d4482649b26e9c33b760b5 (patch)
tree5720bdd1bc707daae1dbb42dd8afa0fc78623546 /contrib/ltree/ltree_gist.c
parent673fb4da02fa574756818bc761c41b7bc0eb4964 (diff)
Allow zero-dimensional (ie, empty) arrays in contrib/ltree operations.
The main motivation for changing this is bug #4921, in which it's pointed out that it's no longer safe to apply ltree operations to the result of ARRAY(SELECT ...) if the sub-select might return no rows. Before 8.3, the ARRAY() construct would return NULL, which might or might not be helpful but at least it wouldn't result in an error. Now it returns an empty array which results in a failure for no good reason, since the ltree operations are all perfectly capable of dealing with zero-element arrays. As far as I can find, these ltree functions are the only places where zero array dimensionality is rejected unnecessarily. Back-patch to 8.3 to prevent behavioral regression of queries that worked in older releases.
Diffstat (limited to 'contrib/ltree/ltree_gist.c')
-rw-r--r--contrib/ltree/ltree_gist.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c
index d48ca8e1d4e..46fccb1ee1b 100644
--- a/contrib/ltree/ltree_gist.c
+++ b/contrib/ltree/ltree_gist.c
@@ -1,7 +1,7 @@
/*
* GiST support for ltree
* Teodor Sigaev <[email protected]>
- * $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.25 2009/06/11 14:48:51 momjian Exp $
+ * $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.26 2010/02/24 18:02:24 tgl Exp $
*/
#include "postgres.h"
@@ -602,7 +602,7 @@ arrq_cons(ltree_gist *key, ArrayType *_query)
lquery *query = (lquery *) ARR_DATA_PTR(_query);
int num = ArrayGetNItems(ARR_NDIM(_query), ARR_DIMS(_query));
- if (ARR_NDIM(_query) != 1)
+ if (ARR_NDIM(_query) > 1)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("array must be one-dimensional")));