Re: [ltree] Should `SELECT LCA('1.2', '1.2.3');` return '1.2' insteadof '1'?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [ltree] Should `SELECT LCA('1.2', '1.2.3');` return '1.2' insteadof '1'?
Дата
Msg-id CAKFQuwbWHohLPZ-USaNPXozVtzCRu41e8A7DSoeOD-LHmxn6kg@mail.gmail.com
обсуждение исходный текст
Ответ на [ltree] Should `SELECT LCA('1.2', '1.2.3');` return '1.2' instead of '1'?  (Julien Grillot <julien.grillot@gmail.com>)
Ответы Re: [ltree] Should `SELECT LCA('1.2', '1.2.3');` return '1.2' insteadof '1'?  (Julien Grillot <julien.grillot@gmail.com>)
Re: [ltree] Should `SELECT LCA('1.2', '1.2.3');` return '1.2' instead of '1'?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Fri, Dec 1, 2017 at 8:32 AM, Julien Grillot wrote: > At the moment, both SELECT LCA('1.2', '1.2'); and SELECT LCA('1.2', > '1.2.3'); return ‘1’. > > According to the Wikipedia1 definition of LCA: > “[…] the lowest common ancestor (LCA) of two nodes v and w […] is the > lowest (i.e. deepest) node that has both v and w as descendants, where we > define each node to be a descendant of itself (so if v has a direct > connection from w, w is the lowest common ancestor).” > > 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. David J.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: lyes.amd@gmail.com
Дата:
Сообщение: BUG #14941: Vacuum crashes
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: BUG #14940: Duplicated records inspite of primary key and uniqueconstraint