[Groonga-commit] groonga/grngo at 0d70f36 [master] Update InsertRow() to support table references.

Back to archive index

susumu.yata null+****@clear*****
Thu Jul 30 18:13:04 JST 2015


susumu.yata	2015-07-30 18:13:04 +0900 (Thu, 30 Jul 2015)

  New Revision: 0d70f3610c4429b7019e4f5e4929f70e1467497a
  https://github.com/groonga/grngo/commit/0d70f3610c4429b7019e4f5e4929f70e1467497a

  Message:
    Update InsertRow() to support table references.
    
    GitHub: #21

  Modified files:
    grngo.c

  Modified: grngo.c (+15 -2)
===================================================================
--- grngo.c    2015-07-30 18:02:22 +0900 (8e50650)
+++ grngo.c    2015-07-30 18:13:04 +0900 (beabd67)
@@ -365,15 +365,28 @@ static grn_rc
 _grngo_insert_row(grngo_table *table, const void *key, size_t key_size,
                   grn_bool *inserted, grn_id *id) {
   grn_ctx *ctx = table->db->ctx;
+  size_t i = table->n_objs - 1;
   int tmp_inserted;
-  grn_id tmp_id = grn_table_add(ctx, table->objs[0],
-                                key, key_size, &tmp_inserted);
+  grn_id tmp_id = grn_table_add(ctx, table->objs[i], key, key_size,
+                                &tmp_inserted);
   if (tmp_id == GRN_ID_NIL) {
     if (ctx->rc != GRN_SUCCESS) {
       return ctx->rc;
     }
     return GRN_UNKNOWN_ERROR;
   }
+  // Resolve table references.
+  while (i > 0) {
+    i--;
+    tmp_id = grn_table_add(ctx, table->objs[i], &tmp_id, sizeof(tmp_id),
+                           &tmp_inserted);
+    if (tmp_id == GRN_ID_NIL) {
+      if (ctx->rc != GRN_SUCCESS) {
+        return ctx->rc;
+      }
+      return GRN_UNKNOWN_ERROR;
+    }
+  }
   *inserted = (grn_bool)tmp_inserted;
   *id = tmp_id;
   return GRN_SUCCESS;
-------------- next part --------------
HTML����������������������������...
다운로드 



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