Kouhei Sutou
null+****@clear*****
Fri May 19 13:58:42 JST 2017
Kouhei Sutou 2017-05-19 13:58:42 +0900 (Fri, 19 May 2017) New Revision: 04f9e29ffbd8efb8068979aec1373037e0170c5c https://github.com/groonga/groonga/commit/04f9e29ffbd8efb8068979aec1373037e0170c5c Message: delete: don't affect error to following deletions If error isn't cleared at each iteration, following deletion may cause unexpected behavior. Modified files: lib/proc.c Modified: lib/proc.c (+12 -7) =================================================================== --- lib/proc.c 2017-05-18 11:28:03 +0900 (c323340) +++ lib/proc.c 2017-05-19 13:58:42 +0900 (002ddaa) @@ -631,19 +631,24 @@ proc_delete(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) records = grn_table_select(ctx, table, cond, NULL, GRN_OP_OR); if (records) { - void *key = NULL; - GRN_TABLE_EACH(ctx, records, GRN_ID_NIL, GRN_ID_NIL, - result_id, &key, NULL, NULL, { - grn_id id = *(grn_id *)key; + GRN_TABLE_EACH_BEGIN(ctx, records, cursor, result_id) { + void *key; + grn_id id; grn_rc sub_rc; + + if (grn_table_cursor_get_key(ctx, cursor, &key) == 0) { + continue; + } + + id = *(grn_id *)key; sub_rc = grn_table_delete_by_id(ctx, table, id); if (rc == GRN_SUCCESS) { rc = sub_rc; } - if (ctx->rc == GRN_OPERATION_NOT_PERMITTED) { + if (ctx->rc != GRN_SUCCESS) { ERRCLR(ctx); } - }); + } GRN_TABLE_EACH_END(ctx, cursor); grn_obj_unlink(ctx, records); } } @@ -654,7 +659,7 @@ exit : if (table) { grn_obj_unlink(ctx, table); } - GRN_OUTPUT_BOOL(!rc); + GRN_OUTPUT_BOOL(rc == GRN_SUCCESS); return NULL; } -------------- next part -------------- HTML����������������������������...다운로드