[Groonga-commit] groonga/groonga at 5c7f8e5 [master] grndb: check domain of table recursively

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jan 28 17:32:22 JST 2016


Kouhei Sutou	2016-01-28 17:32:22 +0900 (Thu, 28 Jan 2016)

  New Revision: 5c7f8e54b43d50cd4def7f4fa9dc2c1047ddf2b7
  https://github.com/groonga/groonga/commit/5c7f8e54b43d50cd4def7f4fa9dc2c1047ddf2b7

  Message:
    grndb: check domain of table recursively

  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 (+11 -0)
===================================================================
--- lib/mrb/scripts/command_line/grndb.rb    2016-01-30 22:58:44 +0900 (0b07ded)
+++ lib/mrb/scripts/command_line/grndb.rb    2016-01-28 17:32:22 +0900 (b8264b8)
@@ -211,6 +211,17 @@ module Groonga
           check_object(target)
           case target
           when Table
+            unless target.is_a?(Groonga::Array)
+              domain_id = target.domain_id
+              domain = @context[domain_id]
+              if domain.nil?
+                record = Record.new(@database, domain_id)
+                failed_to_open(record.key)
+              elsif domain.is_a?(Table)
+                check_object_recursive(domain)
+              end
+            end
+
             target.column_ids.each do |column_id|
               column = @context[column_id]
               if column.nil?

  Modified: test/command_line/suite/grndb/test_check.rb (+21 -1)
===================================================================
--- test/command_line/suite/grndb/test_check.rb    2016-01-30 22:58:44 +0900 (645f575)
+++ test/command_line/suite/grndb/test_check.rb    2016-01-28 17:32:22 +0900 (878c326)
@@ -90,7 +90,27 @@ Database is locked. It may be broken. Re-create the database.
       MESSAGE
     end
 
-    def test_referenced_table
+    def test_referenced_table_by_table
+      groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText")
+      groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8")
+
+      groonga("table_create", "Admins", "TABLE_HASH_KEY", "Users")
+
+      groonga("lock_acquire", "Users")
+      groonga("lock_acquire", "Users.age")
+      groonga("lock_acquire", "Admins")
+
+      error = assert_raise(CommandRunner::Error) do
+        grndb("check", "--target", "Admins")
+      end
+      assert_equal(<<-MESSAGE, error.error_output)
+[Admins] Table is locked. It may be broken. (1) Truncate the table (truncate Admins) or clear lock of the table (lock_clear Admins) 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
+
+    def test_referenced_table_by_column
       groonga("table_create", "Users", "TABLE_HASH_KEY", "ShortText")
       groonga("column_create", "Users", "age", "COLUMN_SCALAR", "UInt8")
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index