null+****@clear*****
null+****@clear*****
2012年 7月 5日 (木) 12:35:42 JST
Daijiro MORI 2012-07-05 12:35:42 +0900 (Thu, 05 Jul 2012) New Revision: a61c71233bfa3246835b92474406f81558f394af https://github.com/groonga/groonga/commit/a61c71233bfa3246835b92474406f81558f394af Log: Fix returning a wrong error code which collapse ja columns. Added files: test/function/suite/load/invalid-geo-point-and-text.expected test/function/suite/load/invalid-geo-point-and-text.test Modified files: lib/store.c Modified: lib/store.c (+13 -4) =================================================================== --- lib/store.c 2012-07-05 10:55:42 +0900 (a39804d) +++ lib/store.c 2012-07-05 12:35:42 +0900 (c96693d) @@ -557,19 +557,24 @@ grn_ja_free(grn_ctx *ctx, grn_ja *ja, grn_ja_einfo *einfo) } grn_rc -grn_ja_replace(grn_ctx *ctx, grn_ja *ja, grn_id id, grn_ja_einfo *ei, uint64_t *cas) +grn_ja_replace(grn_ctx *ctx, grn_ja *ja, grn_id id, + grn_ja_einfo *ei, uint64_t *cas) { + grn_rc rc = GRN_SUCCESS; uint32_t lseg, *pseg, pos; grn_ja_einfo *einfo = NULL, eback; lseg = id >> JA_W_EINFO_IN_A_SEGMENT; pos = id & JA_M_EINFO_IN_A_SEGMENT; pseg = &ja->header->esegs[lseg]; - if (grn_io_lock(ctx, ja->io, 10000000)) { return ctx->rc; } + if (grn_io_lock(ctx, ja->io, 10000000)) { + return ctx->rc; + } if (*pseg == JA_ESEG_VOID) { int i = 0; while (SEGMENTS_AT(ja, i)) { if (++i >= JA_N_DSEGMENTS) { ERR(GRN_NOT_ENOUGH_SPACE, "grn_ja file (%s) is full", ja->io->path); + rc = GRN_NOT_ENOUGH_SPACE; goto exit; } } @@ -577,11 +582,15 @@ grn_ja_replace(grn_ctx *ctx, grn_ja *ja, grn_id id, grn_ja_einfo *ei, uint64_t * *pseg = i; } GRN_IO_SEG_REF(ja->io, *pseg, einfo); - if (!einfo) { goto exit; } + if (!einfo) { + rc = GRN_NO_MEMORY_AVAILABLE; + goto exit; + } eback = einfo[pos]; if (cas && *cas != *((uint64_t *)&eback)) { ERR(GRN_CAS_ERROR, "cas failed (%d)", id); GRN_IO_SEG_UNREF(ja->io, *pseg); + rc = GRN_CAS_ERROR; goto exit; } // smb_wmb(); @@ -594,7 +603,7 @@ grn_ja_replace(grn_ctx *ctx, grn_ja *ja, grn_id id, grn_ja_einfo *ei, uint64_t * grn_ja_free(ctx, ja, &eback); exit : grn_io_unlock(ja->io); - return ctx->rc; + return rc; } #define JA_N_GARBAGES_TH 10 Added: test/function/suite/load/invalid-geo-point-and-text.expected (+20 -0) 100644 =================================================================== --- /dev/null +++ test/function/suite/load/invalid-geo-point-and-text.expected 2012-07-05 12:35:42 +0900 (5e363a8) @@ -0,0 +1,20 @@ +table_create Hoge TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Hoge point COLUMN_SCALAR WGS84GeoPoint +[[0,0.0,0.0],true] +column_create Hoge text COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +load --table Hoge +[ +{"_key":"a","point":"x","text":"a0000000"}, +{"_key":"b","point":"x","text":"b0000000"}, +{"_key":"b","point":"x","text":"b0000001"}, +{"_key":"b","point":"x","text":"b0000002"}, +{"_key":"b","point":"x","text":"b0000003"}, +{"_key":"b","point":"x","text":"b0000004"}, +{"_key":"b","point":"x","text":"b0000005"}, +{"_key":"b","point":"x","text":"b0000006"} +] +[[0,0.0,0.0],8] +select Hoge --filter 'text == "a0000000"' --output_columns _key +[[0,0.0,0.0],[[[1],[["_key","ShortText"]],["a"]]]] Added: test/function/suite/load/invalid-geo-point-and-text.test (+17 -0) 100644 =================================================================== --- /dev/null +++ test/function/suite/load/invalid-geo-point-and-text.test 2012-07-05 12:35:42 +0900 (46768a2) @@ -0,0 +1,17 @@ +table_create Hoge TABLE_HASH_KEY ShortText +column_create Hoge point COLUMN_SCALAR WGS84GeoPoint +column_create Hoge text COLUMN_SCALAR ShortText + +load --table Hoge +[ +{"_key":"a","point":"x","text":"a0000000"}, +{"_key":"b","point":"x","text":"b0000000"}, +{"_key":"b","point":"x","text":"b0000001"}, +{"_key":"b","point":"x","text":"b0000002"}, +{"_key":"b","point":"x","text":"b0000003"}, +{"_key":"b","point":"x","text":"b0000004"}, +{"_key":"b","point":"x","text":"b0000005"}, +{"_key":"b","point":"x","text":"b0000006"} +] + +select Hoge --filter 'text == "a0000000"' --output_columns _key -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...다운로드