Kouhei Sutou
null+****@clear*****
Tue Nov 18 22:32:31 JST 2014
Kouhei Sutou 2014-11-18 22:32:31 +0900 (Tue, 18 Nov 2014) New Revision: 6fd21cf427ae1176ed267529724c5a4a5c3c3d1c https://github.com/groonga/groonga/commit/6fd21cf427ae1176ed267529724c5a4a5c3c3d1c Message: Don't require "_value." for accessing record value in grouped table Modified files: lib/db.c test/command/suite/select/drilldown/labeled/keys/multiple.expected test/command/suite/select/drilldown/labeled/keys/multiple.test Modified: lib/db.c (+26 -13) =================================================================== --- lib/db.c 2014-11-17 22:57:49 +0900 (5b09679) +++ lib/db.c 2014-11-18 22:32:31 +0900 (0b387a9) @@ -4476,7 +4476,15 @@ grn_obj_get_accessor(grn_ctx *ctx, grn_obj *obj, const char *name, unsigned int (*rp)->action = GRN_ACCESSOR_GET_COLUMN_VALUE; break; } else { - if (!obj->header.domain) { + grn_bool is_grouped_table; + grn_id next_obj_id; + is_grouped_table = grn_table_is_grouped(ctx, obj); + if (is_grouped_table) { + next_obj_id = grn_obj_get_range(ctx, obj); + } else { + next_obj_id = obj->header.domain; + } + if (!next_obj_id) { // ERR(GRN_INVALID_ARGUMENT, "no such column: <%s>", name); if (!is_chained) { grn_obj_close(ctx, (grn_obj *)res); @@ -4486,23 +4494,28 @@ grn_obj_get_accessor(grn_ctx *ctx, grn_obj *obj, const char *name, unsigned int } *rp = accessor_new(ctx); (*rp)->obj = obj; - if (!(obj = grn_ctx_at(ctx, obj->header.domain))) { + obj = grn_ctx_at(ctx, next_obj_id); + if (!obj) { grn_obj_close(ctx, (grn_obj *)res); res = NULL; goto exit; } - switch (obj->header.type) { - case GRN_TABLE_PAT_KEY : - case GRN_TABLE_DAT_KEY : - case GRN_TABLE_HASH_KEY : - case GRN_TABLE_NO_KEY : - (*rp)->action = GRN_ACCESSOR_GET_KEY; + if (is_grouped_table) { + (*rp)->action = GRN_ACCESSOR_GET_VALUE; + } else { + switch (obj->header.type) { + case GRN_TABLE_PAT_KEY : + case GRN_TABLE_DAT_KEY : + case GRN_TABLE_HASH_KEY : + case GRN_TABLE_NO_KEY : + (*rp)->action = GRN_ACCESSOR_GET_KEY; break; - default : - /* lookup failed */ - grn_obj_close(ctx, (grn_obj *)res); - res = NULL; - goto exit; + default : + /* lookup failed */ + grn_obj_close(ctx, (grn_obj *)res); + res = NULL; + goto exit; + } } } } Modified: test/command/suite/select/drilldown/labeled/keys/multiple.expected (+1 -1) =================================================================== --- test/command/suite/select/drilldown/labeled/keys/multiple.expected 2014-11-17 22:57:49 +0900 (862ac7c) +++ test/command/suite/select/drilldown/labeled/keys/multiple.expected 2014-11-18 22:32:31 +0900 (4900e88) @@ -15,7 +15,7 @@ load --table Memos {"_key": "Groonga is good!", "tag": "Groonga", "date": "2014-11-17 00:00:00"} ] [[0,0.0,0.0],5] -select Memos --drilldown[tag].keys tag,date --drilldown[tag].output_columns _value.tag,_value.date,_nsubrecs +select Memos --drilldown[tag].keys tag,date --drilldown[tag].output_columns tag,date,_nsubrecs [ [ 0, Modified: test/command/suite/select/drilldown/labeled/keys/multiple.test (+1 -1) =================================================================== --- test/command/suite/select/drilldown/labeled/keys/multiple.test 2014-11-17 22:57:49 +0900 (3495239) +++ test/command/suite/select/drilldown/labeled/keys/multiple.test 2014-11-18 22:32:31 +0900 (21d4c92) @@ -15,4 +15,4 @@ load --table Memos select Memos \ --drilldown[tag].keys tag,date \ - --drilldown[tag].output_columns _value.tag,_value.date,_nsubrecs + --drilldown[tag].output_columns tag,date,_nsubrecs -------------- next part -------------- HTML����������������������������... Download