Kouhei Sutou
null+****@clear*****
Sat Aug 3 20:31:18 JST 2013
Kouhei Sutou 2013-08-03 20:31:18 +0900 (Sat, 03 Aug 2013) New Revision: 66e998a5cd23a4cc5225c31851b48435c4ed13c5 https://github.com/groonga/groonga/commit/66e998a5cd23a4cc5225c31851b48435c4ed13c5 Message: table_remove: disable removing patricia trie table referenced by other patricia trie table Added files: test/command/suite/table_remove/patricia_trie/referenced/table_patricia_trie.expected test/command/suite/table_remove/patricia_trie/referenced/table_patricia_trie.test Modified files: lib/db.c Modified: lib/db.c (+19 -0) =================================================================== --- lib/db.c 2013-08-03 19:28:15 +0900 (33f80ca) +++ lib/db.c 2013-08-03 20:31:18 +0900 (fa98247) @@ -6663,6 +6663,25 @@ is_removable_table(grn_ctx *ctx, grn_obj *table, grn_obj *db) } switch (object->header.type) { + case GRN_TABLE_PAT_KEY : + if (DB_OBJ(object)->id == table_id) { + break; + } + + if (object->header.domain == table_id) { + char reference_table_name[GRN_TABLE_MAX_KEY_SIZE]; + int reference_table_name_size; + reference_table_name_size = + grn_obj_name(ctx, object, reference_table_name, + GRN_TABLE_MAX_KEY_SIZE); + ERR(GRN_OPERATION_NOT_PERMITTED, + "[table][remove] a table that references the table exists: " + "<%.*s._key> -> <%.*s>", + reference_table_name_size, reference_table_name, + table_name_size, table_name); + removable = GRN_FALSE; + } + break; case GRN_COLUMN_VAR_SIZE : case GRN_COLUMN_FIX_SIZE : if (object->header.domain == table_id) { Added: test/command/suite/table_remove/patricia_trie/referenced/table_patricia_trie.expected (+21 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/table_remove/patricia_trie/referenced/table_patricia_trie.expected 2013-08-03 20:31:18 +0900 (43abaa6) @@ -0,0 +1,21 @@ +table_create Names TABLE_PAT_KEY ShortText +[[0,0.0,0.0],true] +table_create Users TABLE_PAT_KEY Names +[[0,0.0,0.0],true] +table_remove Names +[ + [ + [ + -2, + 0.0, + 0.0 + ], + "[table][remove] a table that references the table exists: <Users._key> -> <Names>" + ], + false +] +#|e| [table][remove] a table that references the table exists: <Users._key> -> <Names> +dump +table_create Names TABLE_PAT_KEY ShortText +table_create Users TABLE_PAT_KEY Names + Added: test/command/suite/table_remove/patricia_trie/referenced/table_patricia_trie.test (+6 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/table_remove/patricia_trie/referenced/table_patricia_trie.test 2013-08-03 20:31:18 +0900 (2dd7d49) @@ -0,0 +1,6 @@ +table_create Names TABLE_PAT_KEY ShortText +table_create Users TABLE_PAT_KEY Names + +table_remove Names + +dump -------------- next part -------------- HTML����������������������������... 下載