pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Julien Grillot <julien.grillot@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: [ltree] Should `SELECT LCA('1.2', '1.2.3');` return '1.2' instead of '1'?
Date: Fri, 13 Jul 2018 18:54:12 -0400
Message-ID: <29778.1531522452@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbWHohLPZ-USaNPXozVtzCRu41e8A7DSoeOD-LHmxn6kg@mail.gmail.com>
References: <CAKnjZ0KTVw63SM5wkWqAkNRv5+-GPXF8r60vtssvhOWJ3N5otA@mail.gmail.com>
	<CAKFQuwbWHohLPZ-USaNPXozVtzCRu41e8A7DSoeOD-LHmxn6kg@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Fri, Dec 1, 2017 at 8:32 AM, Julien Grillot <julien.grillot@gmail.com>
> wrote:
>> So, in my understanding, both SELECT LCA('1.2', '1.2'); and SELECT
>> LCA('1.2', '1.2.3'); should return ‘1.2’. What do you think about it?

> If indeed one defines "each node to be a descendant of itself" then you
> are correct.  Unfortunately your example indicates that this implementation
> does not define ancestry that way.  While you may not agree with the
> definition at this point changing the existing function's behavior in this
> manner seems highly undesirable - too much existing code would silently
> break.  Adding a leading (due to varargs) boolean argument that specifies
> "end node is ancestor of itself" behavior might be a workable solution.

> Regardless, the docs should be clarified on this point, though, and maybe
> add a code comment somewhere.

This came up again today; I've now adjusted the docs to reflect reality.

If we were to do something about the lack of a function that behaves
the other way, I'd suggest calling it lcp() for "longest common prefix".
Trying to deal with it with an optional argument is going to create
overloading problems.

			regards, tom lane




view thread (4+ messages)

Message-ID: <29778.1531522452@sss.pgh.pa.us>
Permalink:  ../29778.1531522452@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29778.1531522452@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, david.g.johnston@gmail.com, julien.grillot@gmail.com
  Subject: Re: [ltree] Should `SELECT LCA('1.2', '1.2.3');` return '1.2' instead of '1'?
  In-Reply-To: <29778.1531522452@sss.pgh.pa.us>
  References: <CAKnjZ0KTVw63SM5wkWqAkNRv5+-GPXF8r60vtssvhOWJ3N5otA@mail.gmail.com> <CAKFQuwbWHohLPZ-USaNPXozVtzCRu41e8A7DSoeOD-LHmxn6kg@mail.gmail.com> <29778.1531522452@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