Navigation Menu

Skip to content

Commit

Permalink
Fix a bug that result value is broken
Browse files Browse the repository at this point in the history
In this test case, an optimization is used. The optimization shares y
and res. So we should not change res before retrieving y value. If we
change res, retrieving y value may be broken.
  • Loading branch information
kou committed Jun 19, 2013
1 parent 89642a3 commit c1adbfb
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/expr.c
Expand Up @@ -2212,7 +2212,6 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
grn_obj *x, *y; \
\
POP2ALLOC1(x, y, res); \
res->header.domain = x->header.domain; \
ARITHMETIC_OPERATION_DISPATCH(x, y, res, \
integer8_operation, \
integer16_operation, \
Expand All @@ -2223,6 +2222,7 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller)
right_expression_check, \
text_operation, \
invalid_type_error); \
res->header.domain = x->header.domain; \
} while (0)

#define ARITHMETIC_UNARY_OPERATION_DISPATCH(integer_operation, \
Expand Down
48 changes: 48 additions & 0 deletions test/command/suite/select/scorer/overflow/uint8.expected
@@ -0,0 +1,48 @@
table_create Values TABLE_NO_KEY
[[0,0.0,0.0],true]
column_create Values uint8 COLUMN_SCALAR UInt8
[[0,0.0,0.0],true]
load --table Values
[
{"uint8": 1},
{"uint8": 2},
{"uint8": 3}
]
[[0,0.0,0.0],3]
select Values --filter 'true' --output_columns 'uint8,_score' --scorer '_score = 1000 * uint8 * 12 / 15'
[
[
0,
0.0,
0.0
],
[
[
[
3
],
[
[
"uint8",
"UInt8"
],
[
"_score",
"Int32"
]
],
[
1,
800
],
[
2,
1600
],
[
3,
2400
]
]
]
]
14 changes: 14 additions & 0 deletions test/command/suite/select/scorer/overflow/uint8.test
@@ -0,0 +1,14 @@
table_create Values TABLE_NO_KEY
column_create Values uint8 COLUMN_SCALAR UInt8

load --table Values
[
{"uint8": 1},
{"uint8": 2},
{"uint8": 3}
]

select Values \
--filter 'true' \
--output_columns 'uint8,_score' \
--scorer '_score = 1000 * uint8 * 12 / 15'

0 comments on commit c1adbfb

Please sign in to comment.