null+****@clear*****
null+****@clear*****
2012年 2月 14日 (火) 13:59:10 JST
Kouhei Sutou 2012-02-14 13:59:10 +0900 (Tue, 14 Feb 2012) New Revision: af9883163a5f2b2f09cd9d47c31ba4db8d179402 Log: Revert "[table_create] supported --normalizer." This reverts commit edfe27730eacd23a46cea331300192af89fcd02e. Modified files: lib/proc.c test/unit/core/test-command-table-create.c Modified: lib/proc.c (+12 -57) =================================================================== --- lib/proc.c 2012-02-14 13:59:02 +0900 (b8fb21e) +++ lib/proc.c 2012-02-14 13:59:10 +0900 (613f1f8) @@ -819,7 +819,7 @@ grn_column_create_flags_to_text(grn_ctx *ctx, grn_obj *buf, grn_obj_flags flags) static grn_obj * proc_table_create(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data) { - grn_obj *table, *table_name; + grn_obj *table; const char *rest; grn_obj_flags flags = grn_atoi(GRN_TEXT_VALUE(VAR(1)), GRN_BULK_CURR(VAR(1)), &rest); @@ -828,9 +828,7 @@ proc_table_create(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_d GRN_BULK_CURR(VAR(1))); if (ctx->rc) { goto exit; } } - - table_name = VAR(0); - if (GRN_TEXT_LEN(table_name)) { + if (GRN_TEXT_LEN(VAR(0))) { grn_obj *key_type = NULL, *value_type = NULL; if (GRN_TEXT_LEN(VAR(2)) > 0) { key_type = grn_ctx_get(ctx, GRN_TEXT_VALUE(VAR(2)), @@ -838,7 +836,7 @@ proc_table_create(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_d if (!key_type) { ERR(GRN_INVALID_ARGUMENT, "[table][create] key type doesn't exist: <%.*s> (%.*s)", - GRN_TEXT_LEN(table_name), GRN_TEXT_VALUE(table_name), + GRN_TEXT_LEN(VAR(0)), GRN_TEXT_VALUE(VAR(0)), GRN_TEXT_LEN(VAR(2)), GRN_TEXT_VALUE(VAR(2))); return NULL; } @@ -849,66 +847,24 @@ proc_table_create(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_d if (!value_type) { ERR(GRN_INVALID_ARGUMENT, "[table][create] value type doesn't exist: <%.*s> (%.*s)", - GRN_TEXT_LEN(table_name), GRN_TEXT_VALUE(table_name), + GRN_TEXT_LEN(VAR(0)), GRN_TEXT_VALUE(VAR(0)), GRN_TEXT_LEN(VAR(3)), GRN_TEXT_VALUE(VAR(3))); return NULL; } } flags |= GRN_OBJ_PERSISTENT; table = grn_table_create(ctx, - GRN_TEXT_VALUE(table_name), - GRN_TEXT_LEN(table_name), + GRN_TEXT_VALUE(VAR(0)), + GRN_TEXT_LEN(VAR(0)), NULL, flags, key_type, value_type); if (table) { - grn_obj *tokenizer_name; - grn_obj *normalizer_name; - - tokenizer_name = VAR(4); - normalizer_name = VAR(5); - - if (GRN_TEXT_LEN(tokenizer_name)) { - grn_obj *tokenizer; - - tokenizer = grn_ctx_get(ctx, - GRN_TEXT_VALUE(tokenizer_name), - GRN_TEXT_LEN(tokenizer_name)); - if (tokenizer) { - grn_obj_set_info(ctx, table, GRN_INFO_DEFAULT_TOKENIZER, tokenizer); - } else { - ERR(GRN_INVALID_ARGUMENT, - "[table][create] unknown default tokenizer is specified: " - "<%.*s> (%.*s)", - GRN_TEXT_LEN(table_name), GRN_TEXT_VALUE(table_name), - GRN_TEXT_LEN(tokenizer_name), GRN_TEXT_VALUE(tokenizer_name)); - grn_obj_remove(ctx, table); - table = NULL; - } - } - - if (GRN_TEXT_LEN(normalizer_name)) { - grn_obj *normalizer; - - normalizer = grn_ctx_get(ctx, - GRN_TEXT_VALUE(normalizer_name), - GRN_TEXT_LEN(normalizer_name)); - if (normalizer) { - grn_obj_set_info(ctx, table, GRN_INFO_NORMALIZER, normalizer); - } else { - ERR(GRN_INVALID_ARGUMENT, - "[table][create] unknown normalizer is specified: ", - "<%.*s> (%.*s)", - GRN_TEXT_LEN(table_name), GRN_TEXT_VALUE(table_name), - GRN_TEXT_LEN(normalizer_name), GRN_TEXT_VALUE(normalizer_name)); - grn_obj_remove(ctx, table); - table = NULL; - } - } - - if (table) { - grn_obj_unlink(ctx, table); - } + grn_obj_set_info(ctx, table, + GRN_INFO_DEFAULT_TOKENIZER, + grn_ctx_get(ctx, GRN_TEXT_VALUE(VAR(4)), + GRN_TEXT_LEN(VAR(4)))); + grn_obj_unlink(ctx, table); } } else { ERR(GRN_INVALID_ARGUMENT, @@ -2927,8 +2883,7 @@ grn_db_init_builtin_query(grn_ctx *ctx) DEF_VAR(vars[2], "key_type"); DEF_VAR(vars[3], "value_type"); DEF_VAR(vars[4], "default_tokenizer"); - DEF_VAR(vars[5], "normalizer"); - DEF_COMMAND("table_create", proc_table_create, 6, vars); + DEF_COMMAND("table_create", proc_table_create, 5, vars); DEF_VAR(vars[0], "name"); DEF_COMMAND("table_remove", proc_table_remove, 1, vars); Modified: test/unit/core/test-command-table-create.c (+0 -14) =================================================================== --- test/unit/core/test-command-table-create.c 2012-02-14 13:59:02 +0900 (0b73c66) +++ test/unit/core/test-command-table-create.c 2012-02-14 13:59:10 +0900 (4f1e772) @@ -28,7 +28,6 @@ void test_pat_key(void); void test_dat_key(void); void test_no_key(void); void test_default_tokenizer(void); -void test_normalizer(void); void test_invalid_name(void); @@ -138,19 +137,6 @@ test_default_tokenizer(void) } void -test_normalizer(void) -{ - grn_obj *normalizer; - assert_send_command("table_create Users TABLE_PAT_KEY ShortText " - "--normalizer NormalizerASCII"); - grn_test_assert_users_exist(); - normalizer = grn_obj_get_info(context, users, GRN_INFO_NORMALIZER, NULL); - grn_test_assert_equal_id(context, - GRN_DB_NORMALIZER_ASCII, - grn_obj_id(context, normalizer)); -} - -void test_invalid_name(void) { grn_test_assert_send_command_error(