[Groonga-commit] groonga/groonga [master] [delete] cleanup. refs #1225

Back to archive index

null+****@clear***** null+****@clear*****
2011年 12月 26日 (月) 14:21:31 JST


Kouhei Sutou	2011-12-26 14:21:31 +0900 (Mon, 26 Dec 2011)

  New Revision: 57ccf7ccc1e4c9318dd6549edda0c450ad30b258

  Log:
    [delete] cleanup. refs #1225

  Modified files:
    lib/proc.c

  Modified: lib/proc.c (+12 -11)
===================================================================
--- lib/proc.c    2011-12-26 14:18:45 +0900 (35d3c18)
+++ lib/proc.c    2011-12-26 14:21:31 +0900 (1d9955d)
@@ -1642,17 +1642,18 @@ proc_delete(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
                      NULL, GRN_OP_MATCH, GRN_OP_AND,
                      GRN_EXPR_SYNTAX_SCRIPT);
       if (!ctx->rc) {
-        grn_obj *res;
-        void *res_key, *res_value;
-        uint32_t res_key_size;
-
-        res = grn_table_select(ctx, table, cond, NULL, GRN_OP_OR);
-        GRN_TABLE_EACH(ctx, res, 0, 0,
-                       res_id, &res_key, &res_key_size, &res_value, {
-          grn_id id = *(grn_id *)res_key;
-          grn_table_delete_by_id(ctx, table, id);
-        });
-        grn_obj_unlink(ctx, res);
+        grn_obj *records;
+
+        records = grn_table_select(ctx, table, cond, NULL, GRN_OP_OR);
+        if (records) {
+          void *key;
+          GRN_TABLE_EACH(ctx, records, GRN_ID_NIL, GRN_ID_NIL,
+                         result_id, &key, NULL, NULL, {
+            grn_id id = *(grn_id *)key;
+            grn_table_delete_by_id(ctx, table, id);
+          });
+          grn_obj_unlink(ctx, records);
+        }
       }
 
       grn_obj_unlink(ctx, cond);




Groonga-commit メーリングリストの案内
Back to archive index