[Groonga-commit] groonga/groonga at 242250d [master] Describe "table_remove" with more meaningful examples

Back to archive index

YUKI Hiroshi yuki****@clear*****
Tue Mar 22 19:27:33 JST 2016


再帰削除、という感じの言い方で聞いていた気がしたのでその単語を使ってしま
いました。
書き直した後の例だと「UserIdテーブルを消すと、それに依存している
AdminUserテーブルも消えます」という風になってるんですが、ここでさらに
「AdminUserテーブルに依存してるテーブルまで一気に消える」なら「再帰的」
と言っても嘘にはならないのではないかと思います。

ただ、一般的に再帰的な削除というとこの逆方向(AdminUserを消したら、そこ
からしか参照されていないUserIdも消す)をイメージする感覚が自分にはあるの
で、そういう意味で「再帰的」という表現は適していないという指摘はありうる
と思います。
こっちの意味で「再帰的」ではないということであれば、うーん、
「依存関係に矛盾が発生しないように自動的に他のテーブルを消す」あたりにな
るんですかね……



Kouhei Sutou wrote:
> "recursive"じゃないので"recursive"という単語を意図的に避けて
> いたんですが、"recursive"と説明した方がよさそうでしょうか?
> 
> In <242250d3f9a8fe3f13ba8347b25c0aafd27b878f �� jenkins.clear-code.com>
>    "[Groonga-commit] groonga/groonga �� 242250d [master] Describe "table_remove" with more meaningful examples" on Tue, 22 Mar 2016 18:24:34 +0900,
>    YUKI Hiroshi <null+groonga �� clear-code.com> wrote:
> 
>> YUKI Hiroshi	2016-03-22 18:24:34 +0900 (Tue, 22 Mar 2016)
>>
>>    New Revision: 242250d3f9a8fe3f13ba8347b25c0aafd27b878f
>>    https://github.com/groonga/groonga/commit/242250d3f9a8fe3f13ba8347b25c0aafd27b878f
>>
>>    Message:
>>      Describe "table_remove" with more meaningful examples
>>
>>    Modified files:
>>      doc/source/example/reference/commands/table_remove/remove_dependents_default.log
>>      doc/source/example/reference/commands/table_remove/remove_dependents_schema.log
>>      doc/source/example/reference/commands/table_remove/remove_dependents_yes.log
>>      doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_create.log
>>      doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_remove_fail.log
>>      doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_remove_success.log
>>      doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_create.log
>>      doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_remove_fail.log
>>      doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_remove_success.log
>>      doc/source/reference/commands/table_remove.rst
>>
>>    Modified: doc/source/example/reference/commands/table_remove/remove_dependents_default.log (+2 -2)
>> ===================================================================
>> --- doc/source/example/reference/commands/table_remove/remove_dependents_default.log    2016-03-22 18:22:30 +0900 (3639ead)
>> +++ doc/source/example/reference/commands/table_remove/remove_dependents_default.log    2016-03-22 18:24:34 +0900 (eb4d5df)
>> @@ -1,12 +1,12 @@
>>   Execution example::
>>   
>> -  table_remove ReferencedTable
>> +  table_remove UserId
>>     # [
>>     #   [
>>     #     -2,
>>     #     1337566253.89858,
>>     #     0.000355720520019531,
>> -  #     "[table][remove] a table that references the table exists: <Table1._key> -> <ReferencedTable>",
>> +  #     "[table][remove] a table that references the table exists: <AdminUser._key> -> <UserId>",
>>     #     [
>>     #       [
>>     #         "is_removable_table",
>>
>>    Modified: doc/source/example/reference/commands/table_remove/remove_dependents_schema.log (+4 -4)
>> ===================================================================
>> --- doc/source/example/reference/commands/table_remove/remove_dependents_schema.log    2016-03-22 18:22:30 +0900 (463ecf1)
>> +++ doc/source/example/reference/commands/table_remove/remove_dependents_schema.log    2016-03-22 18:24:34 +0900 (3e8129d)
>> @@ -1,10 +1,10 @@
>>   Execution example::
>>   
>> -  table_create ReferencedTable TABLE_HASH_KEY ShortText
>> +  table_create UserId TABLE_HASH_KEY ShortText
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>> -  table_create Table1 TABLE_HASH_KEY ReferencedTable
>> +  table_create AdminUser TABLE_HASH_KEY UserId
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>> -  table_create Table2 TABLE_NO_KEY
>> +  table_create GeneralUser TABLE_NO_KEY
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>> -  column_create Table2 reference_column COLUMN_SCALAR ReferencedTable
>> +  column_create GeneralUser id COLUMN_SCALAR UserId
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>>
>>    Modified: doc/source/example/reference/commands/table_remove/remove_dependents_yes.log (+1 -1)
>> ===================================================================
>> --- doc/source/example/reference/commands/table_remove/remove_dependents_yes.log    2016-03-22 18:22:30 +0900 (352a6db)
>> +++ doc/source/example/reference/commands/table_remove/remove_dependents_yes.log    2016-03-22 18:24:34 +0900 (5aaf9b6)
>> @@ -1,4 +1,4 @@
>>   Execution example::
>>   
>> -  table_remove ReferencedTable --dependent yes
>> +  table_remove UserId --dependent yes
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>>
>>    Modified: doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_create.log (+2 -2)
>> ===================================================================
>> --- doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_create.log    2016-03-22 18:22:30 +0900 (57d9e4a)
>> +++ doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_create.log    2016-03-22 18:24:34 +0900 (c4698fc)
>> @@ -1,6 +1,6 @@
>>   Execution example::
>>   
>> -  table_create ReferencedByTable TABLE_HASH_KEY ShortText
>> +  table_create UserId TABLE_HASH_KEY ShortText
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>> -  table_create ReferenceTable TABLE_HASH_KEY ReferencedByTable
>> +  table_create AdminUser TABLE_HASH_KEY UserId
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>>
>>    Modified: doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_remove_fail.log (+2 -2)
>> ===================================================================
>> --- doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_remove_fail.log    2016-03-22 18:22:30 +0900 (6be7b00)
>> +++ doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_remove_fail.log    2016-03-22 18:24:34 +0900 (eb4d5df)
>> @@ -1,12 +1,12 @@
>>   Execution example::
>>   
>> -  table_remove ReferencedByTable
>> +  table_remove UserId
>>     # [
>>     #   [
>>     #     -2,
>>     #     1337566253.89858,
>>     #     0.000355720520019531,
>> -  #     "[table][remove] a table that references the table exists: <ReferenceTable._key> -> <ReferencedByTable>",
>> +  #     "[table][remove] a table that references the table exists: <AdminUser._key> -> <UserId>",
>>     #     [
>>     #       [
>>     #         "is_removable_table",
>>
>>    Modified: doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_remove_success.log (+2 -2)
>> ===================================================================
>> --- doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_remove_success.log    2016-03-22 18:22:30 +0900 (64711f5)
>> +++ doc/source/example/reference/commands/table_remove/unremovable_cases_key_type_remove_success.log    2016-03-22 18:24:34 +0900 (57075cb)
>> @@ -1,6 +1,6 @@
>>   Execution example::
>>   
>> -  table_remove ReferenceTable
>> +  table_remove AdminUser
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>> -  table_remove ReferencedByTable
>> +  table_remove UserId
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>>
>>    Modified: doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_create.log (+3 -3)
>> ===================================================================
>> --- doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_create.log    2016-03-22 18:22:30 +0900 (bfc297e)
>> +++ doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_create.log    2016-03-22 18:24:34 +0900 (3de8d33)
>> @@ -1,8 +1,8 @@
>>   Execution example::
>>   
>> -  table_create ReferencedByColumn TABLE_HASH_KEY ShortText
>> +  table_create UserId TABLE_HASH_KEY ShortText
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>> -  table_create Table TABLE_NO_KEY
>> +  table_create GeneralUser TABLE_NO_KEY
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>> -  column_create Table reference_column COLUMN_SCALAR ReferencedByColumn
>> +  column_create GeneralUser id COLUMN_SCALAR UserId
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>>
>>    Modified: doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_remove_fail.log (+2 -2)
>> ===================================================================
>> --- doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_remove_fail.log    2016-03-22 18:22:30 +0900 (68c6360)
>> +++ doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_remove_fail.log    2016-03-22 18:24:34 +0900 (071e51d)
>> @@ -1,12 +1,12 @@
>>   Execution example::
>>   
>> -  table_remove ReferencedByColumn
>> +  table_remove UserId
>>     # [
>>     #   [
>>     #     -2,
>>     #     1337566253.89858,
>>     #     0.000355720520019531,
>> -  #     "[table][remove] a column that references the table exists: <Table.reference_column> -> <ReferencedByColumn>",
>> +  #     "[table][remove] a column that references the table exists: <GeneralUser.id> -> <ReferencedByColumn>",
>>     #     [
>>     #       [
>>     #         "is_removable_table",
>>
>>    Modified: doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_remove_success.log (+2 -2)
>> ===================================================================
>> --- doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_remove_success.log    2016-03-22 18:22:30 +0900 (a7130e2)
>> +++ doc/source/example/reference/commands/table_remove/unremovable_cases_value_type_remove_success.log    2016-03-22 18:24:34 +0900 (1bbdc3e)
>> @@ -1,6 +1,6 @@
>>   Execution example::
>>   
>> -  column_remove Table reference_column
>> +  column_remove GeneralUser id
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>> -  table_remove ReferencedByColumn
>> +  table_remove UserId
>>     # [[0, 1337566253.89858, 0.000355720520019531], true]
>>
>>    Modified: doc/source/reference/commands/table_remove.rst (+60 -58)
>> ===================================================================
>> --- doc/source/reference/commands/table_remove.rst    2016-03-22 18:22:30 +0900 (26d0300)
>> +++ doc/source/reference/commands/table_remove.rst    2016-03-22 18:24:34 +0900 (4577a87)
>> @@ -17,8 +17,10 @@ removed.
>>   
>>   .. versionadded:: 6.0.1
>>   
>> -   You can also remove tables and columns that reference the target
>> -   table by using ``dependent`` parameter.
>> +   This command removes tables and columns recursively, with the
>> +   ``dependent`` parameter. If you specify ``--dependent yes``,
>> +   then other tables and columns depending on the disappearing table
>> +   are also removed recursively.
>>   
>>   Syntax
>>   ------
>> @@ -34,15 +36,15 @@ Usage
>>   -----
>>   
>>   You just specify table name that you want to remove. ``table_remove``
>> -removes the table and its columns. If the table and its columns are
>> -indexed, all index columns for the table and its columns are also
>> -removed.
>> +removes the specified table and its columns. If the table and its
>> +columns are indexed, all index columns for the table and its columns
>> +are also removed.
>>   
>>   This section describes about the followings:
>>   
>>     * Basic usage
>>     * Unremovable cases
>> -  * Removes a table with tables and columns that reference the target table
>> +  * Recursive removing of tables and columns
>>     * Decreases used resources
>>   
>>   .. _table-remove-basic-usage:
>> @@ -87,8 +89,8 @@ Let's confirm the current schema before running ``table_remove``:
>>   .. include:: ../../example/reference/commands/table_remove/basic_usage_dump_before_table_remove.log
>>   .. dump
>>   
>> -If you remove ``Entries`` table, the following tables and columns are
>> -removed:
>> +If you remove the ``Entries`` table, the following tables and columns
>> +are removed:
>>   
>>     * ``Entries``
>>     * ``Entries.title``
>> @@ -96,7 +98,7 @@ removed:
>>     * ``EntryKeys.key_index``
>>     * ``Terms.content_index``
>>   
>> -The following tables (lexicons) aren't removed:
>> +The following tables (lexicons) are left:
>>   
>>     * ``EntryKeys``
>>     * ``Terms``
>> @@ -119,102 +121,102 @@ Here is schema after ``table_remove``. Only ``EntryKeys`` and
>>   Unremovable cases
>>   ^^^^^^^^^^^^^^^^^
>>   
>> -There are some unremovable cases:
>> -
>> -  * One or more tables use the table as key type.
>> -  * One or more columns use the table as value type.
>> +You cannot remove a table, if there is any other table or column
>> +depending on it. In other words, any table satisfying one or more
>> +following conditions is unremovable.
>>   
>> -Both cases blocks dangling references. If the table is referenced as
>> -type and the table is removed, tables and columns that refer the table
>> -are broken.
>> +  * One or more tables use the table as their key type.
>> +  * One or more columns use the table as their value type.
>>   
>> -If the target table satisfies one of them, ``table_remove`` is
>> -failed. The target table and its columns aren't removed.
>> +To avoid breaking of left tables with missing references,
>> +``table_remove`` fails for such a depended (referenced) table.
>>   
>> -Here is an example for the table is used as key type case.
>> +Here is an example for a table which is used as key type.
>>   
>> -The following commands create a table to be removed and a table that
>> -uses the table to be removed as key type:
>> +The following commands create a table ``UserId`` going to be removed
>> +and another table ``AdminUser` depending on the first table via its key
>> +type:
>>   
>>   .. groonga-command
>>   .. include:: ../../example/reference/commands/table_remove/unremovable_cases_key_type_create.log
>> -.. table_create ReferencedByTable TABLE_HASH_KEY ShortText
>> -.. table_create ReferenceTable TABLE_HASH_KEY ReferencedByTable
>> +.. table_create UserId TABLE_HASH_KEY ShortText
>> +.. table_create AdminUser TABLE_HASH_KEY UserId
>>   
>> -``table_remove`` against ``ReferencedByTable`` is failed:
>> +``table_remove`` against ``UserId`` fails:
>>   
>>   .. groonga-command
>>   .. include:: ../../example/reference/commands/table_remove/unremovable_cases_key_type_remove_fail.log
>> -.. table_remove ReferencedByTable
>> +.. table_remove UserId
>>   
>> -You need to remove ``ReferenceTable`` before you remove
>> -``ReferencedByTable``:
>> +You need to remove ``AdminUser`` before ``UserId``:
>>   
>>   .. groonga-command
>>   .. include:: ../../example/reference/commands/table_remove/unremovable_cases_key_type_remove_success.log
>> -.. table_remove ReferenceTable
>> -.. table_remove ReferencedByTable
>> +.. table_remove AdminUser
>> +.. table_remove UserId
>>   
>> -Here is an example for the table is used as value type case.
>> +Here is another example for a table which is used as value type.
>>   
>> -The following commands create a table to be removed and a column that
>> -uses the table to be removed as value type:
>> +The following commands create a table ``UserId`` going to be removed
>> +and another table ``GeneralUser`` with a column depending on the first
>> +table via its value type:
>>   
>>   .. groonga-command
>>   .. include:: ../../example/reference/commands/table_remove/unremovable_cases_value_type_create.log
>> -.. table_create ReferencedByColumn TABLE_HASH_KEY ShortText
>> -.. table_create Table TABLE_NO_KEY
>> -.. column_create Table reference_column COLUMN_SCALAR ReferencedByColumn
>> +.. table_create UserId TABLE_HASH_KEY ShortText
>> +.. table_create GeneralUser TABLE_NO_KEY
>> +.. column_create GeneralUser id COLUMN_SCALAR UserId
>>   
>> -``table_remove`` against ``ReferencedByColumn`` is failed:
>> +``table_remove`` against ``UserId`` fails:
>>   
>>   .. groonga-command
>>   .. include:: ../../example/reference/commands/table_remove/unremovable_cases_value_type_remove_fail.log
>> -.. table_remove ReferencedByColumn
>> +.. table_remove UserId
>>   
>> -You need to remove ``Table.reference_column`` before you remove
>> -``ReferencedByColumn``:
>> +You need to remove ``GeneralUser.id`` before ``UserId``:
>>   
>>   .. groonga-command
>>   .. include:: ../../example/reference/commands/table_remove/unremovable_cases_value_type_remove_success.log
>> -.. column_remove Table reference_column
>> -.. table_remove ReferencedByColumn
>> +.. column_remove GeneralUser id
>> +.. table_remove UserId
>>   
>>   .. _table-remove-remove-dependents:
>>   
>> -Removes a table with tables and columns that reference the target table
>> -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> +Recursive removing of tables and columns
>> +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>   
>>   .. versionadded:: 6.0.1
>>   
>> -If you understand what you'll do, you can also remove tables and
>> -columns that reference the target table with one ``table_remove``
>> -command by using ``--dependent yes`` parameter.
>> +If you understand what you'll do, you can remove a table and other
>> +tables depending on it together at a time, by the ``--dependent yes``
>> +parameter.
>>   
>> -``ReferencedTable`` in the following schema is referenced from a table
>> +``UserId`` in the following schema is referenced from a table
>>   and a column:
>>   
>>   .. groonga-command
>>   .. include:: ../../example/reference/commands/table_remove/remove_dependents_schema.log
>> -.. table_create ReferencedTable TABLE_HASH_KEY ShortText
>> -.. table_create Table1 TABLE_HASH_KEY ReferencedTable
>> -.. table_create Table2 TABLE_NO_KEY
>> -.. column_create Table2 reference_column COLUMN_SCALAR ReferencedTable
>> +.. table_create UserId TABLE_HASH_KEY ShortText
>> +.. table_create AdminUser TABLE_HASH_KEY UserId
>> +.. table_create GeneralUser TABLE_NO_KEY
>> +.. column_create GeneralUser id COLUMN_SCALAR UserId
>>   
>> -You can't remove ``ReferencedTable`` by default:
>> +You can't remove ``UserId`` by default:
>>   
>>   .. groonga-command
>>   .. include:: ../../example/reference/commands/table_remove/remove_dependents_default.log
>> -.. table_remove ReferencedTable
>> +.. table_remove UserId
>>   
>> -You can remove ``ReferencedTable``, ``Table1`` and
>> -``Table2.reference_column`` by using ``--dependent yes``
>> -parameter. ``Table1`` and ``Table2.reference_column`` reference
>> -``ReferencedTable``:
>> +Additional parameter ``--dependent yes`` for the command line allows
>> +you to remove the ``UserId`` table, then both ``AdminUser`` and
>> +``GeneralUser.id`` depending on the ``UserId`` are also removed at a
>> +time:
>>   
>>   .. groonga-command
>>   .. include:: ../../example/reference/commands/table_remove/remove_dependents_yes.log
>> -.. table_remove ReferencedTable --dependent yes
>> +.. table_remove UserId --dependent yes
>> +
>> +After all, only the independent ``GeneralUser`` table is left.
>>   
>>   .. _table-remove-decreases-used-resources:
>>   
> 
> _______________________________________________
> Groonga-commit mailing list
> Groonga-commit �� lists.osdn.me
> http://lists.osdn.me/mailman/listinfo/groonga-commit
> 

-- 
結城 洋志 <YUKI Hiroshi>
E-mail: yuki �� clear-code.com

株式会社クリアコード
〒170-0005 東京都豊島区南大塚3-29-9
           中野ビル3階
TEL : 03-5927-9440
FAX : 03-5927-9441
WWW : http://www.clear-code.com/




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