Skip to content

Commit e7d490f

Browse files
committed
Fix bug introduced by last patch, thanks again to Mario Weilguni <mweilguni@sime.com>
1 parent 79a1a2e commit e7d490f

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

contrib/ltree/ltree_gist.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* GiST support for ltree
33
* Teodor Sigaev <teodor@stack.net>
4-
* $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.17 2006/08/07 17:39:04 teodor Exp $
4+
* $PostgreSQL: pgsql/contrib/ltree/ltree_gist.c,v 1.18 2006/08/08 15:45:18 teodor Exp $
55
*/
66

77
#include "ltree.h"
@@ -456,16 +456,36 @@ gist_isparent(ltree_gist * key, ltree * query)
456456
return false;
457457
}
458458

459+
static ltree *
460+
copy_ltree( ltree *src ) {
461+
ltree *dst = (ltree*)palloc(src->len);
462+
memcpy(dst, src, src->len);
463+
return dst;
464+
}
465+
459466
static bool
460467
gist_ischild(ltree_gist * key, ltree * query)
461468
{
462-
if (ltree_compare(query, LTG_GETLNODE(key)) < 0)
463-
return false;
469+
ltree *left = copy_ltree(LTG_GETLNODE(key));
470+
ltree *right = copy_ltree(LTG_GETRNODE(key));
471+
bool res = true;
464472

465-
if (ltree_compare(query, LTG_GETRNODE(key)) > 0)
466-
return false;
473+
if (left->numlevel > query->numlevel)
474+
left->numlevel = query->numlevel;
467475

468-
return true;
476+
if (ltree_compare(query, left) < 0)
477+
res = false;
478+
479+
if (right->numlevel > query->numlevel)
480+
right->numlevel = query->numlevel;
481+
482+
if (res && ltree_compare(query, right) > 0)
483+
res = false;
484+
485+
pfree(left);
486+
pfree(right);
487+
488+
return res;
469489
}
470490

471491
static bool

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy