pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix crash in contrib/ltree's lca() function for empty input arra
Date: Fri, 13 Jul 2018 22:45:48 +0000
Message-ID: <E1fe6ou-0001wY-2v@gemulon.postgresql.org> (raw)

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

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f8e8be7f2f9ef9162985ca1a8f4cc41940363522

Modified Files
--------------
contrib/ltree/expected/ltree.out | 18 ++++++++++++++++++
contrib/ltree/ltree_op.c         | 34 +++++++++++++++++++++++++---------
contrib/ltree/sql/ltree.sql      |  3 +++
doc/src/sgml/ltree.sgml          |  8 ++++----
4 files changed, 50 insertions(+), 13 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1fe6ou-0001wY-2v@gemulon.postgresql.org>
Permalink:  ../E1fe6ou-0001wY-2v@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fe6ou-0001wY-2v@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix crash in contrib/ltree's lca() function for empty input arra
  In-Reply-To: <E1fe6ou-0001wY-2v@gemulon.postgresql.org>
  References: <E1fe6ou-0001wY-2v@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox