1.4. Multiple Database Tables
Interchange can manage an unlimited number of arbitrary database tables. They use the TAB delimiter by default, but several flexible delimiter schemes are available. These are defined by default:
Type 1 DEFAULT - uses default TAB delimiter Type 2 LINE Each field on its own line, a blank line separates the record. Watch those carriage returns! Also has a special format when CONTINUE is set to be NOTES. Type 3 %% Fields separated by a \n%%\n combination, records by \n%%%\n (where \n is a newline). Watch those carriage returns! Type 4 CSV Type 5 PIPE Type 6 TAB Type 7 reserved Type 8 SQL Type 9 LDAP
The databases are specified in Database directives, as:
Database arbitrary arbitrary.csv CSV
This specifies a Type 4 database, the ASCII version of which is located in the file arbitrary.csv, and the identifier it will be accessed under in Interchange is "arbitrary." The DBM file, if any, will be created in the same directory if the ASCII file is newer, or if the DBM file does not exist. The files will be created as arbitrary.db or arbitrary.gdbm, depending on DBM type.
The identifier is case sensitive, and can only contain characters in the class [A-Za-z0-9_]. Fields are accessed with the [item_data identifier field] or [data identifier field key] elements. NOTE: Use of lower-case letters is strongly recommended.
If one of the first six types is specified, the database will automatically be built in the default Interchange DB style. The type can be specified with DB_FILE, GDBM, or MEMORY, if the type varies from that default. They will coexist with an unlimited number of DBI databases of different types.
In addition to the database, the session files will be kept in the default format, and are affected by the following actions.
The order of preference is:
GDBM
-
This uses the Perl GDBM_File module to build a GDBM database. The following command will indicate if GDBM is in Perl:
perl -e 'require GDBM_File and print "I have GDBM.\n"'
-
Installing GDBM_File requires rebuilding Perl after obtaining the GNU GDBM package, and is beyond the scope of this document. LINUX will typically have this by default; most other operating systems will need to specifically build in this capability.
DB_File (Berkeley DB)
-
This uses the DB_File module to build a Berkeley DB (hash) database. The following command will indicate if DB_File is in Perl:
perl -e 'require DB_File and print "I have Berkeley DB.\n"'
-
Installing DB_File requires rebuilding Perl after obtaining the Berkeley DB package, and is beyond the scope of this document. BSDI, FreeBSD, and LINUX will typically have it by default; most other operating systems will need to specifically build this in.
If using DB_File, even though GDBM_File is in Perl, set the environment variable MINIVEND_DBFILE to a true (non-zero, non-blank) value:
# csh or tcsh setenv MINIVEND_DBFILE 1 # sh, bash, or ksh MINIVEND_DBFILE=1 ; export MINIVEND_DBFILE
-
Then, re-start the server.
Or, to set a particular table to use Berkeley DB, the DB_FILE class in catalog.cfg can be specified:
Database arbitrary DB_FILE 1
In-memory
-
This uses Perl hashes to store the data directly in memory. Every time the Interchange server is restarted, it will re-import all in-memory databases for every catalog.
If this is used, despite the presence of GDBM_File or DB_File, set the environment variable MINIVEND_NODBM as above or specify the memory type in the Database directive:
Database arbitrary MEMORY 1
Note: The use of memory databases is not recommended.