MySQL optimizer_traceパッチ(2)
自分がオプティマイザの動作を理解するために作ったパッチなので汎用性は無いのですが、とりあえずここに置きました。
http://sh2.mydns.to/hatena/optimizer_trace_5.0.51.patch.tar.gz
MySQL Community Server最新版の5.0.51に対するパッチになっています。どのOSでも動くと思いますがこちらではCentOS 4.5 x86で動作を確認しています。
http://dev.mysql.com/downloads/mysql/5.0.html
↑ここのCompressed GNU TAR archive (tar.gz)をダウンロードして、以下のようにしてパッチを当てます。
$ tar xvzf ~/temp/mysql-5.0.51.tar.gz mysql-5.0.51/ mysql-5.0.51/bdb/ mysql-5.0.51/bdb/Makefile.in 〜 mysql-5.0.51/win/data/test/ $ cd mysql-5.0.51/ $ tar xvzf ~/temp/optimizer_trace_5.0.51.patch.tar.gz optimizer_trace_5.0.51.patch $ patch -p0 -d . < optimizer_trace_5.0.51.patch patching file sql/mysqld.cc patching file sql/set_var.cc patching file sql/sql_class.h patching file sql/sql_select.cc
configureオプションの例を以下に示します。これはRPM版のspecファイルから持ってきて少しカスタマイズしたものです。prefix、with-unix-socket-pathはマシン環境に合わせて変更、with-debugは必要なければ外してください。
./configure \ --prefix=/home/taira/mysql/bin-5.0.51 \ --disable-shared \ --enable-assembler \ --enable-local-infile \ --enable-thread-safe-client \ --with-archive-storage-engine \ --with-big-tables \ --with-blackhole-storage-engine \ --with-csv-storage-engine \ --with-debug \ --with-example-storage-engine \ --with-extra-charsets=complex \ --with-federated-storage-engine \ --with-innodb \ --with-pic \ --with-server-suffix=-community \ --with-unix-socket-path=/home/taira/mysql/bin-5.0.51/mysql.sock \ --with-zlib-dir=bundled \ --without-bench \ --without-embedded-server \ --with-comment='MySQL Community Server - Debug'
あとはconfigure、make、make install。インストール先のディレクトリでデータベースを初期化し、サーバを起動します。
$ ls bin include info lib libexec man mysql-test share $ mkdir var $ bin/mysql_install_db Installing MySQL system tables... OK Filling help tables... OK 〜 The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com $ libexec/mysqld InnoDB: The first specified data file ./ibdata1 did not exist: InnoDB: a new database to be created! 071215 23:52:58 InnoDB: Setting file ./ibdata1 size to 10 MB InnoDB: Database physically writes the file full: wait... 〜 071215 23:52:59 [Note] libexec/mysqld: ready for connections. Version: '5.0.51-community-debug' socket: '/home/taira/mysql/bin-5.0.51/mysql.sock' port: 3306 MySQL Community Server - Debug
この環境を使っていろいろ調べていきたいと思います。
2012/03/10追記
ファイルを移動しました。
http://dbstudy.info/files/20120310/optimizer_trace_5.0.51.patch.tar.gz