Kouhei Sutou
null+****@clear*****
Mon Jan 25 17:36:28 JST 2016
Kouhei Sutou 2016-01-25 17:36:28 +0900 (Mon, 25 Jan 2016) New Revision: 6d0adf67c585ceb23728c0a895ecdf35133cf797 https://github.com/groonga/groonga/commit/6d0adf67c585ceb23728c0a895ecdf35133cf797 Message: test grndb check: support recursive check for data column Modified files: lib/mrb/scripts/command_line/grndb.rb test/command_line/suite/grndb/test_check.rb Modified: lib/mrb/scripts/command_line/grndb.rb (+15 -0) =================================================================== --- lib/mrb/scripts/command_line/grndb.rb 2016-01-25 17:36:10 +0900 (9ae644d) +++ lib/mrb/scripts/command_line/grndb.rb 2016-01-25 17:36:28 +0900 (7861624) @@ -176,6 +176,12 @@ module Groonga return end + check_object_recursive(database, target, options, arguments) + end + + def check_object_recursive(database, target, options, arguments) + context = Context.instance + check_object(target, options, arguments) case target when Table @@ -188,6 +194,15 @@ module Groonga check_object(column, options, arguments) end end + when FixedSizeColumn, VariableSizeColumn + range_id = target.range_id + range = context[range_id] + if range.nil? + record = Record.new(database, range_id) + failed_to_open(record.key) + elsif range.is_a?(Table) + check_object_recursive(database, range, options, arguments) + end end end Modified: test/command_line/suite/grndb/test_check.rb (+22 -0) =================================================================== --- test/command_line/suite/grndb/test_check.rb 2016-01-25 17:36:10 +0900 (45bd285) +++ test/command_line/suite/grndb/test_check.rb 2016-01-25 17:36:28 +0900 (6ea63fb) @@ -89,5 +89,27 @@ Database is locked. It may be broken. Re-create the database. [Users.age] Data column is locked. It may be broken. (1) Truncate the column (truncate Users.age) or clear lock of the column (lock_clear Users.age) and (2) load data again. MESSAGE end + + def test_referenced_table + groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText") + groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8") + + groonga("table_create", "Bookmarks", "TABLE_HASH_KEY", "ShortText") + groonga("column_create", "Bookmarks", "user", "COLUMN_SCALAR", "Users") + + groonga("lock_acquire", "Users") + groonga("lock_acquire", "Users.age") + groonga("lock_acquire", "Bookmarks") + groonga("lock_acquire", "Bookmarks.user") + + error = assert_raise(CommandRunner::Error) do + grndb("check", "--target", "Bookmarks.user") + end + assert_equal(<<-MESSAGE, error.error_output) +[Bookmarks.user] Data column is locked. It may be broken. (1) Truncate the column (truncate Bookmarks.user) or clear lock of the column (lock_clear Bookmarks.user) and (2) load data again. +[Users] Table is locked. It may be broken. (1) Truncate the table (truncate Users) or clear lock of the table (lock_clear Users) and (2) load data again. +[Users.age] Data column is locked. It may be broken. (1) Truncate the column (truncate Users.age) or clear lock of the column (lock_clear Users.age) and (2) load data again. + MESSAGE + end end end -------------- next part -------------- HTML����������������������������...Download