Kouhei Sutou
null+****@clear*****
Mon Feb 25 23:22:33 JST 2013
Kouhei Sutou 2013-02-25 23:22:33 +0900 (Mon, 25 Feb 2013) New Revision: a278e54c6e8b97d83806a2de6cca6377a5495b64 https://github.com/groonga/groonga/commit/a278e54c6e8b97d83806a2de6cca6377a5495b64 Log: Fix a bug that select --query _key:XXX for Int*/UInt* doesn't work It is caused only TABLE_PAT_KEY because GRN_OP_GET_VALUE in grn_expr_exec() uses grn_obj_get_value_() (see the last "_") instead of grn_obj_get_value(). get_value_() is lighter version of get_value(). get_value_() doesn't support key decoding. TABLE_PAT_KEY encodes int/uint/geo point/float key. So we can't use get_value_() for Int*/UInt*/*GeoPoint/Float. This change uses get_value() to get column value. (_key is a pseudo column.) Added files: test/command/suite/select/query/not/key/double_array_trie/uint64.expected test/command/suite/select/query/not/key/double_array_trie/uint64.test test/command/suite/select/query/not/key/hash/uint64.expected test/command/suite/select/query/not/key/hash/uint64.test test/command/suite/select/query/not/key/patricia_trie/uint64.expected test/command/suite/select/query/not/key/patricia_trie/uint64.test Modified files: lib/expr.c Modified: lib/expr.c (+24 -13) =================================================================== --- lib/expr.c 2013-02-25 19:02:52 +0900 (036925c) +++ lib/expr.c 2013-02-25 23:22:33 +0900 (d373454) @@ -2682,9 +2682,9 @@ grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs) case GRN_OP_GET_VALUE : { grn_obj *col, *rec; + grn_obj value; + GRN_TEXT_INIT(&value, 0); do { - uint32_t size; - const char *value; if (code->nargs == 1) { rec = v0; if (code->value) { @@ -2708,24 +2708,35 @@ grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs) } grn_obj_reinit_for(ctx, res, col); if (col) { - value = grn_obj_get_value_(ctx, col, GRN_RECORD_VALUE(rec), &size); + GRN_BULK_REWIND(&value); + grn_obj_get_value(ctx, col, GRN_RECORD_VALUE(rec), &value); } else { ERR(GRN_INVALID_ARGUMENT, "col resolve failed"); + GRN_OBJ_FIN(ctx, &value); goto exit; } - if (size == GRN_OBJ_GET_VALUE_IMD) { - GRN_RECORD_SET(ctx, res, (uintptr_t)value); - } else { - if (value) { - if (res->header.type == GRN_VECTOR) { - grn_vector_decode(ctx, res, value, size); - } else { - grn_bulk_write_from(ctx, res, value, 0, size); - } - } + switch (res->header.type) { + case GRN_VECTOR : + grn_vector_decode(ctx, res, + GRN_BULK_HEAD(&value), GRN_BULK_VSIZE(&value)); + break; + case GRN_TABLE_NO_KEY : + case GRN_TABLE_HASH_KEY : + case GRN_TABLE_PAT_KEY : + case GRN_TABLE_DAT_KEY : + GRN_RECORD_SET(ctx, res, GRN_RECORD_VALUE(&value)); + break; + default : + grn_bulk_write_from(ctx, + res, + GRN_BULK_HEAD(&value), + 0, + GRN_BULK_VSIZE(&value)); + break; } code++; } while (code < ce && code->op == GRN_OP_GET_VALUE); + GRN_OBJ_FIN(ctx, &value); } break; case GRN_OP_OBJ_SEARCH : Added: test/command/suite/select/query/not/key/double_array_trie/uint64.expected (+11 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/query/not/key/double_array_trie/uint64.expected 2013-02-25 23:22:33 +0900 (4ac983d) @@ -0,0 +1,11 @@ +table_create UInt64Values TABLE_DAT_KEY UInt64 +[[0,0.0,0.0],true] +load --table UInt64Values +[ +{"_key": 29}, +{"_key": 2929}, +{"_key": 292929} +] +[[0,0.0,0.0],3] +select UInt64Values --query _key:!2929 +[[0,0.0,0.0],[[[2],[["_id","UInt32"],["_key","UInt64"]],[1,29],[3,292929]]]] Added: test/command/suite/select/query/not/key/double_array_trie/uint64.test (+10 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/query/not/key/double_array_trie/uint64.test 2013-02-25 23:22:33 +0900 (c8a5fbd) @@ -0,0 +1,10 @@ +table_create UInt64Values TABLE_DAT_KEY UInt64 + +load --table UInt64Values +[ +{"_key": 29}, +{"_key": 2929}, +{"_key": 292929} +] + +select UInt64Values --query _key:!2929 Added: test/command/suite/select/query/not/key/hash/uint64.expected (+11 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/query/not/key/hash/uint64.expected 2013-02-25 23:22:33 +0900 (d1f0912) @@ -0,0 +1,11 @@ +table_create UInt64Values TABLE_HASH_KEY UInt64 +[[0,0.0,0.0],true] +load --table UInt64Values +[ +{"_key": 29}, +{"_key": 2929}, +{"_key": 292929} +] +[[0,0.0,0.0],3] +select UInt64Values --query _key:!2929 +[[0,0.0,0.0],[[[2],[["_id","UInt32"],["_key","UInt64"]],[1,29],[3,292929]]]] Added: test/command/suite/select/query/not/key/hash/uint64.test (+10 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/query/not/key/hash/uint64.test 2013-02-25 23:22:33 +0900 (1997369) @@ -0,0 +1,10 @@ +table_create UInt64Values TABLE_HASH_KEY UInt64 + +load --table UInt64Values +[ +{"_key": 29}, +{"_key": 2929}, +{"_key": 292929} +] + +select UInt64Values --query _key:!2929 Added: test/command/suite/select/query/not/key/patricia_trie/uint64.expected (+11 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/query/not/key/patricia_trie/uint64.expected 2013-02-25 23:22:33 +0900 (3e25ce5) @@ -0,0 +1,11 @@ +table_create UInt64Values TABLE_PAT_KEY UInt64 +[[0,0.0,0.0],true] +load --table UInt64Values +[ +{"_key": 29}, +{"_key": 2929}, +{"_key": 292929} +] +[[0,0.0,0.0],3] +select UInt64Values --query _key:!2929 +[[0,0.0,0.0],[[[2],[["_id","UInt32"],["_key","UInt64"]],[1,29],[3,292929]]]] Added: test/command/suite/select/query/not/key/patricia_trie/uint64.test (+10 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/select/query/not/key/patricia_trie/uint64.test 2013-02-25 23:22:33 +0900 (905ccc7) @@ -0,0 +1,10 @@ +table_create UInt64Values TABLE_PAT_KEY UInt64 + +load --table UInt64Values +[ +{"_key": 29}, +{"_key": 2929}, +{"_key": 292929} +] + +select UInt64Values --query _key:!2929 -------------- next part -------------- HTML����������������������������...Download