pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pierre Ducroquet <p.psql@pinaraf.info>
Cc: pgsql-hackers@postgresql.org, Oleg Bartunov <obartunov@gmail.com>
Cc: Teodor Sigaev <teodor@sigaev.ru>
Subject: Re: function lca('{}'::ltree[]) caused DB Instance crash
Date: Fri, 13 Jul 2018 18:50:33 -0400
Message-ID: <29351.1531522233@sss.pgh.pa.us> (raw)
In-Reply-To: <993.1531492016@sss.pgh.pa.us>
References: <5b0d8e4f-f2a3-1305-d612-e00e35a7be66@qunar.com>
	<4285558.KOck4HGOto@peanuts2>
	<993.1531492016@sss.pgh.pa.us>

I wrote:
> However, I don't understand why this code is returning NULL, rather than
> a zero-length ltree, in the case that there's no common prefix.  That
> doesn't seem consistent to me.

After looking more closely, I see that what lca() returns is the longest
common *ancestor* of the input paths, not the longest common *prefix*
... at least, by my understanding of what a prefix is.  If the longest
prefix is empty, then there's no common ancestor, so returning null in
that case isn't so insane after all.  However, the documentation seems
very misleading on this point.  I changed it around along with pushing
the crash fix.

I wonder whether there isn't a need for an lcp() that would return the
common prefix as that's usually understood.

			regards, tom lane




view thread (4+ messages)

Message-ID: <29351.1531522233@sss.pgh.pa.us>
Permalink:  ../29351.1531522233@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29351.1531522233@sss.pgh.pa.us

 · 

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, p.psql@pinaraf.info, obartunov@gmail.com, teodor@sigaev.ru
  Subject: Re: function lca('{}'::ltree[]) caused DB Instance crash
  In-Reply-To: <29351.1531522233@sss.pgh.pa.us>
  References: <5b0d8e4f-f2a3-1305-d612-e00e35a7be66@qunar.com> <4285558.KOck4HGOto@peanuts2> <993.1531492016@sss.pgh.pa.us> <29351.1531522233@sss.pgh.pa.us>

* 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