[Groonga-commit] groonga/groonga [master] truncate: fix a bug that default_tokenizer is also truncated

Back to archive index

null+****@clear***** null+****@clear*****
2012年 4月 9日 (月) 10:50:30 JST


Kouhei Sutou	2012-04-09 10:50:30 +0900 (Mon, 09 Apr 2012)

  New Revision: 1f8c14bec46864f7d7fd6c2728ee1b1e6f569b6d

  Log:
    truncate: fix a bug that default_tokenizer is also truncated

  Added files:
    test/function/suite/truncate/default-tokenizer-dat.expected
    test/function/suite/truncate/default-tokenizer-dat.test
    test/function/suite/truncate/default-tokenizer-hash.expected
    test/function/suite/truncate/default-tokenizer-hash.test
    test/function/suite/truncate/default-tokenizer-pat.expected
    test/function/suite/truncate/default-tokenizer-pat.test
  Modified files:
    lib/db.c

  Modified: lib/db.c (+3 -0)
===================================================================
--- lib/db.c    2012-04-09 10:48:17 +0900 (84778e5)
+++ lib/db.c    2012-04-09 10:50:30 +0900 (a41364f)
@@ -1750,6 +1750,7 @@ grn_table_truncate(grn_ctx *ctx, grn_obj *table)
   if (table) {
     grn_hook *hooks;
     grn_hash *cols;
+    grn_obj *tokenizer;
     if ((cols = grn_hash_create(ctx, NULL, sizeof(grn_id), 0,
                                 GRN_OBJ_TABLE_HASH_KEY|GRN_HASH_TINY))) {
       if (grn_table_columns(ctx, table, "", 0, (grn_obj *)cols)) {
@@ -1761,6 +1762,7 @@ grn_table_truncate(grn_ctx *ctx, grn_obj *table)
       }
       grn_hash_close(ctx, cols);
     }
+    grn_table_get_info(ctx, table, NULL, NULL, &tokenizer);
     switch (table->header.type) {
     case GRN_TABLE_PAT_KEY :
       for (hooks = DB_OBJ(table)->hooks[GRN_HOOK_INSERT]; hooks; hooks = hooks->next) {
@@ -1793,6 +1795,7 @@ grn_table_truncate(grn_ctx *ctx, grn_obj *table)
       rc = grn_array_truncate(ctx, (grn_array *)table);
       break;
     }
+    grn_obj_set_info(ctx, table, GRN_INFO_DEFAULT_TOKENIZER, tokenizer);
     grn_obj_touch(ctx, table, NULL);
   }
 exit :

  Added: test/function/suite/truncate/default-tokenizer-dat.expected (+10 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/truncate/default-tokenizer-dat.expected    2012-04-09 10:50:30 +0900 (4ca6242)
@@ -0,0 +1,10 @@
+table_create Tags TABLE_DAT_KEY ShortText --default_tokenizer TokenDelimit
+[[0,0.0,0.0],true]
+dump
+table_create Tags TABLE_DAT_KEY ShortText --default_tokenizer TokenDelimit
+
+truncate Tags
+[[0,0.0,0.0],true]
+dump
+table_create Tags TABLE_DAT_KEY ShortText --default_tokenizer TokenDelimit
+

  Added: test/function/suite/truncate/default-tokenizer-dat.test (+5 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/truncate/default-tokenizer-dat.test    2012-04-09 10:50:30 +0900 (3287846)
@@ -0,0 +1,5 @@
+table_create Tags TABLE_DAT_KEY ShortText --default_tokenizer TokenDelimit
+dump
+
+truncate Tags
+dump

  Added: test/function/suite/truncate/default-tokenizer-hash.expected (+10 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/truncate/default-tokenizer-hash.expected    2012-04-09 10:50:30 +0900 (329b5f3)
@@ -0,0 +1,10 @@
+table_create Tags TABLE_HASH_KEY ShortText --default_tokenizer TokenDelimit
+[[0,0.0,0.0],true]
+dump
+table_create Tags TABLE_HASH_KEY ShortText --default_tokenizer TokenDelimit
+
+truncate Tags
+[[0,0.0,0.0],true]
+dump
+table_create Tags TABLE_HASH_KEY ShortText --default_tokenizer TokenDelimit
+

  Added: test/function/suite/truncate/default-tokenizer-hash.test (+5 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/truncate/default-tokenizer-hash.test    2012-04-09 10:50:30 +0900 (b168447)
@@ -0,0 +1,5 @@
+table_create Tags TABLE_HASH_KEY ShortText --default_tokenizer TokenDelimit
+dump
+
+truncate Tags
+dump

  Added: test/function/suite/truncate/default-tokenizer-pat.expected (+10 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/truncate/default-tokenizer-pat.expected    2012-04-09 10:50:30 +0900 (226fedc)
@@ -0,0 +1,10 @@
+table_create Tags TABLE_PAT_KEY ShortText --default_tokenizer TokenDelimit
+[[0,0.0,0.0],true]
+dump
+table_create Tags TABLE_PAT_KEY ShortText --default_tokenizer TokenDelimit
+
+truncate Tags
+[[0,0.0,0.0],true]
+dump
+table_create Tags TABLE_PAT_KEY ShortText --default_tokenizer TokenDelimit
+

  Added: test/function/suite/truncate/default-tokenizer-pat.test (+5 -0) 100644
===================================================================
--- /dev/null
+++ test/function/suite/truncate/default-tokenizer-pat.test    2012-04-09 10:50:30 +0900 (50e7967)
@@ -0,0 +1,5 @@
+table_create Tags TABLE_PAT_KEY ShortText --default_tokenizer TokenDelimit
+dump
+
+truncate Tags
+dump




Groonga-commit メーリングリストの案内
Back to archive index