susumu.yata
null+****@clear*****
Fri Oct 16 12:48:13 JST 2015
susumu.yata 2015-10-16 12:48:13 +0900 (Fri, 16 Oct 2015) New Revision: 06e344848baa0a6a411c4b189188092f6c5e9297 https://github.com/groonga/groonga/commit/06e344848baa0a6a411c4b189188092f6c5e9297 Message: grn_pat: fix a bug that an index is broken by deletion GitHub: #415 Modified files: lib/pat.c Modified: lib/pat.c (+18 -3) =================================================================== --- lib/pat.c 2015-10-16 12:27:34 +0900 (9d8b07a) +++ lib/pat.c 2015-10-16 12:48:13 +0900 (a0f20b9) @@ -1159,7 +1159,12 @@ _grn_pat_del(grn_ctx *ctx, grn_pat *pat, const char *key, uint32_t key_size, int } PAT_CHK_SET(rno, 0); } - if (proot == p0 && !rno->check) { rno->lr[0] = rno->lr[1] = otherside; } + if (proot == p0 && !rno->check) { + const uint8_t *k = pat_node_get_key(ctx, pat, rno); + int direction = k ? (*k >> 7) : 1; + rno->lr[direction] = otherside; + rno->lr[!direction] = 0; + } } } *p0 = otherside; @@ -1216,7 +1221,12 @@ _grn_pat_del(grn_ctx *ctx, grn_pat *pat, const char *key, uint32_t key_size, int if (*p0 == otherside) { /* The previous node is the other side (self-loop). */ PAT_CHK_SET(rn0, 0); - if (proot == p0 && !rn0->check) { rn0->lr[0] = rn0->lr[1] = otherside; } + if (proot == p0 && !rn0->check) { + const uint8_t *k = pat_node_get_key(ctx, pat, rn0); + int direction = k ? (*k >> 7) : 1; + rn0->lr[direction] = otherside; + rn0->lr[!direction] = 0; + } } else { if (otherside) { if (otherside == r) { @@ -1231,7 +1241,12 @@ _grn_pat_del(grn_ctx *ctx, grn_pat *pat, const char *key, uint32_t key_size, int } PAT_CHK_SET(rno, 0); } - if (proot == p0 && !rno->check) { rno->lr[0] = rno->lr[1] = otherside; } + if (proot == p0 && !rno->check) { + const uint8_t *k = pat_node_get_key(ctx, pat, rno); + int direction = k ? (*k >> 7) : 1; + rno->lr[direction] = otherside; + rno->lr[!direction] = 0; + } } } *p0 = otherside; -------------- next part -------------- HTML����������������������������...Download