 |
 |
|
 |
solidDB for MySQL 5.0
Solid Information Technology, Ltd.
Copyright © Solid Information Technology
Ltd 1993-2006. All rights reserved.
This documentation is not
distributed under a GPL license.
This documentation is for the
solidmysql-5.0.27-0064 release.
|
1. solidDB for MySQL 5.0 User Guide
1.1. solidDB for MySQL Overview
solidDB for MySQL is a turbo-charged version of MySQL database
that leverages solidDB Storage Engine to support heavy transaction
volumes and large numbers of concurrent users. It is a complete
relational database management system (RDBMS) that combines
MySQL Server, solidDB Storage Engine and MyISAM storage engine.
solidDB for MySQL is based on Solid's proven
transactional product Solid
EmbeddedEngine™,
which is a fully-featured
relational database that is being used in products from
companies including HP, Siemens, Nortel and NEC. solidDB for MySQL will supports
mission critical applications that require a high level
of reliability and large transaction volumes. solidDB for MySQL
is licensed under GNU GPL.
solidDB Storage Engine for MySQL leverages solidDB Storage Engine, which is a multi-threaded, transactional storage
engine for MySQL Server. It is designed for mission-critical
implementations that require a robust, transactional database
able to fully leverage multi-processor environments to support
heavy transaction volumes and a large number of concurrent
users. solidDB Storage Engine for MySQL supports full ACID
compliance with configurable transaction isolation
levels, both optimistic and pessimistic concurrency
control, Multi-Version Concurrency Control (MVCC)
with non-blocking reads and writes, row-level locking,
and support for foreign keys and referential integrity.
1.2. Solid Contact Information
Contact information for Solid:
Web site: http://www.solidtech.com
Sales inquiries:
<sales@solidtech.com>
Technical support:
<techsupp@solidtech.com>
Marketing:
<solidwebex@solidtech.com>
Offices
Americas
Asia Pacific
EMEA
Americas
Solid World Headquarters
20400 Stevens Creek Blvd, Suite 200
Cupertino
CA
95014
USA
+1 408 4544700
+1 408 4544900
Asia Pacific
Solid APAC Headquarters
Solid K.K.
43rd Floor
The Landmark Tower Yokohama
2-2-1 Minatomirai, Nishi-ku
Yokohama
220-8143
Japan
+81 45 2242525
+81 45 2242535
EMEA
Solid EMEA Headquarters
Italahdenkatu 22 B
FIN-00210
Helsinki
Finland
+358 42488881
+358 9 2782877
1.3. Installing solidDB for MySQL
This chapter covers solidDB for MySQL installation for
both the Windows and
Linux platforms.
1.3.1. Installing solidDB for MySQL on a Windows Platform
solidDB for MySQL is delivered as a .zip
package without a
Windows Installer. To install,
unzip the package to a directory of your choice. To start the server, either double click
the mysqld.exe in the
bin folder or start it from the
command line as shown here:
C:>
cd <WHERE-YOU-INSTALLED>
C:>
bin\mysqld
Use your favorite SQL tool to connect
to the database. You can also use mysql.exe
and mysqladmin.exe in the
bin folder, but these applications
must be run from the command line.
1.3.2. Installing solidDB for MySQL on a Linux Platform
solidDB for MySQL is delivered as a tar.gz
package. Extract the package under a non-root user's home
directory or to a directory of your choice. The commands are:
shell>
tar zxvf solidmysql-5.0.27-linux-i686-VERSION.tar.gz
shell>
cd solidmysql-5.0.27-linux-i686-VERSION
shell>
bin/mysqld_safe --default-storage-engine=solidDB &
You can create a solidDB database (solid.db)
in the data/ directory as shown here:
shell>
cd bin
shell>
./mysql -u root
shell>
create database solid;
shell>
use solid;
Note
If you want to run mysqld
as root, you must supply --user=<username>
to mysql_install_db and
mysqld_safe. In this case, the server
is started as that user's process. If you are root and try to do
this without the --user option,
the server will fail to start.
1.4. Compiling from Source Distribution
This chapter explains how to compile solidDB for MySQL
from source for both the Windows and
Linux platforms.
1.4.1. Source Compilation in Windows
The basic steps that you must execute to install a solidDB for MySQL
source distribution in Windows are:
You must have the Visual C++ .NET 2003
compiler installed.
Unzip the source distribution.
Start Microsoft Visual Studio.
Open a solution mysql through
from the
MySQL root directory.
Click the Solution explorer
at the upper left corner. At the bottom,
you can see the Active config
field. You can use this field to choose between
Release and Debug.
In the Solution explorer
window, find mysqld
and right click it. Choose the build that rebuilds the
mysqld executable.
The new mysqld executable will be stored in the
client_release directory with name
mysqld.exe (Release) or
client_debug directory with name
mysqld-debug.exe (Debug).
You can use the executables in the same way as in
Linux. To see output on the
command prompt screen, start the executables with the
--console option.
1.4.2. Source Compilation in Linux
The commands that you must give to install a solidDB for MySQL
source distribution in Linux are:
shell>
groupadd mysql
shell>
useradd -g mysql mysql
shell>
gunzip < solidmysql-VERSION.tar.gz | tar -xvf -
shell>
cd solidmysql-VERSION
shell>
./BUILD/compile-pentium-soliddb --prefix=/usr/local/mysql
shell>
make install
shell>
cp support-files/my-medium.cnf /etc/my.cnf
shell>
cd /usr/local/mysql
shell>
bin/mysql_install_db --user=mysql --no-defaults --datadir=/usr/local/mysql/var
shell>
chown -R root .
shell>
chown -R mysql var
shell>
chgrp -R mysql .
shell>
cp support-files/my-soliddb.cnf /etc/my.cnf
1.5. solidDB for MySQL Configuration
The solidDB Storage Engine for MySQL is enabled by default. If you do not want to
use solidDB tables, you can add the skip-soliddb
option to your MySQL option file.
This section contains representative examples of solidDB configuration
parameters. Refer to Section 1.7, "solidDB for MySQL Startup Options and System Variables"
for additional information about solidDB-related
configuration parameters.
To set up the solidDB database files, use the
soliddb_filespec option
in the [mysqld] section
of the my.cnf option file.
On Windows,
you can use the my.ini file
instead. The value of soliddb_filespec
should be a list of one or more database file
specifications. If you name more than
one data file, separate them by comma
(",") characters:
soliddb_filespec=database_file[,database_file2]...
For example,
[mysqld]
soliddb_filespec=soliddb1 10M
This setting configures a single 10MB database file
named soliddb1. No
location for the database file is given.
By default, solidDB creates it in the MySQL
data directory. The full syntax for a database file
specification includes the filename and the file-size:
file_name file_size
solidDB creates tablespace files in the
MySQL data directory by
default. To specify a location explicitly, use the
soliddb_filespec option with a path. For example,
to use two files named soliddb1 and
soliddb2 but create them in the
/soliddb directory, configure
solidDB like this:
[mysqld]
soliddb_filespec=/soliddb/soliddb1 10M,/soliddb/soliddb2 20M
For more information on file management, see
Section 1.26, "solidDB File Space Management and Disk I/O".
If you want to tune other mysqld and
solidDB parameters, the following values are typical and
would suit most users:
[mysqld]
skip-external-locking
max_connections=1024
read_buffer_size=1M
sort_buffer_size=1M
#
# Set key_buffer to 5 - 50% of your RAM depending on how much
# you use MyISAM tables, but keep key_buffer_size + solidDB
# cache size < 80% of your RAM
key_buffer_size=value
#
# Set the cache size to 70-80% of your ram
#
#
soliddb_cache_size=value
#
# Set durability to strict
#
set-variable = soliddb_durability_level=3
character-set-server=latin1
collation-server=latin1_general_cs
[client]
default-character-set=latin1
1.6. Starting the Server and Activating solidDB for MySQL
This chapter explains basic tasks needed to start
solidDB for MySQL.
1.6.1. Starting the Server
If you use Windows,
start the solidDB for MySQL server by double clicking
mysqld.exe. Alternatively,
you can run it from the command line. This starts the
solidDB for MySQL server containing solidDB for MySQL.
If you use Linux,
start the solidDB for MySQL server by
using mysqld_safe.
mysqld_safe is a utility
that starts solidDB for MySQL after
scanning for the needed files and directories (such as
the data directory) below the current working
directory. In other words, if you have installed
solidDB for MySQL under your home directory,
mysqld_safe will
find it when your current working directory
is your home directory. The command syntax
is as follows:
mysqld_safe --mysqld=<mysql-server-name> --default-storage-engine=solidDB
Go to your solidDB for MySQL
installation data directory and issue, for example,
the following command:
mysqld_safe --mysqld=mysqld --default-storage-engine=solidDB
That command starts the solidDB for MySQL server containing
solidDB Storage Engine for MySQL.
When started, solidDB for MySQL creates, if necessary,
the solidDB database file, transaction log files,
and the solidDB
message output file to the solidDB for MySQL data directory.
The default solidDB filenames are:
solid.db for the database file.
sol#####.log for transaction logs.
Files start from sol00001.log.
solmsg.out for message output.
solerror.out for errors occurring
during the startup of solidDB Storage Engine for MySQL.
The names and locations of these files are defined in the
solidDB for MySQL configuration file,
and can be changed according to your specific requirements.
1.6.2. Opening the MySQL Query ToolNote
These instructions are for the command-line query tool, not
for MySQL Query Browser.
You can start the query tool from the
Windows
menu or from the Linux
prompt as follows:
When started from the Windows
menu, the query tool is set to use the "root" user.
At the password prompt, press RETURN.
When starting from the prompt in
Linux, use command:
shell> mysql -u root
1.6.3. Creating a Database
You can create a new database by entering commands as follows:
mysql> create database dba;
Query OK, 1 row affected (0.14 sec)
mysql> use dba;
Database changed
You are now ready to use the database.
1.6.4. Shutting Down the Database
You can shut down the database with the MySQL
mysqladmin utility
by entering a command as follows:
shell> mysqladmin -u root shutdown
This command will shut down solidDB for MySQL.
solidDB for MySQL will first perform a checkpoint, close
the files it is using, and then stop running.
1.7. solidDB for MySQL Startup Options and System Variables
This section describes the command-line
options and system variables for solidDB for MySQL.
System variables have two possible states: they are either true or false.
System variables can be enabled at server startup by naming them, or
disabled by using a skip- prefix. For example,
to enable or disable deleting solidDB transaction log files
after each successful checkpoint, you can use
--soliddb_checkpoint_deletelog or
--skip-soliddb_checkpoint_deletelog
on the command line, or soliddb_checkpoint_deletelog or
skip-soliddb_checkpoint_deleletelog in an option file.
System variables that take a numeric value can be specified as
--var_name=value on the command line or as
var_name=value in option files.
1.7.1. solidDB for MySQL Command Options
soliddb
This command option enables solidDB Storage Engine for MySQL,
if the server was compiled with solidDB support.
Use skip-soliddb to disable
solidDB.
soliddb_checkpoint_deletelog
If this command option is set, the server deletes the
transaction log file(s) after each successful checkpoint.
This saves disk space, but makes it impossible to recover
data by rolling forward the logs. The transaction logs
contain a copy of the transactions executed by the server.
If the database file is erased or corrupted, and if you have
kept the transaction log files, you can restore the data
by restoring the backup database file and then rolling forward
all the transaction logs that accumulated since the last
backup. If you have deleted those transaction logs, you will
lose all transactions since the last successful backup.
1.7.2. solidDB for MySQL System Variables
soliddb_backup_block_size
This variable sets the backup copy block size.
soliddb_backupdir
This variable sets the backup copy directory.
soliddb_cache_size
This variable sets the server's database cache memory size
in bytes; the minimum size is 512 kilobytes. Although
solidDB for MySQL is able to run with a small cache size,
a larger cache size speeds up the server. The cache size needed
depends on the database file-size, the number of connected users,
and the nature of the operations executed against the server.
Warning
Setting the cache size to a value larger than the amount of
memory available may significantly degrade performance. If
your system only has a small amount of free memory available,
reduce the cache size.
soliddb_filespec=database_file1 size[,database_file2 size2 ...]
This variable defines the location and the maximum size
of the index file. Note that in solidDB,
the term "index file" is used as a
synonym for "database file".
The parameter accepts the following two arguments:
database filename followed with maximum size of the database
file, for example:
soliddb_filespec=c:\soldb\solid.db 20M
Note
You cannot use space " "
or comma ","
characters on your path and filenames.
For more information on adding more database files
while the server is running, see
Section 1.26, "solidDB File Space Management and Disk I/O".
soliddb_durability_level
This parameter controls whether the transaction durability
level is "strict" or "relaxed".
If durability is "strict",
writes to the transaction log are synchronous. As soon as a
transaction has been committed, the transaction is written
to the transaction log. If durability is "relaxed", writes
are asynchronous, which means that there can be a delay
between the time that the transaction is committed and the
time that it is logged. For more information on the effect
of this parameter see Section 1.14, "Transaction Durability".
The possible values are:
1, relaxed durability
3, strict durability
Value 2, adaptive durability is not supported with solidDB for MySQL.
Adaptive durability is a configuration setting for
solidDB Storage Engine that can only be used in Solid
EmbeddedEngine™ and BoostEngine™ products.
If you specify an unsupported value, the default value 3 is used.
soliddb_logdir
To ensure the durability of committed transactions,
transaction results are written immediately to a file
in a specified directory when the transaction is
committed. This file must be stored to a local drive
using local disk names to avoid problems with network
input/output (I/O) and to achieve
better performance. The default log file directory is the MySQL
data directory. The soliddb_logdir
parameter defines a path for
the transaction log files. For example, the following setting:
soliddb_logdir = d:\logdir\
instructs solidDB for MySQL to create log files to
directory d:\logdir and names them
sequentially starting from sol00001.log.
Tip
Placing log files on a physical disk separate from
the database files improves performance.
soliddb_lock_wait_timeout
The timeout in seconds a solidDB transaction waits
for a lock before being rolled back. solidDB automatically
detects transaction deadlocks in its own lock table and
rolls back the transaction. The default value is 50 seconds.
soliddb_log_block_size
This variable sets the log block size.
soliddb_db_block_size
This variable sets the database file block size.
Note
The block size has only effect when the database is
created. If you change the block size after you
have created the first database, the change will
not have effect on the new databases you create,
but the same value is used for all database files.
If the given block size value differs from the original
soliddb_db_block_size size,
the soliddb_db_block_size is
used and a warning is displayed.
soliddb_io_threads
This variable sets the number of helper I/O threads
(for each I/O device) for read and write. You
can restrict the number of write threads with the
soliddb_write_threads parameter.
soliddb_filewrite_flushmode
This variable sets the flush mode after write or read operations.
The possible values are:
soliddb_filewrite_flushmode=0 indicates
no flushing after write or read operations. This is the
default setting on most platforms.
soliddb_filewrite_flushmode=1 indicates
flush before reading from the file.
soliddb_filewrite_flushmode=2 indicates
flush after write operations.
soliddb_checkpoint_time
This variable specifies the minimum time in seconds
between two checkpoint operations.
soliddb_write_threads
This parameter sets the number of helper threads dedicated
to a writing task (for each I/O device). You must define
soliddb_io_threads for this
parameter to take effect.
soliddb_pessimistic
When you specify PESSIMISTIC
concurrency control, the server places locks on rows to control
the level of consistency and concurrency when users are submitting
queries or updates to the database table rows. The default value
is false, that is, the server uses optimistic concurrency control.
However, by setting this parameter to true, you can instruct the
server to default to pessimistic locking.
Setting concurrency control to PESSIMISTIC
only affects tables created after the setting change. You
cannot change the concurrency control behavior for an
existing table.
For more information, see Section 1.19, "Concurrency Control"
soliddb_log_enabled
This variable specifies whether transaction logging is
enabled. If transaction logging is disabled, you
will get better performance but lower transaction durability.
This means that if the database engine shuts down unexpectedly,
you will lose all transactions since the last checkpoint.
Transaction logging is enabled by default.
soliddb_readahead
This variable sets the number of prefetched index reads
during long sequential searches. Note that when the I/O
manager is handling a long sequential search, it enters
a read-ahead operation mode. This mode ensures that the
next file blocks of the search are read into
the cache in advance. This naturally improves the overall
performance of sequential searches.
soliddb_checkpoint_interval
This variable sets the number of writes to the log files
that cause automatic checkpoint creation. A large setting
can delay checkpoints and make then larger. A small
setting will guarantee a small checkpoint size.
soliddb_extend_increment
This variable sets the number of disk space blocks that
are allocated at a time when solidDB allocates
more space for the database file.
soliddb_lockhash_size
The server uses a hash table (array) to store lock information.
If the array size is remarkably underestimated, the server
performance degrades. A too large hash table does not affect
directly to the performance, although it causes memory overhead.
1.8. solidDB Data Dictionary
Data dictionary is a file that defines the basic organization of a
database. A data dictionary contains a list of all files in the
database, the number of records in each file, and the names and
types of each field.
1.8.1. solidDB Data Dictionary Installation
solidDB data dictionary can be installed to any database. Data
dictionary is only visible to the installed database, or to any other
database if you use a database prefix on all SQL clauses accessing the
data dictionary.
For example, you can install solidDB data dictionary to database soliddb
by issuing the following commands in the MySQL client interface:
shell> mysqladmin create soliddb -u root
shell> mysql soliddb -u root <
path_to_install_directory/scripts/soliddb_system_tables.sql
1.8.2. Accessing solidDB Data Dictionary
solidDB data dictionary stores server information. Your ability to
access specific system tables depends on your user access rights. For
example, Database Administrators (DBA) can view all information on
the data dictionary. solidDB data dictionary contains the
following tables:
For example, if you have created a solidDB table
t01 using MySQL client as follows:
mysql> use test;
Database changed
mysql> create table t01(a int not null, primary key(a)) engine=soliddb;
Query OK, 0 rows affected (0.73 sec)
Assuming that you have installed solidDB data dictionary to database
soliddb, you can see a description of all solidDB
tables by issuing the following command in the MySQL client interface:
mysql> select * from soliddb.SOLIDDB_SYS_TABLES;
+-------+-------------------------+------------+--------------+
| ID | TABLE_NAME | TABLE_TYPE | TABLE_SCHEMA |
+-------+-------------------------+------------+--------------+
| 100 | SYS_TABLES | BASE TABLE | _SYSTEM |
| 200 | SYS_COLUMNS | BASE TABLE | _SYSTEM |
| 400 | SYS_UROLE | BASE TABLE | _SYSTEM |
| 500 | SYS_RELAUTH | BASE TABLE | _SYSTEM |
| 600 | SYS_ATTAUTH | BASE TABLE | _SYSTEM |
| 700 | SYS_VIEWS | BASE TABLE | _SYSTEM |
| 800 | SYS_KEYPARTS | BASE TABLE | _SYSTEM |
| 900 | SYS_KEYS | BASE TABLE | _SYSTEM |
| 1000 | SYS_CARDINAL | BASE TABLE | _SYSTEM |
| 1100 | SYS_INFO | BASE TABLE | _SYSTEM |
| 1300 | SYS_SYNONYM | BASE TABLE | _SYSTEM |
| 8000 | SYS_USERS | BASE TABLE | _SYSTEM |
| 8002 | SQL_LANGUAGES | BASE TABLE | _SYSTEM |
| 8004 | SYS_TYPES | BASE TABLE | _SYSTEM |
| 8006 | SYS_BLOBS | BASE TABLE | _SYSTEM |
| 8010 | SYS_FORKEYS | BASE TABLE | _SYSTEM |
| 8013 | SYS_FORKEYPARTS | BASE TABLE | _SYSTEM |
| 8015 | SYS_CHECKSTRINGS | BASE TABLE | _SYSTEM |
| 8017 | SYS_PROCEDURES | BASE TABLE | _SYSTEM |
| 8020 | SYS_TRIGGERS | BASE TABLE | _SYSTEM |
| 8024 | SYS_TABLEMODES | BASE TABLE | _SYSTEM |
| 8026 | SYS_EVENTS | BASE TABLE | _SYSTEM |
| 8029 | SYS_CATALOGS | BASE TABLE | _SYSTEM |
| 8032 | SYS_SCHEMAS | BASE TABLE | _SYSTEM |
| 8035 | SYS_SEQUENCES | BASE TABLE | _SYSTEM |
| 8038 | SYS_PROPERTIES | BASE TABLE | _SYSTEM |
| 8040 | SYS_HOTSTANDBY | BASE TABLE | _SYSTEM |
| 8043 | SYS_COLUMNS_AUX | BASE TABLE | _SYSTEM |
| 10000 | SOLIDDB_SYS_TABLES | BASE TABLE | soliddb |
| 10002 | SOLIDDB_SYS_COLUMNS | BASE TABLE | soliddb |
| 10004 | SOLIDDB_SYS_KEYS | BASE TABLE | soliddb |
| 10006 | SOLIDDB_SYS_KEYPARTS | BASE TABLE | soliddb |
| 10008 | SOLIDDB_SYS_FORKEYS | BASE TABLE | soliddb |
| 10010 | SOLIDDB_SYS_FORKEYPARTS | BASE TABLE | soliddb |
| 10012 | SOLIDDB_SYS_SCHEMAS | BASE TABLE | soliddb |
| 10014 | SOLIDDB_SYS_SEQUENCES | BASE TABLE | soliddb |
| 10017 | SOLIDDB_SYS_BLOBS | BASE TABLE | soliddb |
| 10019 | SOLIDDB_SYS_CARDINAL | BASE TABLE | soliddb |
| 10021 | SOLIDDB_SYS_INFO | BASE TABLE | soliddb |
| 10023 | SOLIDDB_SYS_TABLEMODES | BASE TABLE | soliddb |
| 10025 | SOLIDDB_ADMIN_COMMANDS | BASE TABLE | soliddb |
+-------+-------------------------+------------+--------------+
44 rows in set (0.02 sec)
Note
All tables beginning with SYS_ or
SQL_ are solidDB internal tables
and cannot be accessed from the MySQL client.
1.8.3. solidDB Data Dictionary Contents
This chapter explains the contents of the solidDB system tables.
1.8.3.1. SOLIDDB_ADMIN_COMMANDS
You can add ADMIN commands to this system table.
1.8.3.2. SOLIDDB_SYS_TABLES
This table lists all the system tables.
There are no restrictions for viewing the system tables,
which means even users with no access rights can view them.
However, specific users are restricted from viewing the user
table information. Owners are restricted to viewing user
tables they have created and users can only view tables to
which they have
INSERT,
UPDATE,
DELETE, or
SELECT access.
Users are restricted from viewing any user tables if they
have no access rights. No restrictions apply to DBAs.
1.8.3.3. SOLIDDB_SYS_COLUMNS
This table lists all system table columns.
There are no owner or user viewing restrictions for viewing
the system columns, which means owners can view columns other
than those they have created in this table and users
with no access rights or with specific access rights
can still view any system column in this table.
1.8.3.4. SOLIDDB_SYS_KEYS
All database tables must have one clustering key. This key
defines the physical sorting order of the data. It has no
capacity impact. If a primary key is defined, the primary
key is used as the clustering key. If no primary key is
defined, an entry with key name $CLUSTKEY_xxxxx
will be automatically created in SYS_KEYS.
If there is a primary key definition for the table, there
will be an entry in SYS_KEYS with a
key_name like $PRIMARYKEY_xxxx for this
entry. The key_primary and
key_clustering columns will have
value YES.
If there is no primary key definition for the table, there
will be an entry in SYS_KEYS with a
key_name like $CLUSTKEY_xxxxx. The
key_primary column will have value
NO and the key_clustering
column will have value YES.
1.8.3.5. SOLIDDB_SYS_KEYPARTS1.8.3.6. SOLIDDB_SYS_FORKEYS1.8.3.7. SOLIDDB_SYS_FORKEYPARTS1.8.3.8. SOLIDDB_SYS_SCHEMAS
SYS_SCHEMAS lists available schemas.
1.8.3.9. SOLIDDB_SYS_SEQUENCES1.8.3.10. SOLIDDB_SYS_BLOBS1.8.3.11. SOLIDDB_SYS_CARDINAL1.8.3.12. SOLIDDB_SYS_INFO1.8.3.13. SOLIDDB_SYS_TABLEMODES1.9. Creating and Using solidDB Tables
To create a solidDB table, specify the
ENGINE = solidDB
option in the CREATE TABLE statement:
CREATE TABLE customers (a INT, b CHAR (20), INDEX (a)) ENGINE=solidDB;
The statement mentioned previously creates a table and an index on
column a in the solidDB database
that consists of the data files that you specified in
the my.cnf (or my.ini for Windows) file. In addition,
solidDB for MySQL creates a
customers.frm file in the test
directory under the MySQL database directory. Internally,
solidDB for MySQL adds an entry for the table to its own data
dictionary. The entry includes the database name. For example, if
you have a database named test,
and you create a table called customers
in it, the entry is for 'test/customers'.
This means you can create a table of the same name
(customers) in another database, and
the table names do not collide inside solidDB for MySQL.
You can specify the table type, optimistic or pessimistic,
when you create the table. For more information on table
modes, see Section 1.19, "Concurrency Control".
To create an optimistic table, you can use, for example,
the command below:
CREATE TABLE customers (a INT, b CHAR (20), INDEX (a)) ENGINE=solidDB
COMMENT='MODE=OPTIMISTIC';
To create a pessimistic table, you can use, for example,
the command below:
CREATE TABLE customers (a INT, b CHAR (20), INDEX (a)) ENGINE=solidDB
COMMENT='MODE=PESSIMISTIC';
If you specify no table type, the default value
OPTIMISTIC is used.
If you want all your (non-system) tables to be created
as solidDB tables, you can simply add the line
default-storage-engine=soliddb
to the [mysqld] section of your
server option file.
You can check the table type for an existing table by two methods:
If the solidDB system tables are created, you can
issue the query below:
SELECT MODE FROM SOLIDDB_SYS_TABLEMODES, SOLIDDB_SYS_TABLES
-> WHERE SOLIDDB_SYS_TABLES.TABLE_NAME = 't1' AND
-> SOLIDDB_SYS_TABLES.ID = SOLIDDB_SYS_TABLEMODES.ID;
The result is such as follows:
+-------------+
| MODE |
+-------------+
| PESSIMISTIC |
+-------------+
1 row in set (0.01 sec)
If you have given the table type in the create command,
you can use the query below:
mysql>
show create table t1\g;
The result is such as follows:
+-------+----------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------+
| t1 | CREATE TABLE 't1' ( |
| |'a' int(11) NOT NULL, |
| |PRIMARY KEY ('a') |
| |) ENGINE=solidDB DEFAULT CHARSET=latin1 |
| |COMMENT='MODE=PESSIMISTIC' |
+-------+----------------------------------------------------------+
1 row in set (0.02 sec)
Note
The output has been modified for layout purposes.
1.10. The Character Set Used for Data and Sorting
By default, solidDB for MySQL 5.0 uses the latin1 character
set and the latin1_general_cs collation.
Additionally, solidDB for MySQL 5.0 supports the UCS2 character
set and the ucs2_bin collation for storing
Unicode data.
1.11. Limitations on solidDB Tables in This Release
There are a number of known issues with solidDB tables in this release.
Solid is already working to address the most serious of these.
Known issues:
solidDB tables do not support collations.
Column index prefixes are not supported. With col_name(N)
syntax in an index specification, you can create an index that uses
only the first N characters of a string column. Indexing only a prefix
of column values in this way can make the index file much smaller.
For more information, refer to Column Indexes.
For example:
create table t0(a int not null, b varchar(255), primary key (a), key (b(10))) engine=soliddb;
INSERT DELAYED ... is not supported.
An attempt to use it leads to an error as follows:
mysql> insert delayed into isd values (1);
ERROR 1031 (HY000): Table storage engine for 'isd' doesn't have this option
All comparisons for string columns are case-sensitive.
Multiple NULL values are not allowed for UNIQUE keys.
Optimizer hints given to the storage engine are not
implemented. All columns are always retrieved and
index-only operations are not optimal. This
degrades performance with certain query operations.
Ordering of full 32-bit and 64-bit unsigned integer
types may not be correct. This is a known error, which
could not be fixed on time for the release.
BLOB support optimizations are not implemented;
memory usage optimizations are needed.
Table and column names are limited to 255 bytes.
Partial backups are not supported in this release.
Point in time recovery is not supported in this release.
Although solidDB internally supports row sizes
larger than 65535, you cannot define a row containing
VARCHAR columns with a combined
size larger than 65535. If you try, you get error
1118. For more information,
see Section 1.28, "solidDB Error Handling".
solidDB tables do not support
FULLTEXT indexes.
solidDB tables do not support spatial indexes.
This version of solidDB for MySQL does not support referential
action SET DEFAULT.
This version of solidDB for MySQL does not support
the REFERENCES clause on a column
definition. Use a constraint definition instead.
For example:
mysql> create table parent(a int not null, primary key (a)) engine=soliddb;
Query OK, 0 rows affected (0.13 sec)
mysql> create table child(a int not null, b int not null references
parent, primary key(a)) engine=soliddb;
ERROR 1235 (42000): This version of MySQL doesn't yet support 'REFERENCES'
Instead, use:
mysql> create table child(a int not null, b int not null, primary key
(a), constraint fparent foreign key (b) references child) engine=soliddb;
Query OK, 0 rows affected (0.17 sec)
The database can hold up to 232
objects, that is, tables, procedures, triggers, indexes,
and so on. The same counter (unsigned integer) is used to
get IDs for all.
The table column limit is 1000. Trying to create
a table with more than 1000 columns returns error
13121. For more information,
see Section 1.28, "solidDB Error Handling".
Server-side cursors are not supported on solidDB.
X/Open XA protocol is not supported on solidDB.
LOAD INDEX is not implemented on solidDB.
SAVEPOINT is not implemented on solidDB.
Warning
Do not convert MySQL system tables in the
mysql database from
MyISAM to solidDB tables.
This is an unsupported operation. If you do this,
solidDB for MySQL does not restart until you restore the old
system tables from a backup or re-generate them
with the mysql_install_db
script.
1.12. Dynamic Configuration Settings
Some solidDB system variables are dynamic and can be
set at runtime using SET GLOBAL.
You can also obtain their values using SELECT. See
Using System Variables
in MySQL documentation for more information.
The following chapters describe the dynamic
solidDB system variables. The options
that can be set with the SET statement
are also included.
Section
SET Syntax discusses these options.
Variables that have a type of 'string' take a string value.
Variables that have a type of 'numeric' take a numeric value.
Consider, for example, a situation where your database has
reached the maximum size specified by
soliddb_filespec. You can add a new
database file dynamically using a
MySQL client as follows:
shell> mysql
shell> SET GLOBAL soliddb_filespec='solid5.db 1G';
shell> exit;
You can only add one database file at a time. If you need to
add more than one database file, you must set
soliddb_filespec several times.
1.12.1. soliddb_admin_command
The parameter value type is string.
This parameter can have the values explained
in the following list. For each value the purpose, syntax, and an
example are provided.
backup
This parameter is used to take backups. The
syntax is shown below:
'backup [directory]'
An example command is shown below:
mysql> SET GLOBAL soliddb_admin_command='backup';
An example command with the optional backup
directory for Windows is shown below:
mysql> SET GLOBAL soliddb_admin_command='backup D:\\backupdir';
An example command with the optional backup
directory for Linux is shown below:
mysql> SET GLOBAL soliddb_admin_command='backup /backup/';
checkpoint
This parameter is used to make a checkpoint. The
syntax is shown below:
'checkpoint'
An example command is shown below:
mysql> SET GLOBAL soliddb_admin_command='checkpoint';
pmon
This parameter is used to start or stop performance
monitoring. The syntax is shown below:
'pmon diff {start <file> <interval> [append] | stop}'
The command to start performance monitoring
is shown below:
mysql> SET GLOBAL soliddb_admin_command='pmon diff start pmon.out 1000';
The command to stop performance monitoring
is shown below:
mysql> SET GLOBAL soliddb_admin_command='pmon diff stop';
1.12.2. soliddb_backupdir
This parameter defines the backup directory.
The parameter value type is string.
This parameter adds a new database file.
The parameter value type is string.
1.12.4. soliddb_durability_level
This parameter sets the transaction durability level.
The parameter value type is numeric 1-3.
1.12.5. soliddb_checkpoint_time
This parameter sets the checkpoint time interval.
The parameter value type is numeric.
1.12.6. soliddb_lock_wait_timeout
This parameter sets the transaction lock wait timeout.
The parameter value type is numeric.
1.12.7. soliddb_checkpoint_interval
This parameter sets the checkpoint write interval.
The parameter value type is numeric.
1.13. Foreign Key Constraints
In relational databases, it is common for records in one relation to
reference records in the same or other relations. The requirement that
the referenced records must exist is called referential integrity.
References can be made to link information together and it is an
essential part of database normalization. One important type of
referential integrity is the foreign key constraint.
A foreign key is a referential constraint between two tables in the
database. The foreign key identifies a column or a set of columns in
one (referencing) table that refers to a column or set of columns in
another (referenced) table. The columns in the referenced table must
form a primary key or unique key. The values in one row of the
referencing columns must occur in a single row in the referenced
table. Thus, a row in the referencing table cannot contain values that
do not exist in the referenced table. Multiple rows in the referencing
table may refer to the same row in the referenced table.
The referencing and referenced table may be the same table, that is, the
foreign key refers back to the same table. Such a foreign key is known
in SQL:2003 as a self-referencing or recursive foreign key.
A table may have multiple foreign keys, and each foreign key may have
a different referenced table. Each foreign key is independently forced
by the database system. Therefore, cascading relationships between
tables can be documented by using foreign keys.
Foreign keys are defined in the ANSI SQL Standard, by using a
FOREIGN KEY constraint. The syntax to add
such a constraint to an existing table is defined in SQL:2003.
Leaving out the column list in the REFERENCES
clause means that the foreign key references the primary
key of the referenced table.
solidDB for MySQL supports foreign key constraints. solidDB uses the
MySQL parser for foreign key definitions. See
FOREIGN KEY Constraints in the
MySQL 5.0 Reference Manual for more information on foreign keys and
Using Foreign Keys in the MySQL 5.0 Reference Manual for more
information on how to use foreign keys. Foreign key syntax can be found in
CREATE TABLE Syntax and in ALTER TABLE Syntax.
Note
This version of solidDB for MySQL does not
support the MATCH option.
solidDB for MySQL requires that both the referencing table and
referenced tables are solidDB tables.
Additionally, solidDB requires indexes on
foreign keys and referenced keys so that
foreign key checks can be fast and not require a table scan. The index
on the foreign key is automatically created. Corresponding
columns in the foreign key and the referenced key must have similar
internal data types inside solidDB so that they can be compared
without a type conversion. The size and sign of integer types must be
the same. The length of string types need not be the same. If you
specify a SET NULL action, make sure that you have not declared the
columns in the child table as NOT NULL.
The default referential action is ON UPDATE RESTRICT
and ON DELETE RESTRICT unless the ON
UPDATE and ON DELETE attributes are separately
given. Here is an example of creating tables using foreign keys:
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=SOLIDDB;
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT NOT NULL,
FOREIGN KEY fkey(t1_id) REFERENCES t1(id) ON DELETE CASCADE)
ENGINE=SOLIDDB;
If you attempt to insert a row to table t2
with a value that does not exist in the parent table
t1, you get an error message:
mysql> insert into t2 values (0, 0);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key
constraint fails (CONSTRAINT 'fkey' FOREIGN KEY ('t1_id') REFERENCES
't1' ('id') ON DELETE CASCADE ON UPDATE RESTRICT)
You must define tables in such an order that all referenced tables are
created before the tables referencing them. If MySQL reports an error
number 1005 from a CREATE TABLE statement, and the error message
refers to error number 155, then the table creation has failed because a
foreign key constraint was not correctly formed. Similarly, if an
ALTER TABLE fails and it refers to error number 155, then the table
alteration has failed because a foreign key constraint was incorrectly
formed for the altered table.
mysql> CREATE TABLE t3 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind
(t1_id), FOREIGN KEY (t1_id) REFERENCES t4(id) ON DELETE CASCADE)
ENGINE=SOLIDDB;
ERROR 1005 (HY000): Can't create table './test/t3.frm' (errno: 155)
You can also see an error message in the server log:
SOLID Table Error 13011: Table t4 does not exist
See below for a more complex example, in which a
product_order table
has foreign keys for two other tables. One foreign key references a
two-column index in the product table. The other references a
single-column index in the customer table:
create table customer(customer_id int not null, customer_name
varchar(80), primary key(customer_id)) engine=soliddb;
create table product(product_id int not null, product_price int,
primary key(product_id)) engine=soliddb;
create table product_order(order_id int not null, customer_id int not
null, product_id int not null, number_of_products int, primary
key(order_id), foreign key (customer_id) references
customer(customer_id), foreign key (product_id) references
product(product_id)) engine=soliddb;
Additionally, the foreign key can reference the same table:
create table t1(a int not null, b int not null, d int, primary key(a),
foreign key (b) references t1(a) on update no action on delete no
action) engine=soliddb;
1.13.1. Referential Actions
A DBMS must ensure the data integrity of the database when rows in a
referencing table are deleted or updated. SQL:2003 specifies five
different referential actions that will take place in such a case:
CASCADE
RESTRICT
NO ACTION
SET NULL
SET DEFAULT
Each of the five referential actions will be discussed below. 1.14. Transaction Durability
Normally, when a transaction is committed, the database server
writes data to two locations: the database file, and the
transaction log file. However, the data are not necessarily
written to those two locations at the same time. When a
transaction is committed, the server writes the data to
the transaction log file immediately, that is, as soon as
the server commits the transaction. However, the server does
not necessarily write the data to the database file immediately.
The server may wait until it is less busy, or until it has
accumulated multiple changes, before writing the data to
the database file.
If the server shuts down abnormally (due to a power failure,
for example) before all data have been written to the database
file, the server can recover 100% of committed data by reading
the combination of the database file and the transaction log
file. Any changes since the last write to the database file
are in the transaction log file. The server can read those
changes from the log file and then use that information to
update the database file. The process of reading changes
from the log file and updating the database file is called
"recovery". At the end of the recovery process, the database
file is 100% up to date.
The recovery process is automatically executed any time that
the server restarts after an abnormal shutdown. The process
is generally invisible to the user (except that there may
be a delay before the server is ready to respond to new
requests). Not surprisingly, to have a 100% recovery, you
must have 100% of the transactions written to the log file.
Normally, the database server writes data to the log file at
the same time that the server commits the data. Thus committed
transactions are stored on disk and will not be lost if the
computer is shut down abnormally. This is called "strict
durability". The data that have been committed are "durable",
even if the server is shut down abnormally.
If durability is "strict", data are written to the disk
drive at the time that the data are committed. The user is
not told that his data have been committed until the
data were successfully written to the transaction log on disk.
This ensures that the data are recoverable if the server shuts
down abnormally, for example, due to a power failure. Strict durability
makes it almost impossible to lose data unless the hard disk
drive itself fails. If durability is "relaxed", the user
may be told that the data have been committed even before the
data have been written to the transaction log on disk. The
server may choose to delay writing the data by, for example, waiting
until there are several transactions to write. If durability
is relaxed, the server may lose a few committed transactions
if there is a power failure before the data are written to disk.
Historically, the goal of most database servers has been to
maximize safety, that is, to make sure that data are not lost due
to a power failure or other problems. These database servers
use "strict durability". This approach is appropriate for many
types of data, such as accounting data, where it is often
unacceptable to lose track of even a single transaction.
Some database servers have been designed to maximize performance,
without regard to safety. This is acceptable in situations where,
for example, you only need to sample data, or where the server
can simply operate on the most recent set of data, regardless
of the size of that set.
Suppose, for example, that you have a server containing
statistical data about performance, for instance which
computers experience the heaviest loads at particular
times of the day. You might use such information to
balance the load on your computers. This information
changes over time, and "old" data are less valuable than
"new" data. In fact, you might completely discard any data
that are more than a week old. If you were to lose the
performance and load balancing data, then your system
would still function, and within a week you would have
acquired a complete set of new data (assuming that you
normally discard data older than one week). In this
situation, occasional or small data loss is acceptable,
and performance may be more important. solidDB allows you
to specify whether you want logging to be "strict"
(that is, to guarantee that all committed data can be
recovered after an unexpected shutdown) or "relaxed"
(that is, to allow some recent transactions to be lost
in some circumstances).
You can increase performance by instructing the server that it
does not necessarily have to write to the log file at the
same time that it commits data. This allows the server to
write to the log file later, perhaps when the server is
less busy, or when several transactions can be written at
once. This is called "relaxed durability". It increases
performance by decreasing the I/O load.
If you set the transaction durability level to "relaxed",
you risk losing some data if the server shuts down abnormally
after it has committed some data but before it has written
those data to the transaction log. Therefore, you should use
relaxed durability only when you can
afford to lose a small amount of recent data.
If you can afford to lose a small amount of recent data,
and if performance is crucial to you, then you may want
to use relaxed durability. Relaxed durability is appropriate
when each individual transaction is not crucial. For example,
if you are monitoring system performance and you want to store
data on response times, you may only be interested in average
response times, which will not be significantly affected if
you are missing a few pieces of data.
In fact, since measuring performance will itself affect
performance (by using up resources such as Central
Processing Unit (CPU) time and
I/O bandwidth), you probably want your performance
tracking operations themselves to have high performance
(low cost) rather than high precision. Relaxed durability
is appropriate in this situation. On the other hand, if
you are tracking financial data, such as bill payments,
then you probably want to ensure that 100% of your committed
data are stored and recoverable. In this situation, you will
want strict durability. You should use relaxed durability
only when you can afford to lose a few of the most recent
transactions. Otherwise, use strict durability. If you are
not sure whether strict or relaxed durability is appropriate
use strict durability.
1.15. How AUTO_INCREMENT Columns Work in solidDB
If you specify an AUTO_INCREMENT
column for a solidDB table, the table handle in the
solidDB data dictionary contains a special sequence
object called the "auto-increment sequence object" that
is used in assigning new values for the column.
This auto-increment sequence object is stored to disk.
If a user does not explicitly specify a value for an
AUTO_INCREMENT column, solidDB
increments the counter by one and assigns the new value
to the column. If the user inserts a row that explicitly
specifies the column value, and the value is bigger than
the current counter value, the counter is set to the
specified column value.
You may see gaps in the sequence of values assigned to the
AUTO_INCREMENT column if you roll back
transactions that have generated numbers using the counter.
If a user specifies NULL or
0 for the AUTO_INCREMENT
column in an INSERT, solidDB treats the
row as if the value had not been specified and generates a
new value for it.
The behavior of the auto-increment mechanism is not defined
if a user assigns a negative value to the column or if the
value becomes bigger than the maximum integer that can be
stored in the specified integer type.
solidDB supports the AUTO_INCREMENT = N
table option in CREATE TABLE and
ALTER TABLE statements, to set the
initial counter value or alter the current counter value.
1.16. solidDB and TRANSACTION ISOLATION LEVEL< | |