[Groonga-commit] groonga/groonga at 5e37eb7 [master] mrb: add Table#create_column

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Mar 15 18:21:48 JST 2017


Kouhei Sutou	2017-03-15 18:21:48 +0900 (Wed, 15 Mar 2017)

  New Revision: 5e37eb70980fa66d61051d8459cfe087bb4f29fe
  https://github.com/groonga/groonga/commit/5e37eb70980fa66d61051d8459cfe087bb4f29fe

  Message:
    mrb: add Table#create_column

  Modified files:
    lib/mrb/mrb_table.c

  Modified: lib/mrb/mrb_table.c (+29 -0)
===================================================================
--- lib/mrb/mrb_table.c    2017-03-15 14:28:53 +0900 (5b17b3d)
+++ lib/mrb/mrb_table.c    2017-03-15 18:21:48 +0900 (06663fb)
@@ -139,6 +139,32 @@ mrb_grn_table_get_column_ids(mrb_state *mrb, mrb_value self)
 }
 
 static mrb_value
+mrb_grn_table_create_column(mrb_state *mrb, mrb_value self)
+{
+  grn_ctx *ctx = (grn_ctx *)mrb->ud;
+  grn_obj *table;
+  mrb_value mrb_name;
+  mrb_int flags;
+  mrb_value mrb_type;
+  grn_obj *type;
+  grn_obj *column;
+
+  mrb_get_args(mrb, "oio", &mrb_name, &flags, &mrb_type);
+
+  table = DATA_PTR(self);
+  type = DATA_PTR(mrb_type);
+  column = grn_column_create(ctx, table,
+                             RSTRING_PTR(mrb_name),
+                             RSTRING_LEN(mrb_name),
+                             NULL,
+                             flags,
+                             type);
+  grn_mrb_ctx_check(mrb);
+
+  return grn_mrb_value_from_grn_obj(mrb, column);
+}
+
+static mrb_value
 mrb_grn_table_is_locked(mrb_state *mrb, mrb_value self)
 {
   grn_ctx *ctx = (grn_ctx *)mrb->ud;
@@ -371,6 +397,9 @@ grn_mrb_table_init(grn_ctx *ctx)
   mrb_define_method(mrb, klass, "column_ids",
                     mrb_grn_table_get_column_ids, MRB_ARGS_NONE());
 
+  mrb_define_method(mrb, klass, "create_column",
+                    mrb_grn_table_create_column, MRB_ARGS_REQ(3));
+
   mrb_define_method(mrb, klass, "locked?",
                     mrb_grn_table_is_locked, MRB_ARGS_NONE());
 
-------------- next part --------------
HTML����������������������������...
Download 



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