Navigation Menu

Skip to content

Commit

Permalink
Fix codes_curr check position
Browse files Browse the repository at this point in the history
We should not touch expr->codes[si->end] when si->start >=
expr->codes_curr.
  • Loading branch information
kou committed Jun 23, 2018
1 parent f7d2e1c commit 8712afa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions lib/expr.c
Expand Up @@ -4694,13 +4694,23 @@ grn_table_select_inspect_condition(grn_ctx *ctx,
return "";
}

n_codes = si->end - si->start + 1;
last_operator = expr->codes[si->end].op;

GRN_BULK_REWIND(buffer);

GRN_TEXT_PUTS(ctx, buffer, ": ");

if (si->start >= expr->codes_curr) {
if (si->op != GRN_OP_NOP) {
GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(si->op));
GRN_TEXT_PUTS(ctx, buffer, ": ");
}
GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(si->logical_op));
GRN_TEXT_PUTC(ctx, buffer, '\0');
return GRN_TEXT_VALUE(buffer);
}

n_codes = si->end - si->start + 1;
last_operator = expr->codes[si->end].op;

switch (last_operator) {
case GRN_OP_CALL :
for (i = si->start; i <= si->end; i++) {
Expand Down Expand Up @@ -4762,16 +4772,10 @@ grn_table_select_inspect_condition(grn_ctx *ctx,
if (i > si->start) {
GRN_TEXT_PUTC(ctx, buffer, ' ');
}
if (i < expr->codes_curr) {
if (code->value) {
grn_table_select_inspect_condition_argument(ctx, buffer, code->value);
} else {
GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(code->op));
}
if (code->value) {
grn_table_select_inspect_condition_argument(ctx, buffer, code->value);
} else {
GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(si->op));
GRN_TEXT_PUTS(ctx, buffer, ": ");
GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(si->logical_op));
GRN_TEXT_PUTS(ctx, buffer, grn_operator_to_string(code->op));
}
}
break;
Expand Down
Expand Up @@ -84,7 +84,7 @@ select Packages --filter 'sub_filter(files, "revision >
#:000000000000000 filter(0): #<accessor _key(Files)> "ha" prefix
#:000000000000000 filter(1): #<accessor _key(Files)> "include/" prefix
#:000000000000000 filter(1): Files.revision greater_equal 10
#:000000000000000 filter(1): nop: and
#:000000000000000 filter(1): and
#:000000000000000 filter(1): sub_filter(Packages.files, "revision >= 10 && (_key @^ \"ha\" || _key @^ \"include/\")")
#:000000000000000 select(1)
#:000000000000000 output(1)
Expand Down

0 comments on commit 8712afa

Please sign in to comment.