Navigation Menu

Skip to content

Commit

Permalink
dump: add --dump_indexes option
Browse files Browse the repository at this point in the history
You can disable dumping indexes by "--dump_indexes no".
  • Loading branch information
kou committed Apr 4, 2015
1 parent b2aeffb commit f1cae9e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/proc.c
Expand Up @@ -3438,15 +3438,18 @@ proc_dump(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
grn_obj *dump_plugins_raw = VAR(1);
grn_obj *dump_schema_raw = VAR(2);
grn_obj *dump_records_raw = VAR(3);
grn_obj *dump_indexes_raw = VAR(4);
grn_bool is_dump_plugins;
grn_bool is_dump_schema;
grn_bool is_dump_records;
grn_bool is_dump_indexes;

grn_ctx_set_output_type(ctx, GRN_CONTENT_GROONGA_COMMAND_LIST);

is_dump_plugins = bool_option_value(dump_plugins_raw, GRN_TRUE);
is_dump_schema = bool_option_value(dump_schema_raw, GRN_TRUE);
is_dump_records = bool_option_value(dump_records_raw, GRN_TRUE);
is_dump_indexes = bool_option_value(dump_indexes_raw, GRN_TRUE);

if (is_dump_plugins) {
dump_plugins(ctx, outbuf);
Expand All @@ -3464,8 +3467,9 @@ proc_dump(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
dump_all_records(ctx, outbuf);
}
}

dump_indexes(ctx, outbuf);
if (is_dump_indexes) {
dump_indexes(ctx, outbuf);
}

/* remove the last newline because another one will be added by the caller.
maybe, the caller of proc functions currently doesn't consider the
Expand Down Expand Up @@ -6818,7 +6822,8 @@ grn_db_init_builtin_query(grn_ctx *ctx)
DEF_VAR(vars[1], "dump_plugins");
DEF_VAR(vars[2], "dump_schema");
DEF_VAR(vars[3], "dump_records");
DEF_COMMAND("dump", proc_dump, 4, vars);
DEF_VAR(vars[4], "dump_indexes");
DEF_COMMAND("dump", proc_dump, 5, vars);

/* Deprecated. Use "plugin_register" instead. */
DEF_VAR(vars[0], "path");
Expand Down
31 changes: 31 additions & 0 deletions test/command/suite/dump/schema/dump_indexes_no.expected
@@ -0,0 +1,31 @@
plugin_register token_filters/stop_word
[[0,0.0,0.0],true]
table_create Bookmarks TABLE_HASH_KEY ShortText
[[0,0.0,0.0],true]
column_create Bookmarks title COLUMN_SCALAR ShortText
[[0,0.0,0.0],true]
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]
column_create Users bookmark COLUMN_SCALAR Bookmarks
[[0,0.0,0.0],true]
column_create Bookmarks user COLUMN_SCALAR Users
[[0,0.0,0.0],true]
table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
[[0,0.0,0.0],true]
column_create Terms users_name_index COLUMN_INDEX|WITH_POSITION Users name
[[0,0.0,0.0],true]
dump --dump_indexes no
plugin_register token_filters/stop_word

table_create Bookmarks TABLE_HASH_KEY ShortText
column_create Bookmarks title COLUMN_SCALAR ShortText

table_create Users TABLE_HASH_KEY ShortText
column_create Users name COLUMN_SCALAR ShortText

table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto

column_create Bookmarks user COLUMN_SCALAR Users
column_create Users bookmark COLUMN_SCALAR Bookmarks
17 changes: 17 additions & 0 deletions test/command/suite/dump/schema/dump_indexes_no.test
@@ -0,0 +1,17 @@
plugin_register token_filters/stop_word

table_create Bookmarks TABLE_HASH_KEY ShortText
column_create Bookmarks title COLUMN_SCALAR ShortText

table_create Users TABLE_HASH_KEY ShortText
column_create Users name COLUMN_SCALAR ShortText

column_create Users bookmark COLUMN_SCALAR Bookmarks
column_create Bookmarks user COLUMN_SCALAR Users

table_create Terms TABLE_PAT_KEY ShortText \
--default_tokenizer TokenBigram \
--normalizer NormalizerAuto
column_create Terms users_name_index COLUMN_INDEX|WITH_POSITION Users name

dump --dump_indexes no

0 comments on commit f1cae9e

Please sign in to comment.