Database configuration objects
QDB databases are managed with configuration objects, each of which configures one database. The configuration objects are text files that specify the paths to the database schema and storage files as well as policy settings such as backups.
The files are named after the databases that they configure.
For example, suppose you have two media content databases named hdd and cdrom.
You would then create two configuration objects named hdd and cdrom.
For an overview of all database-related files, see Summary of database files
.
By using a separate SQLite storage file for each database, QDB allows you to dynamically load and unload individual databases so you can keep in memory only the data needed for the active client application.
on-the-flyconfiguration changes after a database is loaded. To modify the configuration, you must unload the database, update its configuration object, and reload the database. You must also ensure that the changes are compatible with the previous configuration.
Configuration object contents
The database configuration object gets parsed by QDB to set up the database.
Lines specifying parameters are in the form key::value.
Unknown parameter types are ignored and so they can be made into comments, but you must still use the ::
delimiter on the comment line. For example, you can enter MyComment:: on a line and QDB will treat it as
an unsupported parameter and ignore that line.
For an example of a database configuration, see Sample configuration object
.
- Filename
- The name of the database storage file, which is the raw SQLite file. It must have an absolute path but it can refer to any file location. At database loading time, either this file or its parent directory must exist; otherwise, the loading attempt fails and QDB sets the status to Error. If the database file doesn't exist but its parent directory does, the file is restored from the newest valid backup (if possible) or a blank database file is created.
- AutoAttach
- A comma-separated list of other databases to attach to the current one (using the SQL ATTACH DATABASE statement) whenever a database connection is established.
- BackupAttached, SizeAttached, VacuumAttached
- These entries control what maintenance operations should apply to attached databases when a command is issued to the main database. Each parameter lists the attached databases affected by the operation.
- BackupDir
- A comma-separated list of directories that store database backups. When you specify multiple directories, they're used in rotation to store the backup files. This feature ensures that should a backup be interrupted or aborted by a power failure, another older backup is still available.
- BackupVia
- An interim directory that the database is copied into as part of the backup. To ensure the backup is consistent, QDB puts a read lock on the database while copying and compressing it, so the database may be locked a long time if the destination is slow (e.g., flash).
- ClientSchemaFile
- The name of the file (with an absolute path) that contains the SQL commands to execute every time a client calls qdb_connect().
- Collation, Function
- These entries install user-provided collation (sorting) routines and scalar/aggregate functions. The argument format is a comma-separated list of library symbols in the form tag@library.so, where tag is the symbol name of the function description structure and library.so is the name of the shared library containing the code.
- Compression
- The compression algorithm to apply to backups. The supported options are:
- none (for no compression, which is the default)
- lzo (for LZO compression)
- bzip (for BZIP2 compression)
- diocopy (for direct I/O copy)
- CompressionVia
- This entry is used with the BackupVia entry and any Compression setting specified for the backup. By default, the BackupVia feature first makes a raw/uncompressed copy of the database in the temporary directory and then performs the compression. This works if you have enough space and it read-locks the database for the least amount of time, but you can use less space (at the expense of more time) by compressing during the copy. This option is false by default; if you set it to true, the compression is done in the first step.
- DataSchemaFile
- The name of the file (with an absolute path) that creates the initial data in the database. This text file contains the SQL commands to populate the database when it is created.
- SchemaFile
- The name of the file (with an absolute path) that contains the SQL commands to create the initial schema of tables, indexes, and views for the database. The schema file is used only to set up the database if it didn't already exist.
Sample configuration object
Filename::/root/tmp/cdrom0_db
SchemaFile::/etc/mm/sql/mmsync.sql
DataSchemaFile::/etc/mm/sql/mmsync_data.sql
You would give the configuration object the same name as the database storage file (cdrom0_db).
