Kouhei Sutou
null+****@clear*****
Wed Feb 10 17:26:55 JST 2016
Kouhei Sutou 2016-02-10 17:26:55 +0900 (Wed, 10 Feb 2016) New Revision: 4bd351c7b9ee69a0ddb8e8ccf823901d41268cdd https://github.com/groonga/groonga/commit/4bd351c7b9ee69a0ddb8e8ccf823901d41268cdd Message: doc: add object_remove Added files: doc/source/example/reference/commands/object_remove/name_column.log doc/source/example/reference/commands/object_remove/usage.log doc/source/example/reference/commands/object_remove/usage_broken_with_force.log doc/source/example/reference/commands/object_remove/usage_broken_without_force.log doc/source/reference/commands/object_remove.rst Modified files: doc/update_execution_example.py Added: doc/source/example/reference/commands/object_remove/name_column.log (+8 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/object_remove/name_column.log 2016-02-10 17:26:55 +0900 (dbbc72f) @@ -0,0 +1,8 @@ +Execution example:: + + table_create Logs TABLE_NO_KEY + # [[0, 1337566253.89858, 0.000355720520019531], true] + column_create Logs timestamp COLUMN_SCALAR Time + # [[0, 1337566253.89858, 0.000355720520019531], true] + object_remove Logs.timestamp + # [[0, 1337566253.89858, 0.000355720520019531], true] Added: doc/source/example/reference/commands/object_remove/usage.log (+23 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/object_remove/usage.log 2016-02-10 17:26:55 +0900 (1ca7171) @@ -0,0 +1,23 @@ +Execution example:: + + object_remove Users + # [ + # [ + # -22, + # 1337566253.89858, + # 0.000355720520019531, + # "[object][remove] target object doesn't exist: <Users>", + # [ + # [ + # "command_object_remove", + # "proc_object.c", + # 121 + # ] + # ] + # ], + # false + # ] + table_create Users TABLE_HASH_KEY ShortText + # [[0, 1337566253.89858, 0.000355720520019531], true] + object_remove Users + # [[0, 1337566253.89858, 0.000355720520019531], true] Added: doc/source/example/reference/commands/object_remove/usage_broken_with_force.log (+21 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/object_remove/usage_broken_with_force.log 2016-02-10 17:26:55 +0900 (cfe4a7b) @@ -0,0 +1,21 @@ +Execution example:: + + object_remove Users --force yes + # [ + # [ + # -65, + # 1337566253.89858, + # 0.000355720520019531, + # "[io][open] file size is too small: <7>(required: >= 64): </tmp/groonga-databases/commands_object_remove.0000100>", + # [ + # [ + # "grn_io_open", + # "io.c", + # 565 + # ] + # ] + # ], + # false + # ] + object_exist Users + # [[0, 1337566253.89858, 0.000355720520019531], false] Added: doc/source/example/reference/commands/object_remove/usage_broken_without_force.log (+28 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/object_remove/usage_broken_without_force.log 2016-02-10 17:26:55 +0900 (8791209) @@ -0,0 +1,28 @@ +Execution example:: + + table_create Users TABLE_HASH_KEY ShortText + # [[0, 1337566253.89858, 0.000355720520019531], true] + thread_limit 1 + # [[0, 1337566253.89858, 0.000355720520019531], 1] + database_unmap + # [[0, 1337566253.89858, 0.000355720520019531], true] + echo "BROKEN" > ${DB_PATH}.0000100 + object_remove Users + # [ + # [ + # -22, + # 1337566253.89858, + # 0.000355720520019531, + # "[object][remove] failed to open the target object: <Users>", + # [ + # [ + # "command_object_remove", + # "proc_object.c", + # 116 + # ] + # ] + # ], + # false + # ] + object_exist Users + # [[0, 1337566253.89858, 0.000355720520019531], true] Added: doc/source/reference/commands/object_remove.rst (+140 -0) 100644 =================================================================== --- /dev/null +++ doc/source/reference/commands/object_remove.rst 2016-02-10 17:26:55 +0900 (0495560) @@ -0,0 +1,140 @@ +.. -*- rst -*- + +.. highlightlang:: none + +.. groonga-command +.. database: commands_object_remove + +``object_remove`` +================= + +Summary +------- + +.. versionadded:: 6.0.0 + +``object_remove`` removes an object. You can remove any object +including table, column, command and so on. Normally, you should use +specific remove command such as :doc:`table_remove` and +:doc:`column_remove`. + +``object_remove`` is danger because you can remove any object. You +should use ``object_remove`` carefully. + +``object_remove`` has "force mode". You can remove a broken object by +"force mode". "Force mode" is useful to resolve problems reported by +:doc:`/reference/executable/grndb`. + +Syntax +------ + +This command takes two parameters:: + + object_remove name + [force=no] + +Usage +----- + +You can remove an object in the database specified by ``name``: + +.. groonga-command +.. include:: ../../example/reference/commands/object_remove/usage.log +.. object_remove Users +.. table_create Users TABLE_HASH_KEY ShortText +.. object_remove Users + +The ``object_remove Users`` returns ``false`` before you create +``Users`` table. + +The ``object_remove Users`` returns ``true`` after you create ``Users`` +table. + +You can't remove a broken object by default: + +.. groonga-command +.. include:: ../../example/reference/commands/object_remove/usage_broken_without_force.log +.. table_create Users TABLE_HASH_KEY ShortText +.. thread_limit 1 +.. database_unmap +.. % echo "BROKEN" > ${DB_PATH}.0000100 +.. object_remove Users +.. object_exist Users + +You can remove a broken object by ``--force yes``: + +.. groonga-command +.. include:: ../../example/reference/commands/object_remove/usage_broken_with_force.log +.. object_remove Users --force yes +.. object_exist Users + +``--force yes`` means you enable "force mode". You can remove a broken +object in "force mode". + +Parameters +---------- + +This section describes all parameters. + +Required parameters +^^^^^^^^^^^^^^^^^^^ + +There is only one required parameters. + +.. _object-remove-name: + +``name`` +"""""""" + +Specifies the object name to be removed. + +If you want to remove a column, use ``TABLE_NAME.COLUMN_NAME`` format +like the following: + +.. groonga-command +.. include:: ../../example/reference/commands/object_remove/name_column.log +.. table_create Logs TABLE_NO_KEY +.. column_create Logs timestamp COLUMN_SCALAR Time +.. object_remove Logs.timestamp + +``Logs`` is table name and ``timestamp`` is column name in +``Logs.timestamp``. + +Optional parameters +^^^^^^^^^^^^^^^^^^^ + +There is one optional parameter. + +``force`` +""""""""" + +Specifies whether removing the object in "force mode". + +Normally, you can't remove a broken object. But you can remove a +broken object in "force mode". + +``force`` value must be ``yes`` or ``no``. ``yes`` means that "force +mode" is enabled. ``no`` means that "force mode" is disabled. + +The default value is ``no``. It means that "force mode" is disabled by +default. + +Return value +------------ + +The command returns ``true`` as body when the command removed the +specified object without any error. For example:: + + [HEADER, true] + +The command returns ``false`` as body when the command gets any +errors. For example:: + + [HEADER, false] + +See :doc:`/reference/command/output_format` for ``HEADER``. + +Note that ``false`` doesn't mean that "the command can't remove the +object". If you enable "force mode", the command removes the object +even if the object is broken. In the case, the object is removed and +``false`` is returned as body. Modified: doc/update_execution_example.py (+15 -6) =================================================================== --- doc/update_execution_example.py 2016-02-10 16:07:23 +0900 (e77d384) +++ doc/update_execution_example.py 2016-02-10 17:26:55 +0900 (aacf6eb) @@ -25,15 +25,24 @@ def close_groonga(): groonga_process = None print '###<<< database: close' +current_db_path = None def reconnect(name): global groonga_process + global current_db_path close_groonga() - db_path = os.path.join(DB_DIRECTORY, name) - if os.path.exists(db_path): - groonga_process = Popen(["groonga", db_path], stdin=PIPE, stdout=PIPE) + current_db_path = os.path.join(DB_DIRECTORY, name) + if os.path.exists(current_db_path): + groonga_process = Popen(["groonga", current_db_path], + stdin=PIPE, + stdout=PIPE) else: - groonga_process = Popen(["groonga", "-n", db_path], stdin=PIPE, stdout=PIPE) - print '###>>> database: open <%s>' % db_path + groonga_process = Popen(["groonga", "-n", current_db_path], + stdin=PIPE, + stdout=PIPE) + print '###>>> database: open <%s>' % current_db_path + +def expand_command_line(command_line): + return command_line.replace('${DB_PATH}', current_db_path) fout = None @@ -172,7 +181,7 @@ def readfile(fname, outflag): if fout: fout.write(" " + command_line + "\n") print command_line - os.system(command_line) + os.system(expand_command_line(command_line)) elif cmd.startswith('.. .. '): command_line = cmd[6:] if fout: -------------- next part -------------- HTML����������������������������...Download