Allow zero-dimensional (ie, empty) arrays in contrib/ltree operations.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Feb 2010 18:02:36 +0000 (18:02 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 24 Feb 2010 18:02:36 +0000 (18:02 +0000)
commitfbdf9712afbbee4c213905f28019114e79b4e139
treedaf95b263b7e348b1796ed469b14f5a8a4cc2772
parent28a19436ca464eb4c0a5bad918b3b6b5d8c7b827
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.
contrib/ltree/_ltree_gist.c
contrib/ltree/_ltree_op.c
contrib/ltree/lquery_op.c
contrib/ltree/ltree_gist.c