Kouhei Sutou
null+****@clear*****
Sat Aug 3 12:11:46 JST 2013
Kouhei Sutou 2013-08-03 12:11:46 +0900 (Sat, 03 Aug 2013) New Revision: 047c8af18c9e7871dd07c71a106ac538fe03abb9 https://github.com/groonga/groonga/commit/047c8af18c9e7871dd07c71a106ac538fe03abb9 Message: Extract code that removes hash table Added files: test/command/suite/table_remove/hash/with_columns.expected test/command/suite/table_remove/hash/with_columns.test test/command/suite/table_remove/hash/without_columns.expected test/command/suite/table_remove/hash/without_columns.test Modified files: lib/db.c Modified: lib/db.c (+16 -9) =================================================================== --- lib/db.c 2013-08-03 12:10:07 +0900 (76723f6) +++ lib/db.c 2013-08-03 12:11:46 +0900 (c273f28) @@ -6670,6 +6670,21 @@ _grn_obj_remove_dat(grn_ctx *ctx, grn_obj *obj, grn_obj *db, grn_id id, } static void +_grn_obj_remove_hash(grn_ctx *ctx, grn_obj *obj, grn_obj *db, grn_id id, + const char *path) +{ + remove_index(ctx, obj, GRN_HOOK_INSERT); + remove_columns(ctx, obj); + grn_obj_close(ctx, obj); + if (path) { + grn_ja_put(ctx, ((grn_db *)db)->specs, id, NULL, 0, GRN_OBJ_SET, NULL); + grn_obj_delete_by_id(ctx, db, id, GRN_TRUE); + grn_hash_remove(ctx, path); + } + grn_obj_touch(ctx, db, NULL); +} + +static void _grn_obj_remove(grn_ctx *ctx, grn_obj *obj) { grn_id id = GRN_ID_NIL; @@ -6704,15 +6719,7 @@ _grn_obj_remove(grn_ctx *ctx, grn_obj *obj) _grn_obj_remove_dat(ctx, obj, db, id, path); break; case GRN_TABLE_HASH_KEY : - remove_index(ctx, obj, GRN_HOOK_INSERT); - remove_columns(ctx, obj); - grn_obj_close(ctx, obj); - if (path) { - grn_ja_put(ctx, ((grn_db *)db)->specs, id, NULL, 0, GRN_OBJ_SET, NULL); - grn_obj_delete_by_id(ctx, db, id, GRN_TRUE); - grn_hash_remove(ctx, path); - } - grn_obj_touch(ctx, db, NULL); + _grn_obj_remove_hash(ctx, obj, db, id, path); break; case GRN_TABLE_NO_KEY : remove_columns(ctx, obj); Added: test/command/suite/table_remove/hash/with_columns.expected (+11 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/table_remove/hash/with_columns.expected 2013-08-03 12:11:46 +0900 (30cca22) @@ -0,0 +1,11 @@ +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] +dump +table_create Users TABLE_HASH_KEY ShortText +column_create Users name COLUMN_SCALAR ShortText + +table_remove Users +[[0,0.0,0.0],true] +dump Added: test/command/suite/table_remove/hash/with_columns.test (+8 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/table_remove/hash/with_columns.test 2013-08-03 12:11:46 +0900 (99c1602) @@ -0,0 +1,8 @@ +table_create Users TABLE_HASH_KEY ShortText +column_create Users name COLUMN_SCALAR ShortText + +dump + +table_remove Users + +dump Added: test/command/suite/table_remove/hash/without_columns.expected (+8 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/table_remove/hash/without_columns.expected 2013-08-03 12:11:46 +0900 (ad0a5a0) @@ -0,0 +1,8 @@ +table_create Names TABLE_HASH_KEY ShortText +[[0,0.0,0.0],true] +dump +table_create Names TABLE_HASH_KEY ShortText + +table_remove Names +[[0,0.0,0.0],true] +dump Added: test/command/suite/table_remove/hash/without_columns.test (+7 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/table_remove/hash/without_columns.test 2013-08-03 12:11:46 +0900 (7eb728b) @@ -0,0 +1,7 @@ +table_create Names TABLE_HASH_KEY ShortText + +dump + +table_remove Names + +dump -------------- next part -------------- HTML����������������������������... 다운로드