<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,25 @@
+2009-04-08  Mikio Hirabayashi  &lt;mikio@users.sourceforge.net&gt;
+
+	* tcutil.c (tcsleep): new function.
+
+	* tchdb.c (tchdbtranbegin): locking algorithm was modified.
+
+	* tchdb.c (tchdblocktran, tchdbunlocktran): abolished.
+
+	* tcbdb.c (tcbdbtranbegin): locking algorithm was modified.
+
+	* tcbdb.c (tcbdbcurjumpimpl): a bug related to cursor initialization was fixed.
+
+	* tcfdb.c (tcbdbtranbegin): locking algorithm was modified.
+
+	* tcfdb.c (tcfdblocktran, tcfdbunlocktran): abolished.
+
+	* tctdb.c (tctdbqryallcondmatch): a bug related to handling null value was fixed.
+
+	* tcadb.c (tcadboptimize, tcadbpath): new functions.
+
+	- Release: 1.4.15
+
 2009-04-07  Mikio Hirabayashi  &lt;mikio@users.sourceforge.net&gt;
 
 	* tcbdb.c (tcbdbputimpl, tcbdbcurputimpl): page size limitation was added.</diff>
      <filename>ChangeLog</filename>
    </modified>
    <modified>
      <diff>@@ -89,7 +89,7 @@ all : $(LIBRARYFILES) $(COMMANDFILES) $(CGIFILES)
 clean :
 	rm -rf $(LIBRARYFILES) $(LIBOBJFILES) $(COMMANDFILES) $(CGIFILES) \
 	  *.o a.out tokyocabinet_all.c check.in check.out gmon.out leak.log words.tsv \
-	  casket casket-* casket.* *.wal *~ hoge moge
+	  casket casket-* casket.* *.tch *.tcb *.tcf *.tct *.idx.* *.wal *~ hoge moge tako ika
 
 
 version :
@@ -518,6 +518,7 @@ check-adb :
 	$(RUNENV) $(RUNCMD) ./tcamgr get casket.tch four &gt; check.out
 	$(RUNENV) $(RUNCMD) ./tcamgr get casket.tch five &gt; check.out
 	$(RUNENV) $(RUNCMD) ./tcamgr list -pv -fm f casket.tch &gt; check.out
+	$(RUNENV) $(RUNCMD) ./tcamgr optimize casket.tch
 	$(RUNENV) $(RUNCMD) ./tcamgr put -dc casket.tch three third
 	$(RUNENV) $(RUNCMD) ./tcamgr get casket.tch three &gt; check.out
 	$(RUNENV) $(RUNCMD) ./tcamgr get casket.tch four &gt; check.out</diff>
      <filename>Makefile.in</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for tokyocabinet 1.4.14.
+# Generated by GNU Autoconf 2.61 for tokyocabinet 1.4.15.
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
 # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -572,8 +572,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='tokyocabinet'
 PACKAGE_TARNAME='tokyocabinet'
-PACKAGE_VERSION='1.4.14'
-PACKAGE_STRING='tokyocabinet 1.4.14'
+PACKAGE_VERSION='1.4.15'
+PACKAGE_STRING='tokyocabinet 1.4.15'
 PACKAGE_BUGREPORT=''
 
 # Factoring default headers for most tests.
@@ -1192,7 +1192,7 @@ if test &quot;$ac_init_help&quot; = &quot;long&quot;; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat &lt;&lt;_ACEOF
-\`configure' configures tokyocabinet 1.4.14 to adapt to many kinds of systems.
+\`configure' configures tokyocabinet 1.4.15 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1253,7 +1253,7 @@ fi
 
 if test -n &quot;$ac_init_help&quot;; then
   case $ac_init_help in
-     short | recursive ) echo &quot;Configuration of tokyocabinet 1.4.14:&quot;;;
+     short | recursive ) echo &quot;Configuration of tokyocabinet 1.4.15:&quot;;;
    esac
   cat &lt;&lt;\_ACEOF
 
@@ -1354,7 +1354,7 @@ fi
 test -n &quot;$ac_init_help&quot; &amp;&amp; exit $ac_status
 if $ac_init_version; then
   cat &lt;&lt;\_ACEOF
-tokyocabinet configure 1.4.14
+tokyocabinet configure 1.4.15
 generated by GNU Autoconf 2.61
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1368,7 +1368,7 @@ cat &gt;config.log &lt;&lt;_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by tokyocabinet $as_me 1.4.14, which was
+It was created by tokyocabinet $as_me 1.4.15, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   $ $0 $@
@@ -1724,7 +1724,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 # Package information
 MYLIBVER=8
-MYLIBREV=5
+MYLIBREV=6
 MYFORMATVER=&quot;1.0&quot;
 
 # Targets
@@ -6351,7 +6351,7 @@ exec 6&gt;&amp;1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log=&quot;
-This file was extended by tokyocabinet $as_me 1.4.14, which was
+This file was extended by tokyocabinet $as_me 1.4.15, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -6394,7 +6394,7 @@ Report bugs to &lt;bug-autoconf@gnu.org&gt;.&quot;
 _ACEOF
 cat &gt;&gt;$CONFIG_STATUS &lt;&lt;_ACEOF
 ac_cs_version=&quot;\\
-tokyocabinet config.status 1.4.14
+tokyocabinet config.status 1.4.15
 configured by $0, generated by GNU Autoconf 2.61,
   with options \\&quot;`echo &quot;$ac_configure_args&quot; | sed 's/^ //; s/[\\&quot;&quot;\`\$]/\\\\&amp;/g'`\\&quot;
 </diff>
      <filename>configure</filename>
    </modified>
    <modified>
      <diff>@@ -7,11 +7,11 @@
 #================================================================
 
 # Package name
-AC_INIT(tokyocabinet, 1.4.14)
+AC_INIT(tokyocabinet, 1.4.15)
 
 # Package information
 MYLIBVER=8
-MYLIBREV=5
+MYLIBREV=6
 MYFORMATVER=&quot;1.0&quot;
 
 # Targets</diff>
      <filename>configure.in</filename>
    </modified>
    <modified>
      <diff>@@ -126,7 +126,7 @@
 &lt;p&gt;The following are the source packages of Tokyo Cabinet.  As for binary packages, see the site of each distributor.&lt;/p&gt;
 
 &lt;ul&gt;
-&lt;li&gt;&lt;a href=&quot;tokyocabinet-1.4.14.tar.gz&quot;&gt;Latest Source Package (version 1.4.14)&lt;/a&gt;&lt;/li&gt;
+&lt;li&gt;&lt;a href=&quot;tokyocabinet-1.4.15.tar.gz&quot;&gt;Latest Source Package (version 1.4.15)&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;pastpkg/&quot;&gt;Past Versions&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;
 </diff>
      <filename>doc/index.html</filename>
    </modified>
    <modified>
      <diff>@@ -167,7 +167,7 @@
 &lt;p&gt;&#20197;&#19979;&#12398;&#12477;&#12540;&#12473;&#12497;&#12483;&#12465;&#12540;&#12472;&#12434;&#12480;&#12454;&#12531;&#12525;&#12540;&#12489;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12496;&#12452;&#12490;&#12522;&#12497;&#12483;&#12465;&#12540;&#12472;&#12395;&#12388;&#12356;&#12390;&#12399;&#12289;&#21508;&#12487;&#12451;&#12473;&#12488;&#12522;&#12499;&#12517;&#12540;&#12479;&#12398;&#12469;&#12452;&#12488;&#12434;&#12372;&#35239;&#12367;&#12384;&#12373;&#12356;&#12290;&lt;/p&gt;
 
 &lt;ul&gt;
-&lt;li&gt;&lt;a href=&quot;tokyocabinet-1.4.14.tar.gz&quot;&gt;&#26368;&#26032;&#12398;&#12477;&#12540;&#12473;&#12497;&#12483;&#12465;&#12540;&#12472;&#65288;&#12496;&#12540;&#12472;&#12519;&#12531;1.4.14&#65289;&lt;/a&gt;&lt;/li&gt;
+&lt;li&gt;&lt;a href=&quot;tokyocabinet-1.4.15.tar.gz&quot;&gt;&#26368;&#26032;&#12398;&#12477;&#12540;&#12473;&#12497;&#12483;&#12465;&#12540;&#12472;&#65288;&#12496;&#12540;&#12472;&#12519;&#12531;1.4.15&#65289;&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;pastpkg/&quot;&gt;&#36942;&#21435;&#12398;&#12496;&#12540;&#12472;&#12519;&#12531;&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;
 </diff>
      <filename>doc/index.ja.html</filename>
    </modified>
    <modified>
      <diff>@@ -41,6 +41,7 @@
 &lt;li&gt;&lt;a href=&quot;#tcfdbapi&quot;&gt;The Fixed-length Database API&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;#tctdbapi&quot;&gt;The Table Database API&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;#tcadbapi&quot;&gt;The Abstract Database API&lt;/a&gt;&lt;/li&gt;
+&lt;li&gt;&lt;a href=&quot;#fileformat&quot;&gt;File Format&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;#license&quot;&gt;License&lt;/a&gt;&lt;/li&gt;
 &lt;/ol&gt;
 
@@ -56,7 +57,7 @@
 
 &lt;p&gt;As for database of fixed-length array, records are stored with unique natural numbers.  It is impossible to store two or more records with a key overlaps.  Moreover, the length of each record is limited by the specified length.  Provided operations are the same as ones of hash database.&lt;/p&gt;
 
-&lt;p&gt;Table database is also provided as a variant of hash database.  Each record is identified by the primary key and has a set of named columns.  Although there is no concept of data schema, it is possible to search for records with complex conditions efficiently by using indexes of arbitrary columns.&lt;/p&gt;
+&lt;p&gt;Table database is also provided as a variant of hash database.  Each record is identified by the primary key and has a set of named columns.  Although there is no concept of data schema, it is possible to search for records with complex conditions efficiently by using indices of arbitrary columns.&lt;/p&gt;
 
 &lt;p&gt;Tokyo Cabinet is written in the C language, and provided as API of C, Perl, Ruby, Java, and Lua.  Tokyo Cabinet is available on platforms which have API conforming to C99 and POSIX.  Tokyo Cabinet is a free software licensed under the GNU Lesser General Public License.&lt;/p&gt;
 
@@ -117,7 +118,7 @@
 
 &lt;p&gt;Table database supports query functions with not only the primary key but also with conditions about arbitrary columns.  Each column condition is composed of the name of a column and a condition expression.  Operators of full matching, forward matching, regular expression matching, and so on are provided for the string type.  Operators of full matching, range matching and so on are provided for the number type.  A query can contain multiple conditions.  The order of the result set can be specified as the ascending or descending order of strings or numbers.&lt;/p&gt;
 
-&lt;p&gt;You can create indexes for arbitrary columns to improve performance of search and sorting.  Although columns do not have data types, indexes have types for strings or numbers.  The query optimizer uses indexes in suitable way according to each query.  Indexes are implemented as different files of B+ tree database.&lt;/p&gt;
+&lt;p&gt;You can create indices for arbitrary columns to improve performance of search and sorting.  Although columns do not have data types, indices have types for strings or numbers.  The query optimizer uses indices in suitable way according to each query.  Indices are implemented as different files of B+ tree database.&lt;/p&gt;
 
 &lt;h3 id=&quot;features_practical&quot;&gt;Practical Functionality&lt;/h3&gt;
 
@@ -5307,7 +5308,7 @@ int main(int argc, char **argv){
 &lt;dd&gt;`&lt;var&gt;lcnum&lt;/var&gt;' specifies the maximum number of leaf nodes to be cached.  If it is not more than 0, the default value is specified.  The default value is 4096.&lt;/dd&gt;
 &lt;dd&gt;`&lt;var&gt;ncnum&lt;/var&gt;' specifies the maximum number of non-leaf nodes to be cached.  If it is not more than 0, the default value is specified.  The default value is 512.&lt;/dd&gt;
 &lt;dd&gt;If successful, the return value is true, else, it is false.&lt;/dd&gt;
-&lt;dd&gt;Note that the caching parameters should be set before the database is opened.  Leaf nodes and non-leaf nodes are used in column indexes.&lt;/dd&gt;
+&lt;dd&gt;Note that the caching parameters should be set before the database is opened.  Leaf nodes and non-leaf nodes are used in column indices.&lt;/dd&gt;
 &lt;/dl&gt;
 
 &lt;p&gt;The function `tctdbsetxmsiz' is used in order to set the size of the extra mapped memory of a table database object.&lt;/p&gt;
@@ -5692,7 +5693,7 @@ int main(int argc, char **argv){
 &lt;dd&gt;`&lt;var&gt;name&lt;/var&gt;' specifies the name of a column.  If the name of an existing index is specified, the index is rebuilt.  An empty string means the primary key.&lt;/dd&gt;
 &lt;dd&gt;`&lt;var&gt;type&lt;/var&gt;' specifies the index type: `TDBITLEXICAL' for lexical string, `TDBITDECIMAL' for decimal string.  If it is `TDBITOPT', the index is optimized.  If it is `TDBITVOID', the index is removed.  If `TDBITKEEP' is added by bitwise-or and the index exists, this function merely returns failure.&lt;/dd&gt;
 &lt;dd&gt;If successful, the return value is true, else, it is false.&lt;/dd&gt;
-&lt;dd&gt;Note that the setting indexes should be set after the database is opened.&lt;/dd&gt;
+&lt;dd&gt;Note that the setting indices should be set after the database is opened.&lt;/dd&gt;
 &lt;/dl&gt;
 
 
@@ -6045,7 +6046,7 @@ int main(int argc, char **argv){
 
 &lt;p&gt;Objects whose type is pointer to `&lt;code&gt;TCADB&lt;/code&gt;' are used to handle abstract databases.  An abstract database object is created with the function `&lt;code&gt;tcadbnew&lt;/code&gt;' and is deleted with the function `&lt;code&gt;tcadbdel&lt;/code&gt;'.  To avoid memory leak, it is important to delete every object when it is no longer in use.&lt;/p&gt;
 
-&lt;p&gt;Before operations to store or retrieve records, it is necessary to connect the abstract database object to the concrete one.  The function `&lt;code&gt;tcadbopen&lt;/code&gt;' is used to open a concrete database and the function `&lt;code&gt;tcadbclose&lt;/code&gt;' is used to close the database.  To avoid data missing or corruption, it is important to close every database file when it is no longer in use.&lt;/p&gt;
+&lt;p&gt;Before operations to store or retrieve records, it is necessary to connect the abstract database object to the concrete one.  The function `&lt;code&gt;tcadbopen&lt;/code&gt;' is used to open a concrete database and the function `&lt;code&gt;tcadbclose&lt;/code&gt;' is used to close the database.  To avoid data missing or corruption, it is important to close every database instance when it is no longer in use.&lt;/p&gt;
 
 &lt;h3 id=&quot;tcadbapi_api&quot;&gt;API&lt;/h3&gt;
 
@@ -6297,6 +6298,16 @@ int main(int argc, char **argv){
 &lt;dd&gt;If successful, the return value is true, else, it is false.&lt;/dd&gt;
 &lt;/dl&gt;
 
+&lt;p&gt;The function `tcadboptimize' is used in order to optimize the storage of an abstract database object.&lt;/p&gt;
+
+&lt;dl class=&quot;api&quot;&gt;
+&lt;dt&gt;&lt;code&gt;bool tcadboptimize(TCADB *&lt;var&gt;adb&lt;/var&gt;, const char *&lt;var&gt;params&lt;/var&gt;);&lt;/code&gt;&lt;/dt&gt;
+&lt;dd&gt;`&lt;var&gt;adb&lt;/var&gt;' specifies the abstract database object.&lt;/dd&gt;
+&lt;dd&gt;`&lt;var&gt;params&lt;/var&gt;' specifies the string of the tuning parameters, which works as with the tuning of parameters the function `tcadbopen'.  If it is `NULL', it is not used.&lt;/dd&gt;
+&lt;dd&gt;If successful, the return value is true, else, it is false.&lt;/dd&gt;
+&lt;dd&gt;This function is useful to reduce the size of the database storage with data fragmentation by successive updating.&lt;/dd&gt;
+&lt;/dl&gt;
+
 &lt;p&gt;The function `tcadbvanish' is used in order to remove all records of an abstract database object.&lt;/p&gt;
 
 &lt;dl class=&quot;api&quot;&gt;
@@ -6342,6 +6353,14 @@ int main(int argc, char **argv){
 &lt;dd&gt;Update in the transaction is discarded when it is aborted.  The state of the database is rollbacked to before transaction.&lt;/dd&gt;
 &lt;/dl&gt;
 
+&lt;p&gt;The function `tcadbpath' is used in order to get the file path of an abstract database object.&lt;/p&gt;
+
+&lt;dl class=&quot;api&quot;&gt;
+&lt;dt&gt;&lt;code&gt;const char *tcadbpath(TCADB *&lt;var&gt;adb&lt;/var&gt;);&lt;/code&gt;&lt;/dt&gt;
+&lt;dd&gt;`&lt;var&gt;adb&lt;/var&gt;' specifies the abstract database object.&lt;/dd&gt;
+&lt;dd&gt;The return value is the path of the database file or `NULL' if the object does not connect to any database.  &quot;*&quot; stands for on-memory hash database.  &quot;+&quot; stands for on-memory tree database.&lt;/dd&gt;
+&lt;/dl&gt;
+
 &lt;p&gt;The function `tcadbrnum' is used in order to get the number of records of an abstract database object.&lt;/p&gt;
 
 &lt;dl class=&quot;api&quot;&gt;
@@ -6455,7 +6474,7 @@ int main(int argc, char **argv){
 
 &lt;p&gt;This command returns 0 on success, another on failure.&lt;/p&gt;
 
-&lt;p&gt;The command `&lt;code&gt;tcamgr&lt;/code&gt;' is a utility for test and debugging of the abstract database API and its applications.  `&lt;var&gt;name&lt;/var&gt;' specifies the name of a database.  `&lt;var&gt;key&lt;/var&gt;' specifies the key of a record.  `&lt;var&gt;value&lt;/var&gt;' specifies the value of a record.  `&lt;var&gt;func&lt;/var&gt;' specifies the name of a function.  `&lt;var&gt;arg&lt;/var&gt;' specifies the arguments of the function.  `&lt;var&gt;dest&lt;/var&gt;' specifies the path of the destination file.&lt;/p&gt;
+&lt;p&gt;The command `&lt;code&gt;tcamgr&lt;/code&gt;' is a utility for test and debugging of the abstract database API and its applications.  `&lt;var&gt;name&lt;/var&gt;' specifies the name of a database.  `&lt;var&gt;key&lt;/var&gt;' specifies the key of a record.  `&lt;var&gt;value&lt;/var&gt;' specifies the value of a record.  `&lt;var&gt;params&lt;/var&gt;' specifies the tuning parameters.  `&lt;var&gt;func&lt;/var&gt;' specifies the name of a function.  `&lt;var&gt;arg&lt;/var&gt;' specifies the arguments of the function.  `&lt;var&gt;dest&lt;/var&gt;' specifies the path of the destination file.&lt;/p&gt;
 
 &lt;dl class=&quot;api&quot;&gt;
 &lt;dt&gt;&lt;code&gt;tcamgr create &lt;var&gt;name&lt;/var&gt;&lt;/code&gt;&lt;/dt&gt;
@@ -6470,6 +6489,8 @@ int main(int argc, char **argv){
 &lt;dd&gt;Print the value of a record.&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;tcamgr list [-sep &lt;var&gt;chr&lt;/var&gt;] [-m &lt;var&gt;num&lt;/var&gt;] [-pv] [-px] [-fm &lt;var&gt;str&lt;/var&gt;] &lt;var&gt;name&lt;/var&gt;&lt;/code&gt;&lt;/dt&gt;
 &lt;dd&gt;Print keys of all records, separated by line feeds.&lt;/dd&gt;
+&lt;dt&gt;&lt;code&gt;tcamgr optimize &lt;var&gt;name&lt;/var&gt; &lt;var&gt;params&lt;/var&gt;&lt;/code&gt;&lt;/dt&gt;
+&lt;dd&gt;Optimize a database file.&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;tcamgr misc [-sx] [-sep &lt;var&gt;chr&lt;/var&gt;] [-px] &lt;var&gt;name&lt;/var&gt; &lt;var&gt;func&lt;/var&gt; [&lt;var&gt;arg&lt;/var&gt;...]&lt;/code&gt;&lt;/dt&gt;
 &lt;dd&gt;Call a versatile function for miscellaneous operations.&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;tcamgr map [-fm &lt;var&gt;str&lt;/var&gt;] &lt;var&gt;name&lt;/var&gt; &lt;var&gt;dest&lt;/var&gt;&lt;/code&gt;&lt;/dt&gt;
@@ -6504,6 +6525,563 @@ int main(int argc, char **argv){
 
 &lt;hr /&gt;
 
+&lt;h2 id=&quot;fileformat&quot;&gt;File Format&lt;/h2&gt;
+
+&lt;p&gt;This section describes the format of the database files of Tokyo Cabinet.&lt;/p&gt;
+
+&lt;h3 id=&quot;fileformat_tchdb&quot;&gt;File Format of Hash Database&lt;/h3&gt;
+
+&lt;p&gt;There are four sections in the file managed by the hash database; the header section, the bucket section, the free block pool section, and the record section.  Numeric values in the file are serialized in the little endian order or in the variable length format.  The latter format is delta encoding based on the 128-radix numbering.&lt;/p&gt;
+
+&lt;p&gt;The header section is from the top of the file and its length is 256 bytes.  There are the following information.&lt;/p&gt;
+
+&lt;table summary=&quot;database header format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;magic number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;32&lt;/td&gt;
+&lt;td&gt;identification of the database.  Begins with &quot;ToKyO CaBiNeT&quot;&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;database type&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;32&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;hash (0x01) / B+ tree (0x02) / fixed-length (0x03) / table (0x04)&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;additional flags&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;33&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;logical union of open (1&amp;lt;&amp;lt;0) and fatal (1&amp;lt;&amp;lt;1)&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;alignment power&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;34&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;the alignment size, by power of 2&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;free block pool power&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;35&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;the number of elements in the free block pool, by power of 2&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;options&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;36&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;logical union of large (1&amp;lt;&amp;lt;0), Deflate (1&amp;lt;&amp;lt;1), BZIP2 (1&amp;lt;&amp;lt;2), TCBS (1&amp;lt;&amp;lt;3), extra codec (1&amp;lt;&amp;lt;4)&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;bucket number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;40&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the number of elements of the bucket array&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;record number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;48&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the number of records in the database&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;file size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;56&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the file size of the database&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;first record&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;64&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the offset of the first record&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;opaque region&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;128&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;128&lt;/td&gt;
+&lt;td&gt;users can use this region arbitrarily&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;p&gt;The bucket section trails the header section and its size is defined by the bucket number.  Each element of the bucket array indicates the offset of the first record of the hash chain.  The format of each element is the fixed length number and its size is 4 bytes in the normal mode or 8 bytes in the large mode.  The offset is recorded as the quotient by the alignment.&lt;/p&gt;
+
+&lt;p&gt;The free block pool section trails the bucket section and its size is defined by the free block pool number.  Each element of the free block pool indicates the offset and the size of each free block.  The offset is recorded as the difference of the former free block and as the quotient by the alignment.  The offset and the size are serialized in the variable length format.&lt;/p&gt;
+
+&lt;p&gt;The record section trails the free block pool section and occupies the rest region to the end of the file.  Each element has the following information.  The region of each record begins at the offset of the multiple of the alignment.&lt;/p&gt;
+
+&lt;table summary=&quot;record format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;magic number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;identification of record block. always 0xC8&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;hash value&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;the hash value to decide the path of the hash chain&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;left chain&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;2&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;4&lt;/td&gt;
+&lt;td&gt;the alignment quotient of the destination of the left chain&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;right chain&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;6&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;4&lt;/td&gt;
+&lt;td&gt;the alignment quotient of the destination of the right chain&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;padding size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;10&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;2&lt;/td&gt;
+&lt;td&gt;the size of the padding&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;key size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;12&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the size of the key&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;value size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the size of the value&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;key&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the data of the key&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;value&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the data of the value&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;padding&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;useless data&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;p&gt;However, regions of free blocks contain the following information.&lt;/p&gt;
+
+&lt;table summary=&quot;free block format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;magic number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;identification of record block. always 0xB0&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;block size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;4&lt;/td&gt;
+&lt;td&gt;size of the block&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;p&gt;The transaction log is recorded in the file whose name is composed of the database name and the suffix &quot;.wal&quot;.  The top eight bytes indicate the file size of the beginning of the transaction.  After that, there are the following information.&lt;/p&gt;
+
+&lt;table summary=&quot;transaction log format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;offset&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the offset of the updated region&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;4&lt;/td&gt;
+&lt;td&gt;the size of the updated region&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;data&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;12&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the data before update&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;h3 id=&quot;fileformat_tcbdb&quot;&gt;File Format of B+ Tree Database&lt;/h3&gt;
+
+&lt;p&gt;All data managed by the B+ tree database are recorded in the hash database.  Recorded data are classified into meta data and logical pages.  Logical pages are classified into leaf nodes and non-leaf nodes.  The formats of the fixed length number and the variable length number are the same as with the hash database.&lt;/p&gt;
+
+&lt;p&gt;Meta data are recorded in the opaque region in the header of the hash database and have the following information.&lt;/p&gt;
+
+&lt;table summary=&quot;database header format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+
+&lt;tr&gt;
+&lt;td&gt;comparison function&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;tccmplexical (0x00), tccmpdecimal (0x01), tccmpint32 (0x02), tccmpint64 (0x03), other (0xff)&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;reserved region&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;7&lt;/td&gt;
+&lt;td&gt;not used&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;record number of leaf node&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;4&lt;/td&gt;
+&lt;td&gt;the maximum number of records in a leaf node&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;index number of non-leaf node&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;12&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;4&lt;/td&gt;
+&lt;td&gt;the maximum number of indices in a leaf node&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;root node ID&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;16&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the page ID of the root node of B+ tree&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;first leaf ID&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;24&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the page ID of the first leaf node&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;last leaf ID&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;32&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the page ID of the last leaf node&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;leaf number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;40&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the number of the leaf nodes&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;non-leaf number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;48&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the number of the non-leaf nodes&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;record number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;56&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the number of records in the database&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;p&gt;Each leaf node contains a list of records.  Each non-leaf node contains a list of indices to child nodes.  Though each record is a logical unit of user data, records with the same key are integrated into one record physically.  Each physical record has the following information.&lt;/p&gt;
+
+&lt;table summary=&quot;record format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;key size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the size of the key&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;value size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the size of the value&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;duplication number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the number of values with the same key&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;key&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the data of the key&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;value&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the data of the value&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;duplicated records&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;a list of value sizes and value data&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;p&gt;Each leaf node is a physical unit of a set of records.  Each leaf node is identified by the sequential ID number from 1.  Each leaf node is recorded in the hash database.  The key is a string in the hexadecimal numbering.  The value has the following information.  Records are kept in the ascending order of keys.&lt;/p&gt;
+
+&lt;table summary=&quot;leaf node format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;previous leaf&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the ID number of the previous leaf node&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;next leaf&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the ID number of the next leaf node&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;record list&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the serialized data of all records in the node&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;p&gt;Each index is a logical unit of pointer to the child node.  Each index has the following information.&lt;/p&gt;
+
+&lt;table summary=&quot;index format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;page ID&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the ID number of the referred page&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;key size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the size of the key&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;key&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the data of the key&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;p&gt;Each non-leaf node is a physical unit of a set of indices.  Each non-leaf node is identified by the sequential number from 281474976710657.  Each non-leaf node is recorded in the hash database.  The key is a string begins with &quot;#&quot; and is trailed by the hexadecimal number of the ID number subtracted by 281474976710657.  The value has the following information.  Indices are kept in the ascending order of keys.&lt;/p&gt;
+
+&lt;table summary=&quot;non-leaf format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;accession ID&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the ID number of the first child node&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;index list&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the serialized data of all indices in the node&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;h3 id=&quot;fileformat_tcfdb&quot;&gt;File Format of Fixed-length Database&lt;/h3&gt;
+
+&lt;p&gt;There are two sections in the file managed by the fixed-length database; the header section, and the record section.  Numeric values in the file are serialized in the little endian order.&lt;/p&gt;
+
+&lt;p&gt;The header section is from the top of the file and its length is 256 bytes. There are the following information.&lt;/p&gt;
+
+&lt;table summary=&quot;database header format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;magic number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;32&lt;/td&gt;
+&lt;td&gt;identification of the database. Begins with &quot;ToKyO CaBiNeT&quot;&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;database type&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;32&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;always 0x03&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;additional flags&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;33&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
+&lt;td&gt;logical union of open (1&amp;lt;&amp;lt;0) and fatal (1&amp;lt;&amp;lt;1)&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;record number&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;48&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the number of records in the database&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;file size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;56&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the file size of the database&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;record width&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;64&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the width of each record&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;limit size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;72&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the limit size of the database&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;least ID&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;80&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the least ID number of records&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;greatest ID&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;88&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;8&lt;/td&gt;
+&lt;td&gt;the greatest ID number of records&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;opaque region&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;128&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;128&lt;/td&gt;
+&lt;td&gt;users can use this region arbitrarily&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;p&gt;The record section trails the header section and occupies the rest region to the end of the file. Each element has the following information.  The size region takes 1 byte if the record width is less than 256 bytes, or takes 2 bytes if the record width is less than 65536, else takes 4 bytes.  The size of each record is the summation of the size of the width region and the record width.  So, the region of each record begins at the offset generated by the ID number subtracted by 1 and multiplied by the record width and the added by 256.&lt;/p&gt;
+
+&lt;table summary=&quot;record format&quot;&gt;
+&lt;tr&gt;
+&lt;td class=&quot;label&quot;&gt;name&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;offset&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;length&lt;/td&gt;
+&lt;td class=&quot;label&quot;&gt;feature&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;value size&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the size of the value&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;value&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;the data of the value&lt;/td&gt;
+&lt;/tr&gt;
+&lt;tr&gt;
+&lt;td&gt;padding&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td class=&quot;number&quot;&gt;vary&lt;/td&gt;
+&lt;td&gt;padding.  If the size of the value is 0, the first byte indicates whether the record exists or not&lt;/td&gt;
+&lt;/tr&gt;
+&lt;/table&gt;
+
+&lt;p&gt;The naming convention and the file format of the transaction log file is the same as the one of the hash database.&lt;/p&gt;
+
+&lt;h3 id=&quot;fileformat_note&quot;&gt;Note&lt;/h3&gt;
+
+&lt;p&gt;Because database files are not sparse, you can copy them as with normal files.  Moreover, the database formats don't depend on the byte order of the running environment, you can migrate the database files between environments with different byte orders.&lt;/p&gt;
+
+&lt;p&gt;If possible, set the MIME type `&lt;code&gt;application/x-tokyocabinet-hash&lt;/code&gt;' when sending files of the hash database.  The suffix of the file name should be `&lt;code&gt;.tch&lt;/code&gt;'.  As for the B+ tree database, `&lt;code&gt;application/x-tokyocabinet-btree&lt;/code&gt;' and `&lt;code&gt;.tcb&lt;/code&gt;'.  As for the fixed-length database, `&lt;code&gt;application/x-tokyocabinet-fixed&lt;/code&gt;' and `&lt;code&gt;.tcf&lt;/code&gt;'.  As for the table database, `&lt;code&gt;application/x-tokyocabinet-btree&lt;/code&gt;' and `&lt;code&gt;.tct&lt;/code&gt;'.&lt;/p&gt;
+
+&lt;p&gt;To make the `&lt;code&gt;file&lt;/code&gt;' command identify the database formats, append the following lines to the `&lt;code&gt;magic&lt;/code&gt;' file.&lt;/p&gt;
+
+&lt;pre&gt;# Tokyo Cabinet magic data
+0       string    ToKyO\ CaBiNeT\n   Tokyo Cabinet
+&amp;gt;14     string    x                  \b (%s)
+&amp;gt;32     byte      0                  \b, Hash
+!:mime  application/x-tokyocabinet-hash
+&amp;gt;32     byte      1                  \b, B+ tree
+!:mime  application/x-tokyocabinet-btree
+&amp;gt;32     byte      2                  \b, Fixed-length
+!:mime  application/x-tokyocabinet-fixed
+&amp;gt;32     byte      3                  \b, Table
+!:mime  application/x-tokyocabinet-table
+&amp;gt;33     byte      &amp;amp;1                 \b, [open]
+&amp;gt;33     byte      &amp;amp;2                 \b, [fatal]
+&amp;gt;34     byte      x                  \b, apow=%d
+&amp;gt;35     byte      x                  \b, fpow=%d
+&amp;gt;36     byte      &amp;amp;1                 \b, [large]
+&amp;gt;36     byte      &amp;amp;2                 \b, [deflate]
+&amp;gt;36     byte      &amp;amp;4                 \b, [bzip]
+&amp;gt;36     byte      &amp;amp;8                 \b, [tcbs]
+&amp;gt;36     byte      &amp;amp;16                \b, [excodec]
+&amp;gt;40     lequad    x                  \b, bnum=%lld
+&amp;gt;48     lequad    x                  \b, rnum=%lld
+&amp;gt;56     lequad    x                  \b, fsiz=%lld
+&lt;/pre&gt;
+
+&lt;hr /&gt;
+
 &lt;h2 id=&quot;license&quot;&gt;License&lt;/h2&gt;
 
 &lt;p&gt;Tokyo Cabinet is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License or any later version.&lt;/p&gt;</diff>
      <filename>doc/spex-en.html</filename>
    </modified>
    <modified>
      <diff>@@ -5310,7 +5310,7 @@ int main(int argc, char **argv){
 &lt;dd&gt;`&lt;var&gt;lcnum&lt;/var&gt;' specifies the maximum number of leaf nodes to be cached.  If it is not more than 0, the default value is specified.  The default value is 2048.&lt;/dd&gt;
 &lt;dd&gt;`&lt;var&gt;ncnum&lt;/var&gt;' specifies the maximum number of non-leaf nodes to be cached.  If it is not more than 0, the default value is specified.  The default value is 512.&lt;/dd&gt;
 &lt;dd&gt;If successful, the return value is true, else, it is false.&lt;/dd&gt;
-&lt;dd&gt;Note that the caching parameters should be set before the database is opened.  Leaf nodes and non-leaf nodes are used in column indexes.&lt;/dd&gt;
+&lt;dd&gt;Note that the caching parameters should be set before the database is opened.  Leaf nodes and non-leaf nodes are used in column indices.&lt;/dd&gt;
 &lt;/dl&gt;
 
 &lt;p&gt;The function `tctdbsetxmsiz' is used in order to set the size of the extra mapped memory of a table database object.&lt;/p&gt;
@@ -5695,7 +5695,7 @@ int main(int argc, char **argv){
 &lt;dd&gt;`&lt;var&gt;name&lt;/var&gt;' specifies the name of a column.  If the name of an existing index is specified, the index is rebuilt.  An empty string means the primary key.&lt;/dd&gt;
 &lt;dd&gt;`&lt;var&gt;type&lt;/var&gt;' specifies the index type: `TDBITLEXICAL' for lexical string, `TDBITDECIMAL' for decimal string.  If it is `TDBITOPT', the index is optimized.  If it is `TDBITVOID', the index is removed.  If `TDBITKEEP' is added by bitwise-or and the index exists, this function merely returns failure.&lt;/dd&gt;
 &lt;dd&gt;If successful, the return value is true, else, it is false.&lt;/dd&gt;
-&lt;dd&gt;Note that the setting indexes should be set after the database is opened.&lt;/dd&gt;
+&lt;dd&gt;Note that the setting indices should be set after the database is opened.&lt;/dd&gt;
 &lt;/dl&gt;
 
 
@@ -6298,6 +6298,16 @@ int main(int argc, char **argv){
 &lt;dd&gt;If successful, the return value is true, else, it is false.&lt;/dd&gt;
 &lt;/dl&gt;
 
+&lt;p&gt;The function `tcadboptimize' is used in order to optimize the storage of an abstract database object.&lt;/p&gt;
+
+&lt;dl class=&quot;api&quot;&gt;
+&lt;dt&gt;&lt;code&gt;bool tcadboptimize(TCADB *&lt;var&gt;adb&lt;/var&gt;, const char *&lt;var&gt;params&lt;/var&gt;);&lt;/code&gt;&lt;/dt&gt;
+&lt;dd&gt;`&lt;var&gt;adb&lt;/var&gt;' specifies the abstract database object.&lt;/dd&gt;
+&lt;dd&gt;`&lt;var&gt;params&lt;/var&gt;' specifies the string of the tuning parameters, which works as with the tuning of parameters the function `tcadbopen'.  If it is `NULL', it is not used.&lt;/dd&gt;
+&lt;dd&gt;If successful, the return value is true, else, it is false.&lt;/dd&gt;
+&lt;dd&gt;This function is useful to reduce the size of the database storage with data fragmentation by successive updating.&lt;/dd&gt;
+&lt;/dl&gt;
+
 &lt;p&gt;The function `tcadbvanish' is used in order to remove all records of an abstract database object.&lt;/p&gt;
 
 &lt;dl class=&quot;api&quot;&gt;
@@ -6343,6 +6353,14 @@ int main(int argc, char **argv){
 &lt;dd&gt;Update in the transaction is discarded when it is aborted.  The state of the database is rollbacked to before transaction.&lt;/dd&gt;
 &lt;/dl&gt;
 
+&lt;p&gt;The function `tcadbpath' is used in order to get the file path of an abstract database object.&lt;/p&gt;
+
+&lt;dl class=&quot;api&quot;&gt;
+&lt;dt&gt;&lt;code&gt;const char *tcadbpath(TCADB *&lt;var&gt;adb&lt;/var&gt;);&lt;/code&gt;&lt;/dt&gt;
+&lt;dd&gt;`&lt;var&gt;adb&lt;/var&gt;' specifies the abstract database object.&lt;/dd&gt;
+&lt;dd&gt;The return value is the path of the database file or `NULL' if the object does not connect to any database.  &quot;*&quot; stands for on-memory hash database.  &quot;+&quot; stands for on-memory tree database.&lt;/dd&gt;
+&lt;/dl&gt;
+
 &lt;p&gt;The function `tcadbrnum' is used in order to get the number of records of an abstract database object.&lt;/p&gt;
 
 &lt;dl class=&quot;api&quot;&gt;
@@ -6456,7 +6474,7 @@ int main(int argc, char **argv){
 
 &lt;p&gt;&#12371;&#12398;&#12467;&#12510;&#12531;&#12489;&#12399;&#20966;&#29702;&#12364;&#27491;&#24120;&#12395;&#32066;&#20102;&#12377;&#12428;&#12400; 0 &#12434;&#36820;&#12375;&#12289;&#12456;&#12521;&#12540;&#12364;&#12354;&#12428;&#12400;&#12381;&#12428;&#20197;&#22806;&#12398;&#20516;&#12434;&#36820;&#12375;&#12390;&#32066;&#20102;&#12375;&#12414;&#12377;&#12290;&lt;/p&gt;
 
-&lt;p&gt;&#12467;&#12510;&#12531;&#12489; `&lt;code&gt;tcamgr&lt;/code&gt;' &#12399;&#12289;&#25277;&#35937;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;API&#12420;&#12381;&#12398;&#12450;&#12503;&#12522;&#12465;&#12540;&#12471;&#12519;&#12531;&#12398;&#12486;&#12473;&#12488;&#12420;&#12487;&#12496;&#12483;&#12464;&#12395;&#24441;&#31435;&#12388;&#12484;&#12540;&#12523;&#12391;&#12377;&#12290;&#20197;&#19979;&#12398;&#26360;&#24335;&#12391;&#29992;&#12356;&#12414;&#12377;&#12290;`&lt;var&gt;name&lt;/var&gt;' &#12399;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#21517;&#21069;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;key&lt;/var&gt;' &#12399;&#12524;&#12467;&#12540;&#12489;&#12398;&#12461;&#12540;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;value&lt;/var&gt;' &#12399;&#12524;&#12467;&#12540;&#12489;&#12398;&#20516;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;func&lt;/var&gt;' &#12399;&#38306;&#25968;&#12398;&#21517;&#21069;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;arg&lt;/var&gt;' &#12399;&#38306;&#25968;&#12398;&#24341;&#25968;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;dest&lt;/var&gt;' &#12399;&#26684;&#32013;&#20808;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&lt;/p&gt;
+&lt;p&gt;&#12467;&#12510;&#12531;&#12489; `&lt;code&gt;tcamgr&lt;/code&gt;' &#12399;&#12289;&#25277;&#35937;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;API&#12420;&#12381;&#12398;&#12450;&#12503;&#12522;&#12465;&#12540;&#12471;&#12519;&#12531;&#12398;&#12486;&#12473;&#12488;&#12420;&#12487;&#12496;&#12483;&#12464;&#12395;&#24441;&#31435;&#12388;&#12484;&#12540;&#12523;&#12391;&#12377;&#12290;&#20197;&#19979;&#12398;&#26360;&#24335;&#12391;&#29992;&#12356;&#12414;&#12377;&#12290;`&lt;var&gt;name&lt;/var&gt;' &#12399;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#21517;&#21069;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;key&lt;/var&gt;' &#12399;&#12524;&#12467;&#12540;&#12489;&#12398;&#12461;&#12540;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;value&lt;/var&gt;' &#12399;&#12524;&#12467;&#12540;&#12489;&#12398;&#20516;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;params&lt;/var&gt;' &#12399;&#12481;&#12517;&#12540;&#12491;&#12531;&#12464;&#12497;&#12521;&#12513;&#12540;&#12479;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;func&lt;/var&gt;' &#12399;&#38306;&#25968;&#12398;&#21517;&#21069;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;arg&lt;/var&gt;' &#12399;&#38306;&#25968;&#12398;&#24341;&#25968;&#12434;&#25351;&#23450;&#12375;&#12289;`&lt;var&gt;dest&lt;/var&gt;' &#12399;&#26684;&#32013;&#20808;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#25351;&#23450;&#12375;&#12414;&#12377;&#12290;&lt;/p&gt;
 
 &lt;dl class=&quot;api&quot;&gt;
 &lt;dt&gt;&lt;code&gt;tcamgr create &lt;var&gt;name&lt;/var&gt;&lt;/code&gt;&lt;/dt&gt;
@@ -6471,6 +6489,8 @@ int main(int argc, char **argv){
 &lt;dd&gt;&#12524;&#12467;&#12540;&#12489;&#12398;&#20516;&#12434;&#21462;&#24471;&#12375;&#12390;&#27161;&#28310;&#20986;&#21147;&#12377;&#12427;&#12290;&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;tcamgr list [-sep &lt;var&gt;chr&lt;/var&gt;] [-m &lt;var&gt;num&lt;/var&gt;] [-pv] [-px] [-fm &lt;var&gt;str&lt;/var&gt;] &lt;var&gt;name&lt;/var&gt;&lt;/code&gt;&lt;/dt&gt;
 &lt;dd&gt;&#20840;&#12390;&#12398;&#12524;&#12467;&#12540;&#12489;&#12398;&#12461;&#12540;&#12434;&#25913;&#34892;&#12391;&#21306;&#20999;&#12387;&#12390;&#27161;&#28310;&#20986;&#21147;&#12377;&#12427;&#12290;&lt;/dd&gt;
+&lt;dt&gt;&lt;code&gt;tcamgr optimize &lt;var&gt;name&lt;/var&gt; &lt;var&gt;params&lt;/var&gt;&lt;/code&gt;&lt;/dt&gt;
+&lt;dd&gt;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12434;&#26368;&#36969;&#21270;&#12377;&#12427;&#12290;&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;tcamgr misc [-sx] [-sep &lt;var&gt;chr&lt;/var&gt;] [-px] &lt;var&gt;name&lt;/var&gt; &lt;var&gt;func&lt;/var&gt; [&lt;var&gt;arg&lt;/var&gt;...]&lt;/code&gt;&lt;/dt&gt;
 &lt;dd&gt;&#38609;&#22810;&#12394;&#25805;&#20316;&#12398;&#22810;&#30446;&#30340;&#38306;&#25968;&#12434;&#21628;&#12403;&#20986;&#12377;&#12290;&lt;/dd&gt;
 &lt;dt&gt;&lt;code&gt;tcamgr map [-fm &lt;var&gt;str&lt;/var&gt;] &lt;var&gt;name&lt;/var&gt; &lt;var&gt;dest&lt;/var&gt;&lt;/code&gt;&lt;/dt&gt;
@@ -6771,7 +6791,7 @@ cp -f &quot;$srcpath&quot; &quot;$destpath&quot;
 &lt;td&gt;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12479;&#12452;&#12503;&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;32&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
-&lt;td&gt;&#12495;&#12483;&#12471;&#12517;&#34920;&#65288;0x01&#65289;&#12363;B+&#26408;&#65288;0x02&#65289;&lt;/td&gt;
+&lt;td&gt;&#12495;&#12483;&#12471;&#12517;&#34920;&#65288;0x01&#65289;&#12363;B+&#26408;&#65288;0x02&#65289;&#12363;&#22266;&#23450;&#38263;&#65288;0x03&#65289;&#12363;&#12486;&#12540;&#12502;&#12523;&#65288;0x04&#65289;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&#36861;&#21152;&#12501;&#12521;&#12464;&lt;/td&gt;
@@ -6900,7 +6920,7 @@ cp -f &quot;$srcpath&quot; &quot;$destpath&quot;
 &lt;td&gt;&#12497;&#12487;&#12451;&#12531;&#12464;&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;&#21487;&#22793;&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;&#21487;&#22793;&lt;/td&gt;
-&lt;td&gt;&#12497;&#12487;&#12451;&#12531;&#12464;&lt;/td&gt;
+&lt;td&gt;&#24847;&#21619;&#12434;&#25345;&#12383;&#12394;&#12356;&#12487;&#12540;&#12479;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/table&gt;
 
@@ -6971,10 +6991,10 @@ cp -f &quot;$srcpath&quot; &quot;$destpath&quot;
 &lt;/tr&gt;
 
 &lt;tr&gt;
-&lt;td&gt;&#27604;&#36611;&#38306;&#25968;&#12501;&#12521;&#12464;&lt;/td&gt;
+&lt;td&gt;&#27604;&#36611;&#38306;&#25968;&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;0&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
-&lt;td&gt;&#27604;&#36611;&#38306;&#25968;&#12364;tccmplexical&#65288;&#12487;&#12501;&#12457;&#12523;&#12488;&#65289;&#12394;&#12425;0x0&#12289;tccmpdecimal&#12394;&#12425;0x1&#12289;tccmpint32&#12394;&#12425;0x2&#12289;tccmpint64&#12394;&#12425;0x3&#12289;&#12381;&#12428;&#20197;&#22806;&#12394;&#12425;0xff&lt;/td&gt;
+&lt;td&gt;&#27604;&#36611;&#38306;&#25968;&#12364;tccmplexical&#65288;&#12487;&#12501;&#12457;&#12523;&#12488;&#65289;&#12394;&#12425;0x00&#12289;tccmpdecimal&#12394;&#12425;0x01&#12289;tccmpint32&#12394;&#12425;0x02&#12289;tccmpint64&#12394;&#12425;0x03&#12289;&#12381;&#12428;&#20197;&#22806;&#12394;&#12425;0xff&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&#20104;&#32004;&#38936;&#22495;&lt;/td&gt;
@@ -7108,7 +7128,7 @@ cp -f &quot;$srcpath&quot; &quot;$destpath&quot;
 &lt;/tr&gt;
 &lt;/table&gt;
 
-&lt;p&gt;&#12452;&#12531;&#12487;&#12483;&#12463;&#12473;&#12399;&#12506;&#12540;&#12472;&#12434;&#25506;&#32034;&#12377;&#12427;&#12383;&#12417;&#12398;&#12509;&#12452;&#12531;&#12479;&#12398;&#35542;&#29702;&#30340;&#12394;&#21336;&#20301;&#12391;&#12377;&#12290;&#12452;&#12531;&#12487;&#12483;&#12463;&#12473;&#12399;&#20197;&#19979;&#12398;&#24418;&#24335;&#12391;&#30452;&#21015;&#21270;&#12373;&#12428;&#12414;&#12377;&#12290;&lt;/p&gt;
+&lt;p&gt;&#12452;&#12531;&#12487;&#12483;&#12463;&#12473;&#12399;&#23376;&#12506;&#12540;&#12472;&#12434;&#25506;&#32034;&#12377;&#12427;&#12383;&#12417;&#12398;&#12509;&#12452;&#12531;&#12479;&#12398;&#35542;&#29702;&#30340;&#12394;&#21336;&#20301;&#12391;&#12377;&#12290;&#12452;&#12531;&#12487;&#12483;&#12463;&#12473;&#12399;&#20197;&#19979;&#12398;&#24418;&#24335;&#12391;&#30452;&#21015;&#21270;&#12373;&#12428;&#12414;&#12377;&#12290;&lt;/p&gt;
 
 &lt;table summary=&quot;index format&quot;&gt;
 &lt;tr&gt;
@@ -7183,7 +7203,7 @@ cp -f &quot;$srcpath&quot; &quot;$destpath&quot;
 &lt;td&gt;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12479;&#12452;&#12503;&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;32&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;1&lt;/td&gt;
-&lt;td&gt;0x03&lt;/td&gt;
+&lt;td&gt;0x03&#22266;&#23450;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&#36861;&#21152;&#12501;&#12521;&#12464;&lt;/td&gt;
@@ -7260,15 +7280,17 @@ cp -f &quot;$srcpath&quot; &quot;$destpath&quot;
 &lt;td&gt;&#12497;&#12487;&#12451;&#12531;&#12464;&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;&#21487;&#22793;&lt;/td&gt;
 &lt;td class=&quot;number&quot;&gt;&#21487;&#22793;&lt;/td&gt;
-&lt;td&gt;&#12497;&#12487;&#12451;&#12531;&#12464;&#12290;&#20516;&#12469;&#12452;&#12474;&#12364;0&#12398;&#26178;&#12399;&#12289;&#20808;&#38957;&#12496;&#12452;&#12488;&#12398;&#30495;&#20605;&#20516;&#12391;&#12524;&#12467;&#12540;&#12489;&#12398;&#26377;&#28961;&#12434;&#31034;&#12377;&lt;/td&gt;
+&lt;td&gt;&#20516;&#12469;&#12452;&#12474;&#12364;0&#12398;&#26178;&#12399;&#12289;&#20808;&#38957;&#12496;&#12452;&#12488;&#12398;&#30495;&#20605;&#20516;&#12391;&#12524;&#12467;&#12540;&#12489;&#12398;&#26377;&#28961;&#12434;&#31034;&#12377;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/table&gt;
 
+&lt;p&gt;&#12488;&#12521;&#12531;&#12470;&#12463;&#12471;&#12519;&#12531;&#12525;&#12464;&#12398;&#21629;&#21517;&#35215;&#21063;&#12420;&#12501;&#12457;&#12540;&#12510;&#12483;&#12488;&#12399;&#12495;&#12483;&#12471;&#12517;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12418;&#12398;&#12392;&#21516;&#12376;&#12391;&#12377;&#12290;&lt;/p&gt;
+
 &lt;h3 id=&quot;fileformat_note&quot;&gt;&#27880;&#35352;&lt;/h3&gt;
 
-&lt;p&gt;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12501;&#12449;&#12452;&#12523;&#12399;&#12473;&#12497;&#12540;&#12473;&#12391;&#12399;&#12394;&#12356;&#12398;&#12391;&#12289;&#36890;&#24120;&#12398;&#12501;&#12449;&#12452;&#12523;&#12392;&#21516;&#27096;&#12395;&#35079;&#35069;&#31561;&#12398;&#25805;&#20316;&#12434;&#34892;&#12358;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12495;&#12483;&#12471;&#12517;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12418;B+&#26408;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12418;&#23455;&#34892;&#29872;&#22659;&#12398;&#12496;&#12452;&#12488;&#12458;&#12540;&#12480;&#12395;&#20381;&#23384;&#12375;&#12394;&#12356;&#24418;&#24335;&#12394;&#12398;&#12391;&#12289;&#12496;&#12452;&#12488;&#12458;&#12540;&#12480;&#12398;&#30064;&#12394;&#12427;&#29872;&#22659;&#12395;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12501;&#12449;&#12452;&#12523;&#12434;&#31227;&#35373;&#12375;&#12390;&#12418;&#12381;&#12398;&#12414;&#12414;&#12391;&#21033;&#29992;&#12391;&#12365;&#12414;&#12377;&#12290;&lt;/p&gt;
+&lt;p&gt;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12501;&#12449;&#12452;&#12523;&#12399;&#12473;&#12497;&#12540;&#12473;&#12391;&#12399;&#12394;&#12356;&#12398;&#12391;&#12289;&#36890;&#24120;&#12398;&#12501;&#12449;&#12452;&#12523;&#12392;&#21516;&#27096;&#12395;&#35079;&#35069;&#31561;&#12398;&#25805;&#20316;&#12434;&#34892;&#12358;&#12371;&#12392;&#12364;&#12391;&#12365;&#12414;&#12377;&#12290;&#12414;&#12383;&#12501;&#12457;&#12540;&#12510;&#12483;&#12488;&#12418;&#23455;&#34892;&#29872;&#22659;&#12398;&#12496;&#12452;&#12488;&#12458;&#12540;&#12480;&#12395;&#20381;&#23384;&#12375;&#12394;&#12356;&#12398;&#12391;&#12289;&#12496;&#12452;&#12488;&#12458;&#12540;&#12480;&#12398;&#30064;&#12394;&#12427;&#29872;&#22659;&#12395;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12501;&#12449;&#12452;&#12523;&#12434;&#31227;&#35373;&#12375;&#12390;&#12418;&#12381;&#12398;&#12414;&#12414;&#12391;&#21033;&#29992;&#12391;&#12365;&#12414;&#12377;&#12290;&lt;/p&gt;
 
-&lt;p&gt;&#12394;&#12427;&#12409;&#12367;&#12394;&#12425;&#12289;&#12495;&#12483;&#12471;&#12517;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#12493;&#12483;&#12488;&#12527;&#12540;&#12463;&#12391;&#37197;&#24067;&#12377;&#12427;&#38555;&#12395;&#12399;&#12289;MIME&#12479;&#12452;&#12503;&#12434; `&lt;code&gt;application/x-tokyocabinet-hash&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12398;&#25509;&#23614;&#36766;&#12399; `&lt;code&gt;.tch&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;B+&#26408;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#12493;&#12483;&#12488;&#12527;&#12540;&#12463;&#12391;&#37197;&#24067;&#12377;&#12427;&#38555;&#12395;&#12399;&#12289;MIME&#12479;&#12452;&#12503;&#12434; `&lt;code&gt;application/x-tokyocabinet-btree&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12398;&#25509;&#23614;&#36766;&#12399; `&lt;code&gt;.tcb&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#22266;&#23450;&#38263;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#12493;&#12483;&#12488;&#12527;&#12540;&#12463;&#12391;&#37197;&#24067;&#12377;&#12427;&#38555;&#12395;&#12399;&#12289;MIME&#12479;&#12452;&#12503;&#12434; `&lt;code&gt;application/x-tokyocabinet-fixlen&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12398;&#25509;&#23614;&#36766;&#12399; `&lt;code&gt;.tcf&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12486;&#12540;&#12502;&#12523;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#12493;&#12483;&#12488;&#12527;&#12540;&#12463;&#12391;&#37197;&#24067;&#12377;&#12427;&#38555;&#12395;&#12399;&#12289;MIME&#12479;&#12452;&#12503;&#12434; `&lt;code&gt;application/x-tokyocabinet-table&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12398;&#25509;&#23614;&#36766;&#12399; `&lt;code&gt;.tct&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&lt;/p&gt;
+&lt;p&gt;&#12394;&#12427;&#12409;&#12367;&#12394;&#12425;&#12289;&#12495;&#12483;&#12471;&#12517;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#12493;&#12483;&#12488;&#12527;&#12540;&#12463;&#12391;&#37197;&#24067;&#12377;&#12427;&#38555;&#12395;&#12399;&#12289;MIME&#12479;&#12452;&#12503;&#12434; `&lt;code&gt;application/x-tokyocabinet-hash&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12398;&#25509;&#23614;&#36766;&#12399; `&lt;code&gt;.tch&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;B+&#26408;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#12493;&#12483;&#12488;&#12527;&#12540;&#12463;&#12391;&#37197;&#24067;&#12377;&#12427;&#38555;&#12395;&#12399;&#12289;MIME&#12479;&#12452;&#12503;&#12434; `&lt;code&gt;application/x-tokyocabinet-btree&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12398;&#25509;&#23614;&#36766;&#12399; `&lt;code&gt;.tcb&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#22266;&#23450;&#38263;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#12493;&#12483;&#12488;&#12527;&#12540;&#12463;&#12391;&#37197;&#24067;&#12377;&#12427;&#38555;&#12395;&#12399;&#12289;MIME&#12479;&#12452;&#12503;&#12434; `&lt;code&gt;application/x-tokyocabinet-fixed&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12398;&#25509;&#23614;&#36766;&#12399; `&lt;code&gt;.tcf&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12486;&#12540;&#12502;&#12523;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12398;&#12501;&#12449;&#12452;&#12523;&#12434;&#12493;&#12483;&#12488;&#12527;&#12540;&#12463;&#12391;&#37197;&#24067;&#12377;&#12427;&#38555;&#12395;&#12399;&#12289;MIME&#12479;&#12452;&#12503;&#12434; `&lt;code&gt;application/x-tokyocabinet-table&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&#12501;&#12449;&#12452;&#12523;&#21517;&#12398;&#25509;&#23614;&#36766;&#12399; `&lt;code&gt;.tct&lt;/code&gt;' &#12395;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&lt;/p&gt;
 
 &lt;p&gt;&#12487;&#12540;&#12479;&#12505;&#12540;&#12473;&#12501;&#12449;&#12452;&#12523;&#12398;&#12510;&#12472;&#12483;&#12463;&#12487;&#12540;&#12479;&#12434; `&lt;code&gt;file&lt;/code&gt;' &#12467;&#12510;&#12531;&#12489;&#12395;&#35672;&#21029;&#12373;&#12379;&#12383;&#12356;&#22580;&#21512;&#12399;&#12289;`&lt;code&gt;magic&lt;/code&gt;' &#12501;&#12449;&#12452;&#12523;&#12395;&#20197;&#19979;&#12398;&#34892;&#12434;&#36861;&#35352;&#12375;&#12390;&#12367;&#12384;&#12373;&#12356;&#12290;&lt;/p&gt;
 
@@ -7276,9 +7298,13 @@ cp -f &quot;$srcpath&quot; &quot;$destpath&quot;
 0       string    ToKyO\ CaBiNeT\n   Tokyo Cabinet
 &amp;gt;14     string    x                  \b (%s)
 &amp;gt;32     byte      0                  \b, Hash
+!:mime  application/x-tokyocabinet-hash
 &amp;gt;32     byte      1                  \b, B+ tree
+!:mime  application/x-tokyocabinet-btree
 &amp;gt;32     byte      2                  \b, Fixed-length
+!:mime  application/x-tokyocabinet-fixed
 &amp;gt;32     byte      3                  \b, Table
+!:mime  application/x-tokyocabinet-table
 &amp;gt;33     byte      &amp;amp;1                 \b, [open]
 &amp;gt;33     byte      &amp;amp;2                 \b, [fatal]
 &amp;gt;34     byte      x                  \b, apow=%d
@@ -7288,9 +7314,9 @@ cp -f &quot;$srcpath&quot; &quot;$destpath&quot;
 &amp;gt;36     byte      &amp;amp;4                 \b, [bzip]
 &amp;gt;36     byte      &amp;amp;8                 \b, [tcbs]
 &amp;gt;36     byte      &amp;amp;16                \b, [excodec]
-&amp;gt;40     lelong    x                  \b, bnum=%d
-&amp;gt;48     lelong    x                  \b, rnum=%d
-&amp;gt;56     lelong    x                  \b, fsiz=%d
+&amp;gt;40     lequad    x                  \b, bnum=%lld
+&amp;gt;48     lequad    x                  \b, rnum=%lld
+&amp;gt;56     lequad    x                  \b, fsiz=%lld
 &lt;/pre&gt;
 
 &lt;hr /&gt;</diff>
      <filename>doc/spex-ja.html</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>doc/tokyoproducts.pdf</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>doc/tokyoproducts.ppt</filename>
    </modified>
    <modified>
      <diff>@@ -24,7 +24,7 @@ To use the abstract database API, include `\fBtcutil.h\fR', `\fBtcadb.h\fR', and
 .PP
 Objects whose type is pointer to `\fBTCADB\fR' are used to handle abstract databases.  An abstract database object is created with the function `\fBtcadbnew\fR' and is deleted with the function `\fBtcadbdel\fR'.  To avoid memory leak, it is important to delete every object when it is no longer in use.
 .PP
-Before operations to store or retrieve records, it is necessary to connect the abstract database object to the concrete one.  The function `\fBtcadbopen\fR' is used to open a concrete database and the function `\fBtcadbclose\fR' is used to close the database.  To avoid data missing or corruption, it is important to close every database file when it is no longer in use.
+Before operations to store or retrieve records, it is necessary to connect the abstract database object to the concrete one.  The function `\fBtcadbopen\fR' is used to open a concrete database and the function `\fBtcadbclose\fR' is used to close the database.  To avoid data missing or corruption, it is important to close every database instance when it is no longer in use.
 
 .SH API
 .PP
@@ -508,6 +508,25 @@ If successful, the return value is true, else, it is false.
 .RE
 .RE
 .PP
+The function `tcadboptimize' is used in order to optimize the storage of an abstract database object.
+.PP
+.RS
+.br
+\fBbool tcadboptimize(TCADB *\fIadb\fB, const char *\fIparams\fB);\fR
+.RS
+`\fIadb\fR' specifies the abstract database object.
+.RE
+.RS
+`\fIparams\fR' specifies the string of the tuning parameters, which works as with the tuning of parameters the function `tcadbopen'.  If it is `NULL', it is not used.
+.RE
+.RS
+If successful, the return value is true, else, it is false.
+.RE
+.RS
+This function is useful to reduce the size of the database storage with data fragmentation by successive updating.
+.RE
+.RE
+.PP
 The function `tcadbvanish' is used in order to remove all records of an abstract database object.
 .PP
 .RS
@@ -588,6 +607,19 @@ Update in the transaction is discarded when it is aborted.  The state of the dat
 .RE
 .RE
 .PP
+The function `tcadbpath' is used in order to get the file path of an abstract database object.
+.PP
+.RS
+.br
+\fBconst char *tcadbpath(TCADB *\fIadb\fB);\fR
+.RS
+`\fIadb\fR' specifies the abstract database object.
+.RE
+.RS
+The return value is the path of the database file or `NULL' if the object does not connect to any database.  &quot;*&quot; stands for on\-memory hash database.  &quot;+&quot; stands for on\-memory tree database.
+.RE
+.RE
+.PP
 The function `tcadbrnum' is used in order to get the number of records of an abstract database object.
 .PP
 .RS</diff>
      <filename>man/tcadb.3</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ tcamgr \- the command line utility of the abstract database API
 
 .SH DESCRIPTION
 .PP
-The command `\fBtcamgr\fR' is a utility for test and debugging of the abstract database API and its applications.  `\fIname\fR' specifies the name of a database.  `\fIkey\fR' specifies the key of a record.  `\fIvalue\fR' specifies the value of a record.  `\fIfunc\fR' specifies the name of a function.  `\fIarg\fR' specifies the arguments of the function.  `\fIdest\fR' specifies the path of the destination file.
+The command `\fBtcamgr\fR' is a utility for test and debugging of the abstract database API and its applications.  `\fIname\fR' specifies the name of a database.  `\fIkey\fR' specifies the key of a record.  `\fIvalue\fR' specifies the value of a record.  `\fIparams\fR' specifies the tuning parameters.  `\fIfunc\fR' specifies the name of a function.  `\fIarg\fR' specifies the arguments of the function.  `\fIdest\fR' specifies the path of the destination file.
 .PP
 .RS
 .br
@@ -39,6 +39,11 @@ Print the value of a record.
 Print keys of all records, separated by line feeds.
 .RE
 .br
+\fBtcamgr optimize \fIname\fB \fIparams\fB\fR
+.RS
+Optimize a database file.
+.RE
+.br
 \fBtcamgr misc \fR[\fB\-sx\fR]\fB \fR[\fB\-sep \fIchr\fB\fR]\fB \fR[\fB\-px\fR]\fB \fIname\fB \fIfunc\fB \fR[\fB\fIarg\fB...\fR]\fB\fR
 .RS
 Call a versatile function for miscellaneous operations.</diff>
      <filename>man/tcamgr.1</filename>
    </modified>
    <modified>
      <diff>@@ -145,7 +145,7 @@ The function `tctdbsetcache' is set the caching parameters of a table database o
 If successful, the return value is true, else, it is false.
 .RE
 .RS
-Note that the caching parameters should be set before the database is opened.  Leaf nodes and non\-leaf nodes are used in column indexes.
+Note that the caching parameters should be set before the database is opened.  Leaf nodes and non\-leaf nodes are used in column indices.
 .RE
 .RE
 .PP
@@ -893,7 +893,7 @@ The function `tctdbsetindex' is used in order to set a column index to a table d
 If successful, the return value is true, else, it is false.
 .RE
 .RS
-Note that the setting indexes should be set after the database is opened.
+Note that the setting indices should be set after the database is opened.
 .RE
 .RE
 .PP</diff>
      <filename>man/tctdb.3</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,7 @@ As for database of B+ tree, records whose keys are duplicated can be stored.  Ac
 .PP
 As for database of fixed\-length array, records are stored with unique natural numbers.  It is impossible to store two or more records with a key overlaps.  Moreover, the length of each record is limited by the specified length.  Provided operations are the same as ones of hash database.
 .PP
-Table database is also provided as a variant of hash database.  Each record is identified by the primary key and has a set of named columns.  Although there is no concept of data schema, it is possible to search for records with complex conditions efficiently by using indexes of arbitrary columns.
+Table database is also provided as a variant of hash database.  Each record is identified by the primary key and has a set of named columns.  Although there is no concept of data schema, it is possible to search for records with complex conditions efficiently by using indices of arbitrary columns.
 .PP
 Tokyo Cabinet is written in the C language, and provided as API of C, Perl, Ruby, Java, and Lua.  Tokyo Cabinet is available on platforms which have API conforming to C99 and POSIX.  Tokyo Cabinet is a free software licensed under the GNU Lesser General Public License.
 
@@ -78,7 +78,7 @@ Table database does not express simple key/value structure but expresses a struc
 .PP
 Table database supports query functions with not only the primary key but also with conditions about arbitrary columns.  Each column condition is composed of the name of a column and a condition expression.  Operators of full matching, forward matching, regular expression matching, and so on are provided for the string type.  Operators of full matching, range matching and so on are provided for the number type.  A query can contain multiple conditions.  The order of the result set can be specified as the ascending or descending order of strings or numbers.
 .PP
-You can create indexes for arbitrary columns to improve performance of search and sorting.  Although columns do not have data types, indexes have types for strings or numbers.  The query optimizer uses indexes in suitable way according to each query.  Indexes are implemented as different files of B+ tree database.
+You can create indices for arbitrary columns to improve performance of search and sorting.  Although columns do not have data types, indices have types for strings or numbers.  The query optimizer uses indices in suitable way according to each query.  Indices are implemented as different files of B+ tree database.
 
 .SH PRACTICAL FUNCTIONALITY
 .PP</diff>
      <filename>man/tokyocabinet.3</filename>
    </modified>
    <modified>
      <diff>@@ -872,6 +872,7 @@ bool tcadbsync(TCADB *adb){
         tcmdbcutfront(adb-&gt;mdb, 1);
       }
     }
+    adb-&gt;capcnt = 0;
     break;
   case ADBONDB:
     if(adb-&gt;capnum &gt; 0 &amp;&amp; tcndbrnum(adb-&gt;ndb) &gt; adb-&gt;capnum)
@@ -881,6 +882,7 @@ bool tcadbsync(TCADB *adb){
         tcndbcutfringe(adb-&gt;ndb, 0x100);
       }
     }
+    adb-&gt;capcnt = 0;
     break;
   case ADBOHDB:
     if(!tchdbsync(adb-&gt;hdb)) err = true;
@@ -902,6 +904,117 @@ bool tcadbsync(TCADB *adb){
 }
 
 
+/* Optimize the storage of an abstract database object. */
+bool tcadboptimize(TCADB *adb, const char *params){
+  assert(adb);
+  TCLIST *elems = params ? tcstrsplit(params, &quot;#&quot;) : tclistnew();
+  int64_t bnum = -1;
+  int64_t capnum = -1;
+  int64_t capsiz = -1;
+  int8_t apow = -1;
+  int8_t fpow = -1;
+  bool tdefault = true;
+  bool tlmode = false;
+  bool tdmode = false;
+  bool tbmode = false;
+  bool ttmode = false;
+  int32_t lmemb = -1;
+  int32_t nmemb = -1;
+  int32_t width = -1;
+  int64_t limsiz = -1;
+  int ln = TCLISTNUM(elems);
+  for(int i = 0; i &lt; ln; i++){
+    const char *elem = TCLISTVALPTR(elems, i);
+    char *pv = strchr(elem, '=');
+    if(!pv) continue;
+    *(pv++) = '\0';
+    if(!tcstricmp(elem, &quot;bnum&quot;)){
+      bnum = tcatoix(pv);
+    } else if(!tcstricmp(elem, &quot;capnum&quot;)){
+      capnum = tcatoix(pv);
+    } else if(!tcstricmp(elem, &quot;capsiz&quot;)){
+      capsiz = tcatoix(pv);
+    } else if(!tcstricmp(elem, &quot;apow&quot;)){
+      apow = tcatoix(pv);
+    } else if(!tcstricmp(elem, &quot;fpow&quot;)){
+      fpow = tcatoix(pv);
+    } else if(!tcstricmp(elem, &quot;opts&quot;)){
+      tdefault = false;
+      if(strchr(pv, 'l') || strchr(pv, 'L')) tlmode = true;
+      if(strchr(pv, 'd') || strchr(pv, 'D')) tdmode = true;
+      if(strchr(pv, 'b') || strchr(pv, 'B')) tbmode = true;
+      if(strchr(pv, 't') || strchr(pv, 'T')) ttmode = true;
+    } else if(!tcstricmp(elem, &quot;lmemb&quot;)){
+      lmemb = tcatoix(pv);
+    } else if(!tcstricmp(elem, &quot;nmemb&quot;)){
+      nmemb = tcatoix(pv);
+    } else if(!tcstricmp(elem, &quot;width&quot;)){
+      width = tcatoix(pv);
+    } else if(!tcstricmp(elem, &quot;limsiz&quot;)){
+      limsiz = tcatoix(pv);
+    }
+  }
+  tclistdel(elems);
+  bool err = false;
+  int opts;
+  switch(adb-&gt;omode){
+  case ADBOMDB:
+    adb-&gt;capnum = capnum;
+    adb-&gt;capsiz = capsiz;
+    tcadbsync(adb);
+    break;
+  case ADBONDB:
+    adb-&gt;capnum = capnum;
+    adb-&gt;capsiz = capsiz;
+    tcadbsync(adb);
+    break;
+  case ADBOHDB:
+    opts = 0;
+    if(tdefault){
+      opts = UINT8_MAX;
+    } else {
+      if(tlmode) opts |= HDBTLARGE;
+      if(tdmode) opts |= HDBTDEFLATE;
+      if(tbmode) opts |= HDBTBZIP;
+      if(ttmode) opts |= HDBTTCBS;
+    }
+    if(!tchdboptimize(adb-&gt;hdb, bnum, apow, fpow, opts)) err = true;
+    break;
+  case ADBOBDB:
+    opts = 0;
+    if(tdefault){
+      opts = UINT8_MAX;
+    } else {
+      if(tlmode) opts |= BDBTLARGE;
+      if(tdmode) opts |= BDBTDEFLATE;
+      if(tbmode) opts |= BDBTBZIP;
+      if(ttmode) opts |= BDBTTCBS;
+    }
+    if(!tcbdboptimize(adb-&gt;bdb, lmemb, nmemb, bnum, apow, fpow, opts)) err = true;
+    break;
+  case ADBOFDB:
+    if(!tcfdboptimize(adb-&gt;fdb, width, limsiz)) err = true;
+    break;
+  case ADBOTDB:
+    opts = 0;
+    if(tdefault){
+      opts = UINT8_MAX;
+    } else {
+      if(tlmode) opts |= TDBTLARGE;
+      if(tdmode) opts |= TDBTDEFLATE;
+      if(tbmode) opts |= TDBTBZIP;
+      if(ttmode) opts |= TDBTTCBS;
+    }
+    if(!tctdboptimize(adb-&gt;tdb, bnum, apow, fpow, opts)) err = true;
+    break;
+  default:
+    err = true;
+    break;
+  }
+  return !err;
+}
+
+
 /* Remove all records of an abstract database object. */
 bool tcadbvanish(TCADB *adb){
   assert(adb);
@@ -1083,6 +1196,37 @@ bool tcadbtranabort(TCADB *adb){
 }
 
 
+/* Get the file path of an abstract database object. */
+const char *tcadbpath(TCADB *adb){
+  assert(adb);
+  const char *rv;
+  switch(adb-&gt;omode){
+  case ADBOMDB:
+    rv = &quot;*&quot;;
+    break;
+  case ADBONDB:
+    rv = &quot;+&quot;;
+    break;
+  case ADBOHDB:
+    rv = tchdbpath(adb-&gt;hdb);
+    break;
+  case ADBOBDB:
+    rv = tcbdbpath(adb-&gt;bdb);
+    break;
+  case ADBOFDB:
+    rv = tcfdbpath(adb-&gt;fdb);
+    break;
+  case ADBOTDB:
+    rv = tctdbpath(adb-&gt;tdb);
+    break;
+  default:
+    rv = NULL;
+    break;
+  }
+  return rv;
+}
+
+
 /* Get the number of records of an abstract database object. */
 uint64_t tcadbrnum(TCADB *adb){
   assert(adb);</diff>
      <filename>tcadb.c</filename>
    </modified>
    <modified>
      <diff>@@ -324,6 +324,16 @@ double tcadbadddouble(TCADB *adb, const void *kbuf, int ksiz, double num);
 bool tcadbsync(TCADB *adb);
 
 
+/* Optimize the storage of an abstract database object.
+   `adb' specifies the abstract database object.
+   `params' specifies the string of the tuning parameters, which works as with the tuning
+   of parameters the function `tcadbopen'.  If it is `NULL', it is not used.
+   If successful, the return value is true, else, it is false.
+   This function is useful to reduce the size of the database storage with data fragmentation by
+   successive updating. */
+bool tcadboptimize(TCADB *adb, const char *params);
+
+
 /* Remove all records of an abstract database object.
    `adb' specifies the abstract database object.
    If successful, the return value is true, else, it is false. */
@@ -368,6 +378,14 @@ bool tcadbtrancommit(TCADB *adb);
 bool tcadbtranabort(TCADB *adb);
 
 
+/* Get the file path of an abstract database object.
+   `adb' specifies the abstract database object.
+   The return value is the path of the database file or `NULL' if the object does not connect to
+   any database.  &quot;*&quot; stands for on-memory hash database.  &quot;+&quot; stands for on-memory tree
+   database. */
+const char *tcadbpath(TCADB *adb);
+
+
 /* Get the number of records of an abstract database object.
    `adb' specifies the abstract database object.
    The return value is the number of records or 0 if the object does not connect to any database</diff>
      <filename>tcadb.h</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,7 @@ static int runput(int argc, char **argv);
 static int runout(int argc, char **argv);
 static int runget(int argc, char **argv);
 static int runlist(int argc, char **argv);
+static int runoptimize(int argc, char **argv);
 static int runmisc(int argc, char **argv);
 static int runmap(int argc, char **argv);
 static int runversion(int argc, char **argv);
@@ -49,6 +50,7 @@ static int procput(const char *name, const char *kbuf, int ksiz, const char *vbu
 static int procout(const char *name, const char *kbuf, int ksiz);
 static int procget(const char *name, const char *kbuf, int ksiz, int sep, bool px, bool pz);
 static int proclist(const char *name, int sep, int max, bool pv, bool px, const char *fmstr);
+static int procoptimize(const char *name, const char *params);
 static int procmisc(const char *name, const char *func, const TCLIST *args, int sep, bool px);
 static int procmap(const char *name, const char *dest, const char *fmstr);
 static int procversion(void);
@@ -71,6 +73,8 @@ int main(int argc, char **argv){
     rv = runget(argc, argv);
   } else if(!strcmp(argv[1], &quot;list&quot;)){
     rv = runlist(argc, argv);
+  } else if(!strcmp(argv[1], &quot;optimize&quot;)){
+    rv = runoptimize(argc, argv);
   } else if(!strcmp(argv[1], &quot;misc&quot;)){
     rv = runmisc(argc, argv);
   } else if(!strcmp(argv[1], &quot;map&quot;)){
@@ -95,6 +99,7 @@ static void usage(void){
   fprintf(stderr, &quot;  %s out [-sx] [-sep chr] name key\n&quot;, g_progname);
   fprintf(stderr, &quot;  %s get [-sx] [-sep chr] [-px] [-pz] name key\n&quot;, g_progname);
   fprintf(stderr, &quot;  %s list [-sep chr] [-m num] [-pv] [-px] [-fm str] name\n&quot;, g_progname);
+  fprintf(stderr, &quot;  %s optimize name [params]\n&quot;, g_progname);
   fprintf(stderr, &quot;  %s misc [-sx] [-sep chr] [-px] name func [arg...]\n&quot;, g_progname);
   fprintf(stderr, &quot;  %s map [-fm str] name dest\n&quot;, g_progname);
   fprintf(stderr, &quot;  %s version\n&quot;, g_progname);
@@ -126,7 +131,8 @@ static char *strtozsv(const char *str, int sep, int *sp){
 
 /* print error information */
 static void printerr(TCADB *adb){
-  fprintf(stderr, &quot;%s: error\n&quot;, g_progname);
+  const char *path = tcadbpath(adb);
+  fprintf(stderr, &quot;%s: %s: error\n&quot;, g_progname, path ? path : &quot;-&quot;);
 }
 
 
@@ -389,6 +395,27 @@ static int runlist(int argc, char **argv){
 }
 
 
+/* parse arguments of optimize command */
+static int runoptimize(int argc, char **argv){
+  char *name = NULL;
+  char *params = NULL;
+  for(int i = 2; i &lt; argc; i++){
+    if(!name &amp;&amp; argv[i][0] == '-'){
+      usage();
+    } else if(!name){
+      name = argv[i];
+    } else if(!params){
+      params = argv[i];
+    } else {
+      usage();
+    }
+  }
+  if(!name) usage();
+  int rv = procoptimize(name, params);
+  return rv;
+}
+
+
 /* parse arguments of misc command */
 static int runmisc(int argc, char **argv){
   char *name = NULL;
@@ -498,6 +525,9 @@ static int procinform(const char *name){
     return 1;
   }
   bool err = false;
+  const char *path = tcadbpath(adb);
+  if(!path) path = &quot;(unknown)&quot;;
+  printf(&quot;path: %s\n&quot;, path);
   const char *type = &quot;(unknown)&quot;;
   switch(tcadbomode(adb)){
   case ADBOVOID: type = &quot;not opened&quot;; break;
@@ -506,6 +536,7 @@ static int procinform(const char *name){
   case ADBOHDB: type = &quot;hash database&quot;; break;
   case ADBOBDB: type = &quot;B+ tree database&quot;; break;
   case ADBOFDB: type = &quot;fixed-length database&quot;; break;
+  case ADBOTDB: type = &quot;table database&quot;; break;
   }
   printf(&quot;database type: %s\n&quot;, type);
   printf(&quot;record number: %llu\n&quot;, (unsigned long long)tcadbrnum(adb));
@@ -680,6 +711,28 @@ static int proclist(const char *name, int sep, int max, bool pv, bool px, const
 }
 
 
+/* perform optimize command */
+static int procoptimize(const char *name, const char *params){
+  TCADB *adb = tcadbnew();
+  if(!tcadbopen(adb, name)){
+    printerr(adb);
+    tcadbdel(adb);
+    return 1;
+  }
+  bool err = false;
+  if(!tcadboptimize(adb, params)){
+    printerr(adb);
+    err = true;
+  }
+  if(!tcadbclose(adb)){
+    if(!err) printerr(adb);
+    err = true;
+  }
+  tcadbdel(adb);
+  return err ? 1 : 0;
+}
+
+
 /* perform misc command */
 static int procmisc(const char *name, const char *func, const TCLIST *args, int sep, bool px){
   TCADB *adb = tcadbnew();</diff>
      <filename>tcamgr.c</filename>
    </modified>
    <modified>
      <diff>@@ -116,7 +116,8 @@ static void iputchar(int c){
 
 /* print error message of abstract database */
 static void eprint(TCADB *adb, const char *func){
-  fprintf(stderr, &quot;%s: %s: error\n&quot;, g_progname, func);
+  const char *path = tcadbpath(adb);
+  fprintf(stderr, &quot;%s: %s: %s: error\n&quot;, g_progname, path ? path : &quot;-&quot;, func);
 }
 
 
@@ -680,6 +681,10 @@ static int procmisc(const char *name, int rnum){
     eprint(adb, &quot;tcadbsync&quot;);
     err = true;
   }
+  if(myrand(10) == 0 &amp;&amp; !tcadboptimize(adb, NULL)){
+    eprint(adb, &quot;tcadboptimize&quot;);
+    err = true;
+  }
   if(!tcadbvanish(adb)){
     eprint(adb, &quot;tcadbvanish&quot;);
     err = true;</diff>
      <filename>tcatest.c</filename>
    </modified>
    <modified>
      <diff>@@ -62,7 +62,7 @@ typedef struct {                         // type of structure for a page index
 typedef struct {                         // type of structure for a node page
   uint64_t id;                           // ID number of the node
   uint64_t heir;                         // ID of the child before the first index
-  TCPTRLIST *idxs;                       // list of indexes
+  TCPTRLIST *idxs;                       // list of indices
   bool dirty;                            // whether to be written back
   bool dead;                             // whether to be removed
 } BDBNODE;
@@ -806,11 +806,17 @@ bool tcbdbcopy(TCBDB *bdb, const char *path){
 /* Begin the transaction of a B+ tree database object. */
 bool tcbdbtranbegin(TCBDB *bdb){
   assert(bdb);
-  if(!BDBLOCKMETHOD(bdb, true)) return false;
-  if(!bdb-&gt;open || !bdb-&gt;wmode || bdb-&gt;tran){
-    tcbdbsetecode(bdb, TCEINVALID, __FILE__, __LINE__, __func__);
+  for(double wsec = 1.0 / sysconf(_SC_CLK_TCK); true; wsec *= 2){
+    if(!BDBLOCKMETHOD(bdb, true)) return false;
+    if(!bdb-&gt;open || !bdb-&gt;wmode){
+      tcbdbsetecode(bdb, TCEINVALID, __FILE__, __LINE__, __func__);
+      BDBUNLOCKMETHOD(bdb);
+      return false;
+    }
+    if(!bdb-&gt;tran) break;
     BDBUNLOCKMETHOD(bdb);
-    return false;
+    if(wsec &gt; 1.0) wsec = 1.0;
+    tcsleep(wsec);
   }
   if(!tcbdbmemsync(bdb, false)){
     BDBUNLOCKMETHOD(bdb);
@@ -3570,7 +3576,10 @@ static bool tcbdbcurjumpimpl(BDBCUR *cur, const char *kbuf, int ksiz, bool forwa
     } else {
       rv = bdb-&gt;cmp(kbuf, ksiz, dbuf, rec-&gt;ksiz, bdb-&gt;cmpop);
     }
-    if(rv &lt; 0) return true;
+    if(rv &lt; 0){
+      cur-&gt;vidx = 0;
+      return true;
+    }
     cur-&gt;vidx = rec-&gt;rest ? TCLISTNUM(rec-&gt;rest) : 0;
     return tcbdbcurnextimpl(cur);
   }
@@ -4012,7 +4021,7 @@ void tcbdbprintleaf(TCBDB *bdb, BDBLEAF *leaf){
 }
 
 
-/* Print indexes of a node object into the debugging output.
+/* Print indices of a node object into the debugging output.
    `bdb' specifies the B+ tree database object.
    `node' specifies the node object. */
 void tcbdbprintnode(TCBDB *bdb, BDBNODE *node){</diff>
      <filename>tcbdb.c</filename>
    </modified>
    <modified>
      <diff>@@ -1328,6 +1328,33 @@ static void *threadwicked(void *targ){
       break;
     default:
       if(id == 0) iputchar('@');
+      if(tcbdbtranbegin(bdb)){
+        if(myrand(2) == 0){
+          if(!tcbdbput(bdb, kbuf, ksiz, vbuf, vsiz)){
+            eprint(bdb, &quot;tcbdbput&quot;);
+            err = true;
+          }
+        } else {
+          if(!tcbdbout(bdb, kbuf, ksiz) &amp;&amp; tcbdbecode(bdb) != TCENOREC){
+            eprint(bdb, &quot;tcbdbout&quot;);
+            err = true;
+          }
+        }
+        if(nc &amp;&amp; myrand(2) == 0){
+          if(!tcbdbtrancommit(bdb)){
+            eprint(bdb, &quot;tcbdbtrancommit&quot;);
+            err = true;
+          }
+        } else {
+          if(!tcbdbtranabort(bdb)){
+            eprint(bdb, &quot;tcbdbtranabort&quot;);
+            err = true;
+          }
+        }
+      } else {
+        eprint(bdb, &quot;tcbdbtranbegin&quot;);
+        err = true;
+      }
       if(myrand(1000) == 0){
         if(!tcbdbforeach(bdb, iterfunc, NULL)){
           eprint(bdb, &quot;tcbdbforeach&quot;);
@@ -1341,7 +1368,7 @@ static void *threadwicked(void *targ){
     if(id == 0){
       if(i % 50 == 0) iprintf(&quot; (%08d)\n&quot;, i);
       if(id == 0 &amp;&amp; i == rnum / 4){
-        if(!tcbdboptimize(bdb, -1, -1, -1, -1, -1, -1)){
+        if(!tcbdboptimize(bdb, -1, -1, -1, -1, -1, -1) &amp;&amp; tcbdbecode(bdb) != TCEINVALID){
           eprint(bdb, &quot;tcbdboptimize&quot;);
           err = true;
         }</diff>
      <filename>tcbmttest.c</filename>
    </modified>
    <modified>
      <diff>@@ -72,10 +72,6 @@ typedef struct {                         // type of structure for a duplication
   ((TC_fdb)-&gt;mmtx ? tcfdblockallrecords((TC_fdb), (TC_wr)) : true)
 #define FDBUNLOCKALLRECORDS(TC_fdb) \
   ((TC_fdb)-&gt;mmtx ? tcfdbunlockallrecords(TC_fdb) : true)
-#define FDBLOCKTRAN(TC_fdb) \
-  ((TC_fdb)-&gt;mmtx ? tcfdblocktran(TC_fdb) : true)
-#define FDBUNLOCKTRAN(TC_fdb) \
-  ((TC_fdb)-&gt;mmtx ? tcfdbunlocktran(TC_fdb) : true)
 #define FDBLOCKWAL(TC_fdb) \
   ((TC_fdb)-&gt;mmtx ? tcfdblockwal(TC_fdb) : true)
 #define FDBUNLOCKWAL(TC_fdb) \
@@ -115,8 +111,6 @@ static bool tcfdblockrecord(TCFDB *fdb, bool wr, uint64_t id);
 static bool tcfdbunlockrecord(TCFDB *fdb, uint64_t id);
 static bool tcfdblockallrecords(TCFDB *fdb, bool wr);
 static bool tcfdbunlockallrecords(TCFDB *fdb);
-static bool tcfdblocktran(TCFDB *fdb);
-static bool tcfdbunlocktran(TCFDB *fdb);
 static bool tcfdblockwal(TCFDB *fdb);
 static bool tcfdbunlockwal(TCFDB *fdb);
 
@@ -881,7 +875,7 @@ bool tcfdbvanish(TCFDB *fdb){
 bool tcfdbcopy(TCFDB *fdb, const char *path){
   assert(fdb &amp;&amp; path);
   if(!FDBLOCKMETHOD(fdb, false)) return false;
-  if(fdb-&gt;fd &lt; 0 || !(fdb-&gt;omode &amp; FDBOWRITER)){
+  if(fdb-&gt;fd &lt; 0){
     tcfdbsetecode(fdb, TCEINVALID, __FILE__, __LINE__, __func__);
     FDBUNLOCKMETHOD(fdb);
     return false;
@@ -901,11 +895,17 @@ bool tcfdbcopy(TCFDB *fdb, const char *path){
 /* Begin the transaction of a fixed-length database object. */
 bool tcfdbtranbegin(TCFDB *fdb){
   assert(fdb);
-  if(!FDBLOCKMETHOD(fdb, true)) return false;
-  if(fdb-&gt;fd &lt; 0 || !(fdb-&gt;omode &amp; FDBOWRITER) || fdb-&gt;fatal || fdb-&gt;tran){
-    tcfdbsetecode(fdb, TCEINVALID, __FILE__, __LINE__, __func__);
+  for(double wsec = 1.0 / sysconf(_SC_CLK_TCK); true; wsec *= 2){
+    if(!FDBLOCKMETHOD(fdb, true)) return false;
+    if(fdb-&gt;fd &lt; 0 || !(fdb-&gt;omode &amp; FDBOWRITER) || fdb-&gt;fatal){
+      tcfdbsetecode(fdb, TCEINVALID, __FILE__, __LINE__, __func__);
+      FDBUNLOCKMETHOD(fdb);
+      return false;
+    }
+    if(!fdb-&gt;tran) break;
     FDBUNLOCKMETHOD(fdb);
-    return false;
+    if(wsec &gt; 1.0) wsec = 1.0;
+    tcsleep(wsec);
   }
   fdb-&gt;flags &amp;= ~FDBFOPEN;
   if(!tcfdbmemsync(fdb, false)){
@@ -938,10 +938,6 @@ bool tcfdbtranbegin(TCFDB *fdb){
     FDBUNLOCKMETHOD(fdb);
     return false;
   }
-  if(!FDBLOCKTRAN(fdb)){
-    FDBUNLOCKMETHOD(fdb);
-    return false;
-  }
   fdb-&gt;tran = true;
   FDBUNLOCKMETHOD(fdb);
   return true;
@@ -964,7 +960,6 @@ bool tcfdbtrancommit(TCFDB *fdb){
     err = true;
   }
   fdb-&gt;tran = false;
-  FDBUNLOCKTRAN(fdb);
   FDBUNLOCKMETHOD(fdb);
   return !err;
 }
@@ -993,7 +988,6 @@ bool tcfdbtranabort(TCFDB *fdb){
     tcfdbloadmeta(fdb, hbuf);
   }
   fdb-&gt;tran = false;
-  FDBUNLOCKTRAN(fdb);
   FDBUNLOCKMETHOD(fdb);
   return !err;
 }
@@ -1140,7 +1134,7 @@ uint64_t tcfdbmax(TCFDB *fdb){
 
 
 /* Get the width of the value of each record of a fixed-length database object. */
-uint64_t tcfdbwidth(TCFDB *fdb){
+uint32_t tcfdbwidth(TCFDB *fdb){
   assert(fdb);
   if(fdb-&gt;fd &lt; 0){
     tcfdbsetecode(fdb, TCEINVALID, __FILE__, __LINE__, __func__);
@@ -1808,7 +1802,6 @@ static bool tcfdbcloseimpl(TCFDB *fdb){
   if(fdb-&gt;tran){
     if(!tcfdbwalrestore(fdb, fdb-&gt;path)) err = true;
     fdb-&gt;tran = false;
-    FDBUNLOCKTRAN(fdb);
   }
   if(fdb-&gt;walfd &gt;= 0){
     if(close(fdb-&gt;walfd) == -1){
@@ -2561,34 +2554,6 @@ static bool tcfdbunlockallrecords(TCFDB *fdb){
 }
 
 
-/* Lock the transaction of the fixed-length database object.
-   `fdb' specifies the fixed-length database object.
-   If successful, the return value is true, else, it is false. */
-static bool tcfdblocktran(TCFDB *fdb){
-  assert(fdb);
-  if(pthread_mutex_lock(fdb-&gt;tmtx) != 0){
-    tcfdbsetecode(fdb, TCETHREAD, __FILE__, __LINE__, __func__);
-    return false;
-  }
-  TCTESTYIELD();
-  return true;
-}
-
-
-/* Unlock the transaction of the fixed-length database object.
-   `fdb' specifies the fixed-length database object.
-   If successful, the return value is true, else, it is false. */
-static bool tcfdbunlocktran(TCFDB *fdb){
-  assert(fdb);
-  if(pthread_mutex_unlock(fdb-&gt;tmtx) != 0){
-    tcfdbsetecode(fdb, TCETHREAD, __FILE__, __LINE__, __func__);
-    return false;
-  }
-  TCTESTYIELD();
-  return true;
-}
-
-
 /* Lock the write ahead logging file of the fixed-length database object.
    `fdb' specifies the fixed-length database object.
    If successful, the return value is true, else, it is false. */</diff>
      <filename>tcfdb.c</filename>
    </modified>
    <modified>
      <diff>@@ -720,7 +720,7 @@ uint64_t tcfdbmax(TCFDB *fdb);
    `fdb' specifies the fixed-length database object.
    The return value is the width of the value of each record or 0 if the object does not connect
    to any database file. */
-uint64_t tcfdbwidth(TCFDB *fdb);
+uint32_t tcfdbwidth(TCFDB *fdb);
 
 
 /* Get the limit file size of a fixed-length database object.</diff>
      <filename>tcfdb.h</filename>
    </modified>
    <modified>
      <diff>@@ -679,7 +679,7 @@ static int procwicked(const char *path, int tnum, int rnum, int omode, bool nc){
       char *rbuf = tcfdbget2(fdb, kbuf, ksiz, &amp;rsiz);
       if(vbuf){
         iputchar('.');
-        if(vsiz &gt; RECBUFSIZ) vsiz = RECBUFSIZ;
+        if(vsiz &gt; tcfdbwidth(fdb)) vsiz = tcfdbwidth(fdb);
         if(!rbuf){
           eprint(fdb, &quot;tcfdbget&quot;);
           err = true;
@@ -1023,6 +1023,33 @@ static void *threadwicked(void *targ){
       break;
     default:
       if(id == 0) iputchar('@');
+      if(tcfdbtranbegin(fdb)){
+        if(myrand(2) == 0){
+          if(!tcfdbput2(fdb, kbuf, ksiz, vbuf, vsiz)){
+            eprint(fdb, &quot;tcfdbput&quot;);
+            err = true;
+          }
+        } else {
+          if(!tcfdbout2(fdb, kbuf, ksiz) &amp;&amp; tcfdbecode(fdb) != TCENOREC){
+            eprint(fdb, &quot;tcfdbout&quot;);
+            err = true;
+          }
+        }
+        if(nc &amp;&amp; myrand(2) == 0){
+          if(!tcfdbtrancommit(fdb)){
+            eprint(fdb, &quot;tcfdbtrancommit&quot;);
+            err = true;
+          }
+        } else {
+          if(!tcfdbtranabort(fdb)){
+            eprint(fdb, &quot;tcfdbtranabort&quot;);
+            err = true;
+          }
+        }
+      } else {
+        eprint(fdb, &quot;tcfdbtranbegin&quot;);
+        err = true;
+      }
       if(myrand(1000) == 0){
         if(!tcfdbforeach(fdb, iterfunc, NULL)){
           eprint(fdb, &quot;tcfdbforeach&quot;);
@@ -1036,7 +1063,7 @@ static void *threadwicked(void *targ){
     if(id == 0){
       if(i % 50 == 0) iprintf(&quot; (%08d)\n&quot;, i);
       if(id == 0 &amp;&amp; i == rnum / 4){
-        if(!tcfdboptimize(fdb, RECBUFSIZ, -1)){
+        if(!tcfdboptimize(fdb, RECBUFSIZ, -1) &amp;&amp; tcfdbecode(fdb) != TCEINVALID){
           eprint(fdb, &quot;tcfdboptimize&quot;);
           err = true;
         }</diff>
      <filename>tcfmttest.c</filename>
    </modified>
    <modified>
      <diff>@@ -1603,7 +1603,7 @@ static int procwicked(const char *path, int rnum, bool mt, int omode){
     iputchar('+');
     int vsiz;
     const char *vbuf = tcmapiterval(kbuf, &amp;vsiz);
-    if(vsiz &gt; RECBUFSIZ) vsiz = RECBUFSIZ;
+    if(vsiz &gt; tcfdbwidth(fdb)) vsiz = tcfdbwidth(fdb);
     int rsiz;
     char *rbuf = tcfdbget2(fdb, kbuf, ksiz, &amp;rsiz);
     if(!rbuf){</diff>
      <filename>tcftest.c</filename>
    </modified>
    <modified>
      <diff>@@ -111,10 +111,6 @@ typedef struct {                         // type of structure for a duplication
   ((TC_hdb)-&gt;mmtx ? tchdblockdb(TC_hdb) : true)
 #define HDBUNLOCKDB(TC_hdb) \
   ((TC_hdb)-&gt;mmtx ? tchdbunlockdb(TC_hdb) : true)
-#define HDBLOCKTRAN(TC_hdb) \
-  ((TC_hdb)-&gt;mmtx ? tchdblocktran(TC_hdb) : true)
-#define HDBUNLOCKTRAN(TC_hdb) \
-  ((TC_hdb)-&gt;mmtx ? tchdbunlocktran(TC_hdb) : true)
 #define HDBLOCKWAL(TC_hdb) \
   ((TC_hdb)-&gt;mmtx ? tchdblockwal(TC_hdb) : true)
 #define HDBUNLOCKWAL(TC_hdb) \
@@ -187,8 +183,6 @@ static bool tchdblockallrecords(TCHDB *hdb, bool wr);
 static bool tchdbunlockallrecords(TCHDB *hdb);
 static bool tchdblockdb(TCHDB *hdb);
 static bool tchdbunlockdb(TCHDB *hdb);
-static bool tchdblocktran(TCHDB *hdb);
-static bool tchdbunlocktran(TCHDB *hdb);
 static bool tchdblockwal(TCHDB *hdb);
 static bool tchdbunlockwal(TCHDB *hdb);
 
@@ -1019,7 +1013,7 @@ bool tchdbvanish(TCHDB *hdb){
 bool tchdbcopy(TCHDB *hdb, const char *path){
   assert(hdb &amp;&amp; path);
   if(!HDBLOCKMETHOD(hdb, false)) return false;
-  if(hdb-&gt;fd &lt; 0 || !(hdb-&gt;omode &amp; HDBOWRITER)){
+  if(hdb-&gt;fd &lt; 0){
     tchdbsetecode(hdb, TCEINVALID, __FILE__, __LINE__, __func__);
     HDBUNLOCKMETHOD(hdb);
     return false;
@@ -1043,11 +1037,17 @@ bool tchdbcopy(TCHDB *hdb, const char *path){
 /* Begin the transaction of a hash database object. */
 bool tchdbtranbegin(TCHDB *hdb){
   assert(hdb);
-  if(!HDBLOCKMETHOD(hdb, true)) return false;
-  if(hdb-&gt;fd &lt; 0 || !(hdb-&gt;omode &amp; HDBOWRITER) || hdb-&gt;fatal || hdb-&gt;tran){
-    tchdbsetecode(hdb, TCEINVALID, __FILE__, __LINE__, __func__);
+  for(double wsec = 1.0 / sysconf(_SC_CLK_TCK); true; wsec *= 2){
+    if(!HDBLOCKMETHOD(hdb, true)) return false;
+    if(hdb-&gt;fd &lt; 0 || !(hdb-&gt;omode &amp; HDBOWRITER) || hdb-&gt;fatal){
+      tchdbsetecode(hdb, TCEINVALID, __FILE__, __LINE__, __func__);
+      HDBUNLOCKMETHOD(hdb);
+      return false;
+    }
+    if(!hdb-&gt;tran) break;
     HDBUNLOCKMETHOD(hdb);
-    return false;
+    if(wsec &gt; 1.0) wsec = 1.0;
+    tcsleep(wsec);
   }
   if(hdb-&gt;async &amp;&amp; !tchdbflushdrp(hdb)){
     HDBUNLOCKMETHOD(hdb);
@@ -1084,10 +1084,6 @@ bool tchdbtranbegin(TCHDB *hdb){
     HDBUNLOCKMETHOD(hdb);
     return false;
   }
-  if(!HDBLOCKTRAN(hdb)){
-    HDBUNLOCKMETHOD(hdb);
-    return false;
-  }
   hdb-&gt;tran = true;
   HDBUNLOCKMETHOD(hdb);
   return true;
@@ -1111,7 +1107,6 @@ bool tchdbtrancommit(TCHDB *hdb){
     err = true;
   }
   hdb-&gt;tran = false;
-  HDBUNLOCKTRAN(hdb);
   HDBUNLOCKMETHOD(hdb);
   return !err;
 }
@@ -1140,11 +1135,11 @@ bool tchdbtranabort(TCHDB *hdb){
   } else {
     tchdbloadmeta(hdb, hbuf);
   }
+  hdb-&gt;iter = 0;
   hdb-&gt;xfsiz = 0;
   hdb-&gt;fbpnum = 0;
   if(hdb-&gt;recc) tcmdbvanish(hdb-&gt;recc);
   hdb-&gt;tran = false;
-  HDBUNLOCKTRAN(hdb);
   HDBUNLOCKMETHOD(hdb);
   return !err;
 }
@@ -1648,7 +1643,6 @@ bool tchdbtranvoid(TCHDB *hdb){
     return false;
   }
   hdb-&gt;tran = false;
-  HDBUNLOCKTRAN(hdb);
   HDBUNLOCKMETHOD(hdb);
   return true;
 }
@@ -3237,7 +3231,6 @@ static bool tchdbcloseimpl(TCHDB *hdb){
   if(hdb-&gt;tran){
     if(!tchdbwalrestore(hdb, hdb-&gt;path)) err = true;
     hdb-&gt;tran = false;
-    HDBUNLOCKTRAN(hdb);
   }
   if(hdb-&gt;walfd &gt;= 0){
     if(close(hdb-&gt;walfd) == -1){
@@ -4521,34 +4514,6 @@ static bool tchdbunlockdb(TCHDB *hdb){
 }
 
 
-/* Lock the transaction of the hash database object.
-   `hdb' specifies the hash database object.
-   If successful, the return value is true, else, it is false. */
-static bool tchdblocktran(TCHDB *hdb){
-  assert(hdb);
-  if(pthread_mutex_lock(hdb-&gt;tmtx) != 0){
-    tchdbsetecode(hdb, TCETHREAD, __FILE__, __LINE__, __func__);
-    return false;
-  }
-  TCTESTYIELD();
-  return true;
-}
-
-
-/* Unlock the transaction of the hash database object.
-   `hdb' specifies the hash database object.
-   If successful, the return value is true, else, it is false. */
-static bool tchdbunlocktran(TCHDB *hdb){
-  assert(hdb);
-  if(pthread_mutex_unlock(hdb-&gt;tmtx) != 0){
-    tchdbsetecode(hdb, TCETHREAD, __FILE__, __LINE__, __func__);
-    return false;
-  }
-  TCTESTYIELD();
-  return true;
-}
-
-
 /* Lock the write ahead logging file of the hash database object.
    `hdb' specifies the hash database object.
    If successful, the return value is true, else, it is false. */</diff>
      <filename>tchdb.c</filename>
    </modified>
    <modified>
      <diff>@@ -1377,6 +1377,33 @@ static void *threadwicked(void *targ){
       break;
     default:
       if(id == 0) iputchar('@');
+      if(tchdbtranbegin(hdb)){
+        if(myrand(2) == 0){
+          if(!tchdbput(hdb, kbuf, ksiz, vbuf, vsiz)){
+            eprint(hdb, &quot;tchdbput&quot;);
+            err = true;
+          }
+        } else {
+          if(!tchdbout(hdb, kbuf, ksiz) &amp;&amp; tchdbecode(hdb) != TCENOREC){
+            eprint(hdb, &quot;tchdbout&quot;);
+            err = true;
+          }
+        }
+        if(nc &amp;&amp; myrand(2) == 0){
+          if(!tchdbtrancommit(hdb)){
+            eprint(hdb, &quot;tchdbtrancommit&quot;);
+            err = true;
+          }
+        } else {
+          if(!tchdbtranabort(hdb)){
+            eprint(hdb, &quot;tchdbtranabort&quot;);
+            err = true;
+          }
+        }
+      } else {
+        eprint(hdb, &quot;tchdbtranbegin&quot;);
+        err = true;
+      }
       if(myrand(1000) == 0){
         if(!tchdbforeach(hdb, iterfunc, NULL)){
           eprint(hdb, &quot;tchdbforeach&quot;);
@@ -1390,7 +1417,7 @@ static void *threadwicked(void *targ){
     if(id == 0){
       if(i % 50 == 0) iprintf(&quot; (%08d)\n&quot;, i);
       if(id == 0 &amp;&amp; i == rnum / 4){
-        if(!tchdboptimize(hdb, rnum / 50, -1, -1, -1)){
+        if(!tchdboptimize(hdb, rnum / 50, -1, -1, -1) &amp;&amp; tchdbecode(hdb) != TCEINVALID){
           eprint(hdb, &quot;tchdboptimize&quot;);
           err = true;
         }
@@ -1595,7 +1622,7 @@ static void *threadrace(void *targ){
       if(myrand(mid) == 0){
         iprintf(&quot;[o]&quot;);
         if(!tchdboptimize(hdb, myrand(rnum) + 1, myrand(10), myrand(10), 0)){
-          eprint(hdb, &quot;tchdbvanish&quot;);
+          eprint(hdb, &quot;tchdboptimize&quot;);
           err = true;
         }
       }</diff>
      <filename>tchmttest.c</filename>
    </modified>
    <modified>
      <diff>@@ -586,7 +586,7 @@ bool tctdbvanish(TCTDB *tdb){
 bool tctdbcopy(TCTDB *tdb, const char *path){
   assert(tdb &amp;&amp; path);
   if(!TDBLOCKMETHOD(tdb, false)) return false;
-  if(!tdb-&gt;open || !tdb-&gt;wmode || tdb-&gt;tran){
+  if(!tdb-&gt;open){
     tctdbsetecode(tdb, TCEINVALID, __FILE__, __LINE__, __func__);
     TDBUNLOCKMETHOD(tdb);
     return false;
@@ -601,16 +601,23 @@ bool tctdbcopy(TCTDB *tdb, const char *path){
 /* Begin the transaction of a table database object. */
 bool tctdbtranbegin(TCTDB *tdb){
   assert(tdb);
-  if(!TDBLOCKMETHOD(tdb, true)) return false;
-  if(!tdb-&gt;open || !tdb-&gt;wmode || tdb-&gt;tran){
-    tctdbsetecode(tdb, TCEINVALID, __FILE__, __LINE__, __func__);
+  for(double wsec = 1.0 / sysconf(_SC_CLK_TCK); true; wsec *= 2){
+    if(!TDBLOCKMETHOD(tdb, true)) return false;
+    if(!tdb-&gt;open || !tdb-&gt;wmode){
+      tctdbsetecode(tdb, TCEINVALID, __FILE__, __LINE__, __func__);
+      TDBUNLOCKMETHOD(tdb);
+      return false;
+    }
+    if(!tdb-&gt;tran) break;
     TDBUNLOCKMETHOD(tdb);
-    return false;
+    if(wsec &gt; 1.0) wsec = 1.0;
+    tcsleep(wsec);
   }
   if(!tctdbtranbeginimpl(tdb)){
     TDBUNLOCKMETHOD(tdb);
     return false;
   }
+  tdb-&gt;tran = true;
   TDBUNLOCKMETHOD(tdb);
   return true;
 }
@@ -625,12 +632,11 @@ bool tctdbtrancommit(TCTDB *tdb){
     TDBUNLOCKMETHOD(tdb);
     return false;
   }
-  if(!tctdbtrancommitimpl(tdb)){
-    TDBUNLOCKMETHOD(tdb);
-    return false;
-  }
+  tdb-&gt;tran = false;
+  bool err = false;
+  if(!tctdbtrancommitimpl(tdb)) err = true;
   TDBUNLOCKMETHOD(tdb);
-  return true;
+  return !err;
 }
 
 
@@ -643,12 +649,11 @@ bool tctdbtranabort(TCTDB *tdb){
     TDBUNLOCKMETHOD(tdb);
     return false;
   }
-  if(!tctdbtranabortimpl(tdb)){
-    TDBUNLOCKMETHOD(tdb);
-    return false;
-  }
+  tdb-&gt;tran = false;
+  bool err = false;
+  if(!tctdbtranabortimpl(tdb)) err = true;
   TDBUNLOCKMETHOD(tdb);
-  return true;
+  return !err;
 }
 
 
@@ -1060,7 +1065,7 @@ uint64_t tctdbbnumused(TCTDB *tdb){
 }
 
 
-/* Get the number of column indexes of a table database object. */
+/* Get the number of column indices of a table database object. */
 int tctdbinum(TCTDB *tdb){
   assert(tdb);
   if(!tdb-&gt;open){
@@ -1729,7 +1734,6 @@ static bool tctdbtranbeginimpl(TCTDB *tdb){
       break;
     }
   }
-  tdb-&gt;tran = true;
   return !err;
 }
 
@@ -1756,7 +1760,6 @@ static bool tctdbtrancommitimpl(TCTDB *tdb){
       break;
     }
   }
-  tdb-&gt;tran = false;
   return !err;
 }
 
@@ -1782,7 +1785,6 @@ static bool tctdbtranabortimpl(TCTDB *tdb){
       break;
     }
   }
-  tdb-&gt;tran = false;
   return !err;
 }
 
@@ -2830,7 +2832,7 @@ static bool tctdbqryallcondmatch(TDBQRY *qry, const char *pkbuf, int pksiz){
           break;
         }
       } else {
-        if(!cond-&gt;sign){
+        if(cond-&gt;sign){
           ok = false;
           break;
         }
@@ -3174,7 +3176,7 @@ static int tdbcmpsortkeynumdesc(const TDBSORTKEY *a, const TDBSORTKEY *b){
 }
 
 
-/* Add a record into indexes of a table database object.
+/* Add a record into indices of a table database object.
    `tdb' specifies the table database object.
    `pkbuf' specifies the pointer to the region of the primary key.
    `pksiz' specifies the size of the region of the primary key.
@@ -3222,7 +3224,7 @@ static bool tctdbidxput(TCTDB *tdb, const void *pkbuf, int pksiz, TCMAP *cols){
 }
 
 
-/* Remove a record from indexes of a table database object.
+/* Remove a record from indices of a table database object.
    `tdb' specifies the table database object.
    `pkbuf' specifies the pointer to the region of the primary key.
    `pksiz' specifies the size of the region of the primary key.</diff>
      <filename>tctdb.c</filename>
    </modified>
    <modified>
      <diff>@@ -58,8 +58,8 @@ typedef struct {                         /* type of structure for a table databa
   uint8_t opts;                          /* options */
   int32_t lcnum;                         /* max number of cached leaves */
   int32_t ncnum;                         /* max number of cached nodes */
-  TDBIDX *idxs;                          /* column indexes */
-  int inum;                              /* number of column indexes */
+  TDBIDX *idxs;                          /* column indices */
+  int inum;                              /* number of column indices */
   bool tran;                             /* whether in the transaction */
 } TCTDB;
 
@@ -229,7 +229,7 @@ bool tctdbtune(TCTDB *tdb, int64_t bnum, int8_t apow, int8_t fpow, uint8_t opts)
    the default value is specified.  The default value is 512.
    If successful, the return value is true, else, it is false.
    Note that the caching parameters should be set before the database is opened.  Leaf nodes and
-   non-leaf nodes are used in column indexes. */
+   non-leaf nodes are used in column indices. */
 bool tctdbsetcache(TCTDB *tdb, int32_t rcnum, int32_t lcnum, int32_t ncnum);
 
 
@@ -616,7 +616,7 @@ uint64_t tctdbfsiz(TCTDB *tdb);
    removed.  If `TDBITKEEP' is added by bitwise-or and the index exists, this function merely
    returns failure.
    If successful, the return value is true, else, it is false.
-   Note that the setting indexes should be set after the database is opened. */
+   Note that the setting indices should be set after the database is opened. */
 bool tctdbsetindex(TCTDB *tdb, const char *name, int type);
 
 
@@ -811,9 +811,9 @@ char *tctdbopaque(TCTDB *tdb);
 uint64_t tctdbbnumused(TCTDB *tdb);
 
 
-/* Get the number of column indexes of a table database object.
+/* Get the number of column indices of a table database object.
    `tdb' specifies the table database object.
-   The return value is the number of column indexes or 0 if the object does not connect to any
+   The return value is the number of column indices or 0 if the object does not connect to any
    database file. */
 int tctdbinum(TCTDB *tdb);
 </diff>
      <filename>tctdb.h</filename>
    </modified>
    <modified>
      <diff>@@ -1289,6 +1289,33 @@ static void *threadwicked(void *targ){
       break;
     default:
       if(id == 0) iputchar('@');
+      if(tctdbtranbegin(tdb)){
+        if(myrand(2) == 0){
+          if(!tctdbput(tdb, pkbuf, pksiz, cols)){
+            eprint(tdb, &quot;tctdbput&quot;);
+            err = true;
+          }
+        } else {
+          if(!tctdbout(tdb, pkbuf, pksiz) &amp;&amp; tctdbecode(tdb) != TCENOREC){
+            eprint(tdb, &quot;tctdbout&quot;);
+            err = true;
+          }
+        }
+        if(myrand(2) == 0){
+          if(!tctdbtrancommit(tdb)){
+            eprint(tdb, &quot;tctdbtrancommit&quot;);
+            err = true;
+          }
+        } else {
+          if(!tctdbtranabort(tdb)){
+            eprint(tdb, &quot;tctdbtranabort&quot;);
+            err = true;
+          }
+        }
+      } else {
+        eprint(tdb, &quot;tctdbtranbegin&quot;);
+        err = true;
+      }
       if(myrand(10000) == 0) srand((unsigned int)(tctime() * 1000) % UINT_MAX);
       break;
     }
@@ -1296,7 +1323,7 @@ static void *threadwicked(void *targ){
     if(id == 0){
       if(i % 50 == 0) iprintf(&quot; (%08d)\n&quot;, i);
       if(id == 0 &amp;&amp; i == rnum / 4){
-        if(!tctdboptimize(tdb, rnum / 50, -1, -1, -1)){
+        if(!tctdboptimize(tdb, rnum / 50, -1, -1, -1) &amp;&amp; tctdbecode(tdb) != TCEINVALID){
           eprint(tdb, &quot;tctdboptimize&quot;);
           err = true;
         }</diff>
      <filename>tctmttest.c</filename>
    </modified>
    <modified>
      <diff>@@ -5758,6 +5758,23 @@ void *tcstrjoin4(const TCMAP *map, int *sp){
 }
 
 
+/* Suspend execution of the current thread. */
+bool tcsleep(double sec){
+  if(!isnormal(sec) || sec &lt;= 0.0) return false;
+  if(sec &lt;= 1.0 / sysconf(_SC_CLK_TCK)) return sched_yield() == 0;
+  double integ, fract;
+  fract = modf(sec, &amp;integ);
+  struct timespec req, rem;
+  req.tv_sec = integ;
+  req.tv_nsec = tclmin(fract * 1000.0 * 1000.0 * 1000.0, 999999999);
+  while(nanosleep(&amp;req, &amp;rem) != 0){
+    if(errno != EINTR) return false;
+    req = rem;
+  }
+  return true;
+}
+
+
 
 /*************************************************************************************************
  * filesystem utilities</diff>
      <filename>tcutil.c</filename>
    </modified>
    <modified>
      <diff>@@ -2596,6 +2596,12 @@ char *tcstrjoin3(const TCMAP *map, char delim);
 void *tcstrjoin4(const TCMAP *map, int *sp);
 
 
+/* Suspend execution of the current thread.
+   `sec' specifies the interval of the suspension in seconds.
+   If successful, the return value is true, else, it is false. */
+bool tcsleep(double sec);
+
+
 
 /*************************************************************************************************
  * filesystem utilities
@@ -3290,8 +3296,8 @@ typedef struct {                         /* type of structure for a bit stream o
 
 #include &lt;stdio.h&gt;
 
-#define _TC_VERSION    &quot;1.4.14&quot;
-#define _TC_LIBVER     805
+#define _TC_VERSION    &quot;1.4.15&quot;
+#define _TC_LIBVER     806
 #define _TC_FORMATVER  &quot;1.0&quot;
 
 enum {                                   /* enumeration for error codes */</diff>
      <filename>tcutil.h</filename>
    </modified>
    <modified>
      <diff>@@ -19,13 +19,13 @@
  */
 module TokyoCabinet {
   //----------------------------------------------------------------
-  // list of strings (substituted for by the native mechanism).
+  // list of strings (substituted for by the native mechanism)
   //----------------------------------------------------------------
   interface List {
     string get(in long index);
   };
   //----------------------------------------------------------------
-  // map of strings (substituted for by the native mechanism).
+  // map of strings (substituted for by the native mechanism)
   //----------------------------------------------------------------
   interface Map {
     string get(in string key);
@@ -307,6 +307,7 @@ module TokyoCabinet {
     long addint(in string key, in long num);
     double adddouble(in string key, in double num);
     boolean sync();
+    boolean optimize(in string params);
     boolean vanish();
     boolean copy(in string path);
     boolean tranbegin();</diff>
      <filename>tokyocabinet.idl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8a6686129b4d6a188e8762354035ca85c0d27775</id>
    </parent>
  </parents>
  <author>
    <name>Bob Ippolito</name>
    <email>bob@redivi.com</email>
  </author>
  <url>http://github.com/etrepum/tokyo-cabinet/commit/6f562ea49ea5050bf435b0cb38fbf9ed41e11136</url>
  <id>6f562ea49ea5050bf435b0cb38fbf9ed41e11136</id>
  <committed-date>2009-04-19T11:07:34-07:00</committed-date>
  <authored-date>2009-04-19T11:07:34-07:00</authored-date>
  <message>sync with tokyotyrant-1.4.15.tar.gz</message>
  <tree>5580f2ab6a07b70a25fe51bfff455fa8d06aa173</tree>
  <committer>
    <name>Bob Ippolito</name>
    <email>bob@redivi.com</email>
  </committer>
</commit>
