Navigation Menu

Skip to content

Commit

Permalink
ii regexp: add grn_ii_select_cursor_open() return value check
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 12, 2017
1 parent 37237dd commit 30b1a24
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/ii.c
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
@@ -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]
@@ -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

0 comments on commit 30b1a24

Please sign in to comment.