Kouhei Sutou
null+****@clear*****
Fri Jul 19 18:39:20 JST 2013
Kouhei Sutou 2013-07-19 18:39:20 +0900 (Fri, 19 Jul 2013) New Revision: 9bf7595042f5fb2745c34eefccffd9cbde2774f8 https://github.com/groonga/groonga/commit/9bf7595042f5fb2745c34eefccffd9cbde2774f8 Message: Clear undeletable error for each record deletion when bulk delete If the error is not cleared, the next record may be cleared incompletely by detecting the error. This may cause a problem that inverted index has garbage. See the newly added test for the problem. Added files: test/command/suite/delete/filter/undeletable_records/fulltext_index.expected test/command/suite/delete/filter/undeletable_records/fulltext_index.test Modified files: lib/proc.c Modified: lib/proc.c (+3 -0) =================================================================== --- lib/proc.c 2013-07-19 18:21:38 +0900 (b794151) +++ lib/proc.c 2013-07-19 18:39:20 +0900 (34320f2) @@ -1980,6 +1980,9 @@ proc_delete(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) result_id, &key, NULL, NULL, { grn_id id = *(grn_id *)key; grn_table_delete_by_id(ctx, table, id); + if (ctx->rc == GRN_OPERATION_NOT_PERMITTED) { + ERRCLR(ctx); + } }); grn_obj_unlink(ctx, records); } Added: test/command/suite/delete/filter/undeletable_records/fulltext_index.expected (+140 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/delete/filter/undeletable_records/fulltext_index.expected 2013-07-19 18:39:20 +0900 (0194adc) @@ -0,0 +1,140 @@ +table_create Users TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +column_create Users name COLUMN_SCALAR ShortText +[[0,0.0,0.0],true] +table_create Bookmarks TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Bookmarks url COLUMN_SCALAR Text +[[0,0.0,0.0],true] +column_create Bookmarks user COLUMN_SCALAR Users +[[0,0.0,0.0],true] +column_create Users bookmakrs COLUMN_INDEX Bookmarks user +[[0,0.0,0.0],true] +table_create Names TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto +[[0,0.0,0.0],true] +column_create Names users_name COLUMN_INDEX|WITH_POSITION Users name +[[0,0.0,0.0],true] +load --table Users +[ +["_key", "name"], +["mori", "Daijiro MORI"], +["kou", "Kouhei Sutou"], +["s-yata", "Susumu Yata"] +] +[[0,0.0,0.0],3] +load --table Bookmarks +[ +["url", "user"], +["http://groonga.org/", "mori"], +["http://mroonga.org/", "mori"], +["http://groonga.org/", "s-yata"] +] +[[0,0.0,0.0],3] +delete --table Users --filter 'true' +[[0,0.0,0.0],true] +#|e| undeletable record (Users:1) has value (bookmakrs:4) +#|e| undeletable record (Users:3) has value (bookmakrs:1) +select --table Users +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 2 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "_key", + "ShortText" + ], + [ + "bookmakrs", + "Bookmarks" + ], + [ + "name", + "ShortText" + ] + ], + [ + 1, + "mori", + 4, + "Daijiro MORI" + ], + [ + 3, + "s-yata", + 1, + "Susumu Yata" + ] + ] + ] +] +select --table Names +[ + [ + 0, + 0.0, + 0.0 + ], + [ + [ + [ + 6 + ], + [ + [ + "_id", + "UInt32" + ], + [ + "_key", + "ShortText" + ], + [ + "users_name", + "Users" + ] + ], + [ + 1, + "daijiro", + 1 + ], + [ + 3, + "kouhei", + 0 + ], + [ + 2, + "mori", + 1 + ], + [ + 5, + "susumu", + 1 + ], + [ + 4, + "sutou", + 0 + ], + [ + 6, + "yata", + 1 + ] + ] + ] +] Added: test/command/suite/delete/filter/undeletable_records/fulltext_index.test (+32 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/delete/filter/undeletable_records/fulltext_index.test 2013-07-19 18:39:20 +0900 (27ad2d1) @@ -0,0 +1,32 @@ +table_create Users TABLE_HASH_KEY ShortText +column_create Users name COLUMN_SCALAR ShortText + +table_create Bookmarks TABLE_NO_KEY +column_create Bookmarks url COLUMN_SCALAR Text +column_create Bookmarks user COLUMN_SCALAR Users + +column_create Users bookmakrs COLUMN_INDEX Bookmarks user + +table_create Names TABLE_PAT_KEY ShortText \ + --default_tokenizer TokenBigram --normalizer NormalizerAuto +column_create Names users_name COLUMN_INDEX|WITH_POSITION Users name + +load --table Users +[ +["_key", "name"], +["mori", "Daijiro MORI"], +["kou", "Kouhei Sutou"], +["s-yata", "Susumu Yata"] +] + +load --table Bookmarks +[ +["url", "user"], +["http://groonga.org/", "mori"], +["http://mroonga.org/", "mori"], +["http://groonga.org/", "s-yata"] +] + +delete --table Users --filter 'true' +select --table Users +select --table Names -------------- next part -------------- HTML����������������������������...Download