Kouhei Sutou
null+****@clear*****
Mon Apr 18 11:40:08 JST 2016
Kouhei Sutou 2016-04-18 11:40:08 +0900 (Mon, 18 Apr 2016) New Revision: 88aa4254f6facd9a8d4c02c29c35ce72f2d5be4b https://github.com/groonga/groonga/commit/88aa4254f6facd9a8d4c02c29c35ce72f2d5be4b Message: grndb: add a workaround for backward compatibility It's for users who used Groonga master at between 2016-02-03 and 2016-02-26. Groonga for the above span has "inspect" but Groonga since 2016-02-27 doesn't have "inspect". ("inspect" was renamed to "object_inspect".) Modified files: lib/db.c lib/mrb/scripts/command_line/grndb.rb Modified: lib/db.c (+22 -1) =================================================================== --- lib/db.c 2016-04-17 23:59:26 +0900 (7338403) +++ lib/db.c 2016-04-18 11:40:08 +0900 (7591ea9) @@ -13908,6 +13908,27 @@ grn_db_recover_index_column(grn_ctx *ctx, grn_obj *index_column) grn_index_column_rebuild(ctx, index_column); } +static grn_bool +grn_db_recover_is_builtin(grn_ctx *ctx, grn_id id, grn_table_cursor *cursor) +{ + char name[GRN_TABLE_MAX_KEY_SIZE]; + int name_size; + + if (id < GRN_N_RESERVED_TYPES) { + return GRN_TRUE; + } + + name_size = grn_table_cursor_get_key(ctx, cursor, (void **)&name); + name[name_size] = '\0'; + if (strcmp(name, "inspect") == 0) { + /* Just for compatibility. It's needed for users who used + Groonga master at between 2016-02-03 and 2016-02-26. */ + return GRN_TRUE; + } + + return GRN_FALSE; +} + grn_rc grn_db_recover(grn_ctx *ctx, grn_obj *db) { @@ -13952,7 +13973,7 @@ grn_db_recover(grn_ctx *ctx, grn_obj *db) } grn_obj_unlink(ctx, object); } else { - if (id < GRN_N_RESERVED_TYPES) { + if (grn_db_recover_is_builtin(ctx, id, cursor)) { ERRCLR(ctx); } } Modified: lib/mrb/scripts/command_line/grndb.rb (+12 -0) =================================================================== --- lib/mrb/scripts/command_line/grndb.rb 2016-04-17 23:59:26 +0900 (6dee132) +++ lib/mrb/scripts/command_line/grndb.rb 2016-04-18 11:40:08 +0900 (9870f1e) @@ -161,6 +161,7 @@ module Groonga context = Context.instance cursor.each do |id| next if ID.builtin?(id) + next if builtin_object_name?(cursor.key) next if context[id] failed_to_open(cursor.key) end @@ -287,6 +288,17 @@ module Groonga TableCursor.open(@database, :flags => flags, &block) end + def builtin_object_name?(name) + case name + when "inspect" + # Just for compatibility. It's needed for users who used + # Groonga master at between 2016-02-03 and 2016-02-26. + true + else + false + end + end + def failed(message) @on_failure.call(message) end -------------- next part -------------- HTML����������������������������... Download