Kouhei Sutou
null+****@clear*****
Wed Apr 12 15:58:46 JST 2017
Kouhei Sutou 2017-04-12 15:58:46 +0900 (Wed, 12 Apr 2017) New Revision: 30b1a24f419de54cefd167621f1d39abd5b43eec https://github.com/groonga/groonga/commit/30b1a24f419de54cefd167621f1d39abd5b43eec Message: ii regexp: add grn_ii_select_cursor_open() return value check Added files: test/command/suite/select/filter/index/regexp/dot_asterisk/not_match.expected test/command/suite/select/filter/index/regexp/dot_asterisk/not_match.test Modified files: lib/ii.c Modified: lib/ii.c (+10 -3) =================================================================== --- lib/ii.c 2017-04-12 15:27:21 +0900 (b7ebda9) +++ lib/ii.c 2017-04-12 15:58:46 +0900 (701174f) @@ -8116,10 +8116,11 @@ grn_ii_select_regexp(grn_ctx *ctx, grn_ii *ii, } else { int i; grn_ii_select_cursor **cursors; + grn_bool have_error = GRN_FALSE; int keep_i = 0; grn_posting keep_posting; - cursors = GRN_MALLOC(sizeof(grn_ii_select_cursor *) * n_parsed_strings); + cursors = GRN_CALLOC(sizeof(grn_ii_select_cursor *) * n_parsed_strings); for (i = 0; i < n_parsed_strings; i++) { const char *parsed_string; unsigned int parsed_string_len; @@ -8134,9 +8135,13 @@ grn_ii_select_regexp(grn_ctx *ctx, grn_ii *ii, parsed_string, parsed_string_len, optarg); + if (!cursors[i]) { + have_error = GRN_TRUE; + break; + } } - for (;;) { + while (!have_error) { grn_posting *posting; uint32_t pos; @@ -8189,7 +8194,9 @@ grn_ii_select_regexp(grn_ctx *ctx, grn_ii *ii, } for (i = 0; i < n_parsed_strings; i++) { - grn_ii_select_cursor_close(ctx, cursors[i]); + if (cursors[i]) { + grn_ii_select_cursor_close(ctx, cursors[i]); + } } GRN_FREE(cursors); } Added: test/command/suite/select/filter/index/regexp/dot_asterisk/not_match.expected (+27 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/index/regexp/dot_asterisk/not_match.expected 2017-04-12 15:58:46 +0900 (0259dd4) @@ -0,0 +1,27 @@ +table_create Memos TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Memos content COLUMN_SCALAR Text +[[0,0.0,0.0],true] +table_create RegexpTokens TABLE_PAT_KEY ShortText --normalizer NormalizerAuto --default_tokenizer TokenRegexp +[[0,0.0,0.0],true] +column_create RegexpTokens memos_content COLUMN_INDEX|WITH_POSITION Memos content +[[0,0.0,0.0],true] +load --table Memos +[ +{"content": "Groonga"}, +{"content": "Rroonga"}, +{"content": "PGroonga"} +] +[[0,0.0,0.0],3] +log_level --level info +[[0,0.0,0.0],true] +select Memos --filter 'content @~ "mr.*ga"' +[[0,0.0,0.0],[[[0],[["_id","UInt32"],["content","Text"]]]]] +#|i| [object][search][index][key][regexp] <RegexpTokens.memos_content> +#|i| grn_ii_sel > (mr.*ga) +#|i| exact: 0 +#|i| unsplit: 0 +#|i| partial: 0 +#|i| hits=0 +log_level --level notice +[[0,0.0,0.0],true] Added: test/command/suite/select/filter/index/regexp/dot_asterisk/not_match.test (+23 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/filter/index/regexp/dot_asterisk/not_match.test 2017-04-12 15:58:46 +0900 (126cc67) @@ -0,0 +1,23 @@ +#$GRN_II_REGEXP_DOT_ASTERISK_ENABLE=yes + +table_create Memos TABLE_NO_KEY +column_create Memos content COLUMN_SCALAR Text + +table_create RegexpTokens TABLE_PAT_KEY ShortText \ + --normalizer NormalizerAuto \ + --default_tokenizer TokenRegexp +column_create RegexpTokens memos_content COLUMN_INDEX|WITH_POSITION \ + Memos content + +load --table Memos +[ +{"content": "Groonga"}, +{"content": "Rroonga"}, +{"content": "PGroonga"} +] + +log_level --level info +#@add-important-log-levels info +select Memos --filter 'content @~ "mr.*ga"' +#@remove-important-log-levels info +log_level --level notice -------------- next part -------------- HTML����������������������������...Download