]> granicus.if.org Git - postgresql/commit
Fix crash in contrib/ltree's lca() function for empty input array.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 13 Jul 2018 22:45:30 +0000 (18:45 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 13 Jul 2018 22:45:30 +0000 (18:45 -0400)
commitdbd7f4e7c433b4fc202e9520d2bd360200f07805
tree08af17dcb9dbe0a558ad81466c24e08711ef3246
parentbc4e355f013d6122e4ae17fa99e9db20babbb86a
Fix crash in contrib/ltree's lca() function for empty input array.

lca_inner() wasn't prepared for the possibility of getting no inputs.
Fix that, and make some cosmetic improvements to the code while at it.

Also, I thought the documentation of this function as returning the
"longest common prefix" of the paths was entirely misleading; it really
returns a path one shorter than the longest common prefix, for the typical
definition of "prefix".  Don't use that term in the docs, and adjust the
examples to clarify what really happens.

This has been broken since its beginning, so back-patch to all supported
branches.

Per report from Hailong Li.  Thanks to Pierre Ducroquet for diagnosing
and for the initial patch, though I whacked it around some and added
test cases.

Discussion: https://postgr.es/m/5b0d8e4f-f2a3-1305-d612-e00e35a7be66@qunar.com
contrib/ltree/expected/ltree.out
contrib/ltree/ltree_op.c
contrib/ltree/sql/ltree.sql
doc/src/sgml/ltree.sgml