subpath(ltree,0,0) returns ''.
(1 row)
SELECT subpath('Top.Child1.Child2',0,0);
- subpath
--------------------
- Top.Child1.Child2
+ subpath
+---------
+
(1 row)
SELECT subpath('Top.Child1.Child2',1,0);
- subpath
----------------
- Child1.Child2
+ subpath
+---------
+
(1 row)
SELECT subpath('Top.Child1.Child2',0);
ltree *res;
int i;
- if (startpos < 0 || endpos < 0 || startpos >= t->numlevel || startpos >= endpos)
+ if (startpos < 0 || endpos < 0 || startpos >= t->numlevel || startpos > endpos)
elog(ERROR, "Wrong positions");
if (endpos > t->numlevel)
endpos = t->numlevel;
+ start = end = (char *) ptr;
for (i = 0; i < endpos; i++)
{
if (i == startpos)
if (len < 0)
end = t->numlevel + len;
else if (len == 0)
- end = 0xffff;
+ end = (fcinfo->nargs == 3) ? start : 0xffff;
res = inner_subltree(t, start, end);