[Groonga-commit] groonga/groonga at e2b9eea [master] grn_table_select: stop to return res on error

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Aug 17 15:32:39 JST 2015


Kouhei Sutou	2015-08-17 15:32:39 +0900 (Mon, 17 Aug 2015)

  New Revision: e2b9eea1b6e67d67d3927e126fe111fbfef0400f
  https://github.com/groonga/groonga/commit/e2b9eea1b6e67d67d3927e126fe111fbfef0400f

  Message:
    grn_table_select: stop to return res on error
    
    If res is created internally, it's freed in the function.

  Modified files:
    lib/expr.c
    lib/mrb/mrb_table.c

  Modified: lib/expr.c (+13 -1)
===================================================================
--- lib/expr.c    2015-08-17 15:12:39 +0900 (66a5f0d)
+++ lib/expr.c    2015-08-17 15:32:39 +0900 (10ac108)
@@ -5522,7 +5522,13 @@ grn_table_select(grn_ctx *ctx, grn_obj *table, grn_obj *expr,
         }
         GRN_QUERY_LOG(ctx, GRN_QUERY_LOG_SIZE,
                       ":", "filter(%d)", grn_table_size(ctx, res));
-        if (ctx->rc) { break; }
+        if (ctx->rc) {
+          if (res_created) {
+            GRN_OBJ_FIN(ctx, res);
+          }
+          res = NULL;
+          break;
+        }
       }
       for (i = 0; i < n; i++) {
         scan_info *si = sis[i];
@@ -5535,6 +5541,12 @@ grn_table_select(grn_ctx *ctx, grn_obj *table, grn_obj *expr,
     } else {
       if (!ctx->rc) {
         grn_table_select_sequential(ctx, table, expr, v, res, op);
+        if (ctx->rc) {
+          if (res_created) {
+            GRN_OBJ_FIN(ctx, res);
+          }
+          res = NULL;
+        }
       }
     }
   }

  Modified: lib/mrb/mrb_table.c (+0 -3)
===================================================================
--- lib/mrb/mrb_table.c    2015-08-17 15:12:39 +0900 (a44537c)
+++ lib/mrb/mrb_table.c    2015-08-17 15:32:39 +0900 (6dbe0ec)
@@ -153,9 +153,6 @@ mrb_grn_table_select(mrb_state *mrb, mrb_value self)
 
   result = grn_table_select(ctx, table, expr, result, operator);
   if (ctx->rc != GRN_SUCCESS) {
-    if (result) {
-      grn_obj_unlink(ctx, result);
-    }
     grn_mrb_ctx_check(mrb);
   }
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index