Kouhei Sutou
null+****@clear*****
Wed Jun 19 12:18:35 JST 2013
Kouhei Sutou 2013-06-19 12:18:35 +0900 (Wed, 19 Jun 2013) New Revision: c1adbfb1c317c860f7e8c1e03e3314cc1a7cdcb4 https://github.com/groonga/groonga/commit/c1adbfb1c317c860f7e8c1e03e3314cc1a7cdcb4 Message: Fix a bug that result value is broken 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. Added files: test/command/suite/select/scorer/overflow/uint8.expected test/command/suite/select/scorer/overflow/uint8.test Modified files: lib/expr.c Modified: lib/expr.c (+1 -1) =================================================================== --- lib/expr.c 2013-06-19 12:14:19 +0900 (9174809) +++ lib/expr.c 2013-06-19 12:18:35 +0900 (315c976) @@ -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, \ @@ -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, \ Added: test/command/suite/select/scorer/overflow/uint8.expected (+48 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/scorer/overflow/uint8.expected 2013-06-19 12:18:35 +0900 (726c481) @@ -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 + ] + ] + ] +] Added: test/command/suite/select/scorer/overflow/uint8.test (+14 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/scorer/overflow/uint8.test 2013-06-19 12:18:35 +0900 (bb31824) @@ -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' -------------- next part -------------- HTML����������������������������...Download