Fix contrib/ltree's subpath() with negative offset. subpath(ltree,offset,len) now correctly errors when given an offset less than -n, where n is the number of labels in the given ltree. There was a duplicate block of code that allowed an offset as low as -2n. The documentation says no such thing, so this must have been a copy-and-paste error in the original ltree patch.
While here, avoid redundant calculation of "end" and write LTREE_MAX_LEVELS rather than its hard-coded value. Author: Marcus Gartner <[email protected]> Reviewed-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/caaugv_svbo9gwybaejb9nhe-ms9fknp4qadntdm3wdrhvlo...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ff8aba65d463b144db7c081181b5ccf6eaaf1af4 Modified Files -------------- contrib/ltree/expected/ltree.out | 2 ++ contrib/ltree/ltree_op.c | 14 +++----------- contrib/ltree/sql/ltree.sql | 1 + 3 files changed, 6 insertions(+), 11 deletions(-)
