Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2c91493

Browse files
committed
Fix subpath and subltree. Allow to return '' value.
subpath(ltree,0,0) returns ''.
1 parentfd4c775 commit2c91493

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

‎contrib/ltree/expected/ltree.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ SELECT subpath('Top.Child1.Child2',0,-1);
7474
(1 row)
7575

7676
SELECT subpath('Top.Child1.Child2',0,0);
77-
subpath
78-
-------------------
79-
Top.Child1.Child2
77+
subpath
78+
---------
79+
8080
(1 row)
8181

8282
SELECT subpath('Top.Child1.Child2',1,0);
83-
subpath
84-
---------------
85-
Child1.Child2
83+
subpath
84+
---------
85+
8686
(1 row)
8787

8888
SELECT subpath('Top.Child1.Child2',0);

‎contrib/ltree/ltree_op.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,13 @@ inner_subltree(ltree * t, int4 startpos, int4 endpos)
196196
ltree*res;
197197
inti;
198198

199-
if (startpos<0||endpos<0||startpos >=t->numlevel||startpos >=endpos)
199+
if (startpos<0||endpos<0||startpos >=t->numlevel||startpos>endpos)
200200
elog(ERROR,"Wrong positions");
201201

202202
if (endpos>t->numlevel)
203203
endpos=t->numlevel;
204204

205+
start=end= (char*)ptr;
205206
for (i=0;i<endpos;i++)
206207
{
207208
if (i==startpos)
@@ -258,7 +259,7 @@ subpath(PG_FUNCTION_ARGS)
258259
if (len<0)
259260
end=t->numlevel+len;
260261
elseif (len==0)
261-
end=0xffff;
262+
end=(fcinfo->nargs==3) ?start :0xffff;
262263

263264
res=inner_subltree(t,start,end);
264265

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp