null+****@clear*****
null+****@clear*****
2010年 10月 5日 (火) 15:48:51 JST
Kouhei Sutou 2010-10-05 06:48:51 +0000 (Tue, 05 Oct 2010)
New Revision: fae9609c06159e43e3b72d03278b28a3822fa7a0
Log:
fix all delete operations are failed. #541
Modified files:
lib/db.c
test/unit/core/test-command-delete.c
Modified: lib/db.c (+3 -1)
===================================================================
--- lib/db.c 2010-10-05 05:18:49 +0000 (096c9ff)
+++ lib/db.c 2010-10-05 06:48:51 +0000 (80ce1af)
@@ -1240,9 +1240,11 @@ grn_table_delete(grn_ctx *ctx, grn_obj *table, const void *key, unsigned key_siz
grn_rc rc = GRN_INVALID_ARGUMENT;
GRN_API_ENTER;
if (table) {
+ if (key && key_size) {
+ rid = grn_table_get(ctx, table, key, key_size);
+ }
if (is_deletable(ctx, table, rid)) {
if (key && key_size) {
- rid = grn_table_get(ctx, table, key, key_size);
call_delete_hook(ctx, table, rid, key, key_size);
}
switch (table->header.type) {
Modified: test/unit/core/test-command-delete.c (+12 -7)
===================================================================
--- test/unit/core/test-command-delete.c 2010-10-05 05:18:49 +0000 (7f71aa8)
+++ test/unit/core/test-command-delete.c 2010-10-05 06:48:51 +0000 (b98f70e)
@@ -58,9 +58,15 @@ setup_data(void)
{
assert_send_command("table_create Users TABLE_HASH_KEY ShortText");
assert_send_command("table_create Bookmarks TABLE_HASH_KEY ShortText");
+ assert_send_command("table_create Bigram TABLE_PAT_KEY ShortText "
+ "--default_tokenizer TokenBigram");
+
assert_send_command("column_create Bookmarks user COLUMN_SCALAR Users");
assert_send_command("column_create Users bookmarks COLUMN_INDEX "
"Bookmarks user");
+ assert_send_command("column_create Bigram user COLUMN_INDEX|WITH_POSITION "
+ "Users _key");
+
assert_send_command("load --table Users --columns '_key'\n"
"[\n"
" [\"mori\"],\n"
@@ -131,17 +137,17 @@ void
test_referenced_record(void)
{
assert_send_command_error(GRN_OPERATION_NOT_PERMITTED,
- "undeletable record (Users:3) "
+ "undeletable record (Users:4) "
"has value (bookmarks:1)",
- "delete Users yu");
- cut_assert_equal_string("[[[4],"
+ "delete Users tasukuchan");
+ cut_assert_equal_string("[[[2],"
"[[\"_key\",\"ShortText\"]],"
- "[\"mori\"],"
"[\"tapo\"],"
- "[\"yu\"],"
"[\"tasukuchan\"]]]",
send_command("select Users "
- "--output_columns _key"));
+ "--output_columns _key "
+ "--match_columns \"_key\" "
+ "--query \"ta\""));
}
void
@@ -160,4 +166,3 @@ test_uint64(void)
send_command("select Students "
"--output_columns _key"));
}
-