Re: function lca('{}'::ltree[]) caused DB Instance crash
Tom Lane <tgl@sss.pgh.pa.us>
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>,
Teodor Sigaev <teodor@sigaev.ru>
Date: 2018-07-13T22:50:33Z
Lists: pgsql-bugs, pgsql-hackers
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
Commits
-
Fix crash in contrib/ltree's lca() function for empty input array.
- f8e8be7f2f9e 9.4.19 landed
- dbd7f4e7c433 11.0 landed
- cbbe75fe6719 9.3.24 landed
- ac6b69c1959f 9.5.14 landed
- 330cad2c4b9a 9.6.10 landed
- 28a1ae5342fe 12.0 landed
- 1f47eb08cb42 10.5 landed