diff options
author | Kentoku <kentokushiba@gmail.com> | 2017-10-10 23:15:25 +0900 |
---|---|---|
committer | Kentoku <kentokushiba@gmail.com> | 2017-10-10 23:15:25 +0900 |
commit | 13167e64898da6373fa8cab2ad89514eaf886412 (patch) | |
tree | 80bf1b092bc5ebd5d64624a2df41ac31bf115959 /storage/mroonga/vendor/groonga/lib/mrb/mrb_accessor.c | |
parent | 494d1bf8859bbc9f80779144d07ce0603523d813 (diff) | |
download | mariadb-git-13167e64898da6373fa8cab2ad89514eaf886412.tar.gz |
Update Mroonga to the latest version on 2017-10-10T23:15:25+0900
Diffstat (limited to 'storage/mroonga/vendor/groonga/lib/mrb/mrb_accessor.c')
-rw-r--r-- | storage/mroonga/vendor/groonga/lib/mrb/mrb_accessor.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/storage/mroonga/vendor/groonga/lib/mrb/mrb_accessor.c b/storage/mroonga/vendor/groonga/lib/mrb/mrb_accessor.c index daa0caada06..0ef790544ba 100644 --- a/storage/mroonga/vendor/groonga/lib/mrb/mrb_accessor.c +++ b/storage/mroonga/vendor/groonga/lib/mrb/mrb_accessor.c @@ -25,6 +25,7 @@ #include <mruby/data.h> #include "../grn_db.h" +#include "mrb_ctx.h" #include "mrb_accessor.h" #include "mrb_converter.h" @@ -71,6 +72,30 @@ mrb_grn_accessor_object(mrb_state *mrb, mrb_value self) return grn_mrb_value_from_grn_obj(mrb, accessor->obj); } +static mrb_value +mrb_grn_accessor_name(mrb_state *mrb, mrb_value self) +{ + grn_ctx *ctx = (grn_ctx *)mrb->ud; + grn_rc rc; + grn_obj *accessor; + grn_obj name; + mrb_value mrb_name; + + accessor = DATA_PTR(self); + GRN_TEXT_INIT(&name, 0); + rc = grn_column_name_(ctx, accessor, &name); + if (rc == GRN_SUCCESS) { + mrb_name = mrb_str_new(mrb, GRN_TEXT_VALUE(&name), GRN_TEXT_LEN(&name)); + GRN_OBJ_FIN(ctx, &name); + } else { + mrb_name = mrb_nil_value(); + GRN_OBJ_FIN(ctx, &name); + grn_mrb_ctx_check(mrb); + } + + return mrb_name; +} + void grn_mrb_accessor_init(grn_ctx *ctx) { @@ -89,5 +114,8 @@ grn_mrb_accessor_init(grn_ctx *ctx) mrb_grn_accessor_have_next_p, MRB_ARGS_NONE()); mrb_define_method(mrb, klass, "object", mrb_grn_accessor_object, MRB_ARGS_NONE()); + + mrb_define_method(mrb, klass, "name", + mrb_grn_accessor_name, MRB_ARGS_NONE()); } #endif |