This chapter describes a lot of things that you need to know when working on the MySQL code. If you plan to contribute to MySQL development, want to have access to the bleeding-edge in-between versions code, or just want to keep track of development, follow the instructions in 「4.8 開発ソースツリーからのインストール」節参照. If you are interested in MySQL internals, you should also subscribe to internals@lists.mysql.com. This is a relatively low traffic list, in comparison with mysql@lists.mysql.com.
MySQL サーバーは以下のスレッドを作成します:
process_alarm()
to force timeouts on connections
that have been idle too long.
mysqld
is compiled with -DUSE_ALARM_THREAD
, a dedicated
thread that handles alarms is created. This is only used on some systems where
there are problems with sigwait()
or if one wants to use the
thr_alarm()
code in ones application without a dedicated signal
handling thread.
--flush-time=#
オプションを使用したなら、
全てのテーブルを一定期間でフラッシュするためだけのスレッドを作ります。
INSERT DELAYED
gets its
own thread.
--master-host
, a slave replication thread will be
started to read and apply updates from the master.
mysqladmin processlist
only shows the connection, INSERT DELAYED
,
and replication threads.
mysqladmin processlist
only shows the connection and INSERT
DELAYED
threads.
Until recently, our main full-coverage test suite was based on proprietary
customer data and for that reason has not been publicly available. The only
publicly available part of our testing process consisted of the crash-me
test, a Perl DBI/DBD benchmark found in the sql-bench
directory, and
miscellaneous tests located in tests
directory. The lack of a
standardized publicly available test suite has made it difficult for our users,
as well developers, to do regression tests on the MySQL code. To
address this problem, we have created a new test system that is included in
the source and binary distributions starting in Version 3.23.29.
The test system consist of a test language interpreter (mysqltest
),
a shell script to run all tests(mysql-test-run
), the actual test cases
written in a special test language, and their expected results. To run the
test suite on your system after a build, type mysql-test/mysql-test-run
from the source root. If you have installed a binary distribution, cd
to the install root (eg. /usr/local/mysql
), and do
scripts/mysql-test-run
. All tests should succeed. If they do not,
use mysqlbug
to send a bug report to bugs@lists.mysql.com.
Make sure to include the output of mysql-test-run
, as well as
contents of all .reject
files in mysql-test/r
directory.
If you have a copy of mysqld
running on the machine where you want to
run the test suite you do not have to stop it, as long as it is not using
ports 9306
and 9307
. If one of those ports is taken, you should
edit mysql-test-run
and change the values of the master and/or slave
port to one that is available.
The current set of test cases is far from comprehensive, as we have not yet converted all of our private tests to the new format. However, it should already catch most obvious bugs in the SQL processing code, OS/library issues, and is quite thorough in testing replication. Our eventual goal is to have the tests cover 100% of the code. We welcome contributions to our test suite. You may especially want to contribute tests that examine the functionality critical to your system, as this will ensure that all future MySQL releases will work well with your applications.
You can use the mysqltest
language to write your own test cases.
Unfortunately, we have not yet written full documentation for it - we plan to
do this shortly. You can, however, look at our current test cases and use
them as an example. The following points should help you get started:
mysql-test/t/*.test
mysql-test/mysql-test-run test_name
removing .test
extension from the file name
;
terminated statements and is similar to the
input of mysql
command line client. A statement by default is a query
to be sent to MySQL server, unless it is recognized as internal
command ( eg. sleep
).
SELECT
, SHOW
,
EXPLAIN
, etc., must be preceded with @/path/to/result/file
. The
file must contain the expected results. An easy way to generate the result
file is to run mysqltest -r < t/test-case-name.test
from
mysql-test
directory, and then edit the generated result files, if
needed, to adjust them to the expected output. In that case, be very careful
about not adding or deleting any invisible characters - make sure to only
change the text and/or delete lines. If you have to insert a line, make sure
the fields are separated with a hard tab, and there is a hard tab at the end.
You may want to use od -c
to make sure your text editor has not messed
anything up during edit. We, of course, hope that you will never have to edit
the output of mysqltest -r
as you only have to do it when you find a
bug.
mysql-test/r
directory and name them test_name.result
. If the
test produces more than one result, you should use test_name.a.result
,
test_name.b.result
, etc.
.reject
extension. If your test case is
failing, you should do a diff on the two files. If you cannot see how
they are different, examine both with od -c
and also check their
lengths.
!
if the test can continue after that query
returns an error.
source include/master-slave.inc;
. To switch between
master and slave, use connection master;
and connection slave;
.
If you need to do something on an alternate connection, you can do
connection master1;
for the master, and connection slave1;
for
the slave.
let $1=1000; while ($1) { # do your queries here dec $1; }
sleep
command. It supports fractions
of a second, so you can do sleep 1.3;
, for example, to sleep 1.3
seconds.
mysql-test/t/test_name-slave.opt
. For
the master, put them in mysql-test/t/test_name-master.opt
.
If your MySQL version doesn't pass the test suite you should do the following:
mysqlbug
script
so that we can get information about your system and MySQL
version. 「2.3 バグや問題を報告する方法」節参照.
Result length mismatch
or Result
content mismatch
it means that the output of the test didn't match
exactly the expected output. This could be a bug in MySQL or
that your mysqld version produces slight different results under some
circumstances. In this case you should compare the .test
and .reject
file in the mysql-test/r
sub directory to
see if this is something to worry about.
mysql-test/var/log
directory for hints of what went wrong.
--gdb
and --debug
options to mysql-test-run
.
「I.1.2 Creating trace files and using gdb on mysqld」節参照.
If you have not compiled MySQL for debugging you should probably
do that. Just specify the --with-debug
options to configure
!
「4.7 MySQL ソースディストリビューションのインストール」節参照.
Go to the first, previous, next, last section, table of contents.