備忘録的ログ

月曜日の部内勉強会までに調べにゃいかんことがたんまり残ってるので、今週末は予定の合間を縫ってぼちぼちInnoDBを弄っていきまふ。ちなみにうちの部では定期的にMySQLのソース解析勉強会をやってまふ。企画したのおいらだけどw サービスで飯食ってくつもりならそれくらいはせんとね・・・。

とりあえず、備忘録的ログ。このエントリにがしがし追加していきまふ。

mysql-5.0をbkからゲト。

./sfioball -r+ bk://mysql.bkbits.net/mysql-5.0 my-5.0

configureを生成

BUILD/autorun.sh

とりあえずconfigure

./configure
...
checking for termcap functions library... configure: error: No curses/termcap library found

いまビルドしようとしてる環境だと

mir@mir33:~/software/mysql/my-5.0$ ls /lib | grep libncurs
libncurses.so.5
libncurses.so.5.4

ということなのでこれを指定せねばならんね。

./configure --with-named-curses-libs=/lib/libncurses.so.5 

readlineは今回は無視で。

とりあえず一度ビルドしておく(意味あるよね?)。

make
make install

あーもう準備だけでだらだら30分もやってるw 王様のブランチが気になるw

VisualStudio側も5.0.22落としてとりあえずビルド。そういえばついでに例の件しらべてしまおうか。3台目のマシンがひまそうにしてるなー。ビルド終わるまでこいつで遊んどこうか。

といったところでそろそろ本題。とりあえずUNIV_DEBUGを有効にして再ビルド。

CFLAGS="-DUNIV_DEBUG" ./configure --with-named-curses-libs=/lib/libncurses.so.5
make
make install

ビルド失敗w

: undefined reference to `btr_pcur_move_to_next_user_rec'
../innobase/dict/libdict.a(dict0load.o)(.text+0x386e): In function `dict_load_foreigns':
: undefined reference to `btr_pcur_close'
../innobase/dict/libdict.a(dict0load.o)(.text+0x3897): In function `dict_load_foreigns':
: undefined reference to `mem_heap_free_func'
../innobase/dict/libdict.a(dict0load.o)(.text+0x38a5): In function `dict_load_foreigns':
: undefined reference to `dict_table_get_next_index'
../innobase/dict/libdict.a(dict0load.o)(.text+0x38c2): In function `dict_load_foreigns':

UNIV_DEBUGだけじゃ駄目だったかw

ということで素直にuniv.iのコメントを外して再挑戦。

/* Make a non-inline debug version */

#define UNIV_DEBUG
#define UNIV_MEM_DEBUG
#define UNIV_IBUF_DEBUG
#define UNIV_SYNC_DEBUG
#define UNIV_SEARCH_DEBUG
#define UNIV_SYNC_PERF_STAT
#define UNIV_SEARCH_PERF_STAT
#define UNIV_SRV_PRINT_LATCH_WAITS;

VisualStuio側では"#DEFINE UNIV_DEBUG"のみやってみたら以下のコンパイルエラー

Error	13	error C2065: 'ssize_t' : undeclared identifier	c:\software\mysql\mysql-5.0.22\innobase\include\mem0mem.ic	625

ん〜〜。これは、、、

char* mem_strdupq(const char* str, char q)
{
    ...
    const char* s   = str;
    size_t      len = strlen(str) + 3;
    ...
    ut_ad((ssize_t) len == d - dst);
    return(dst);
}

size_tをssize_tにキャストしてるけどssize_tがどこにも定義されていないわけですか。VisualStudioディレクトリを文字列検索すれど使えそうなヘッダファイルは見つからず。size_tを代用しとくかw

そーするとビルドはできたけど、mysqld-max-nt.exe起動してmysql.exeで接続して、InnoDBテーブルを作ろうとした瞬間、DBG系ライブラリとリンクしてないからアクセス例外なんたらでWindowsに怒られた。そりゃそうだ。Linuxの方も同じ問題起きそうだね。はい、やり直し。

なかなかrem0rec.cまで到達しないな〜 orz

んー、だめっぽい。UNIV_DEBUGの影響か。CREATE TABLE時にアクセス違反例外がおきる。

mysqld-debug.exe!dict_table_get_n_user_cols(dict_table_struct * table=0x015dbca0)  Line 95 + 0x28 bytes	C
mysqld-debug.exe!row_create_table_for_mysql(dict_table_struct * table=0x015dbca0, trx_struct * trx=0x015d8ca0)  Line 1830 + 0x1b bytes	C
mysqld-debug.exe!create_table_def(trx_struct * trx=0x015d8ca0, st_table * form=0x0498d800, const char * table_name=0x0498d5b0, const char * path_of_temp_table=0x00000000, unsigned long comp=1)  Line 4384 + 0xd bytes	C++
mysqld-debug.exe!ha_innobase::create(const char * name=0x0498e2fc, st_table * form=0x0498d800, st_ha_create_information * create_info=0x03a55808)  Line 4623 + 0x3c bytes	C++
mysqld-debug.exe!ha_create_table(const char * name=0x0498e2fc, st_ha_create_information * create_info=0x03a55808, int update_create_info=0)  Line 2134 + 0x25 bytes	C++
mysqld-debug.exe!rea_create_table(THD * thd=0x03a55200, char * file_name=0x0498e2fc, const char * db=0x03a58da0, const char * table=0x03a738b0, st_ha_create_information * create_info=0x03a55808, List<create_field> & create_fields={...}, unsigned int keys=1, st_key * key_info=0x03a73ce8)  Line 264 + 0x1b bytes	C++
mysqld-debug.exe!mysql_create_table(THD * thd=0x03a55200, const char * db=0x03a58da0, const char * table_name=0x03a738b0, st_ha_create_information * create_info=0x03a55808, List<create_field> & fields={...}, List<Key> & keys={...}, int internal_tmp_table=0, unsigned int select_field_count=0)  Line 1689 + 0x28 bytes	C++
mysqld-debug.exe!mysql_execute_command(THD * thd=0x03a55200)  Line 2899 + 0x3e bytes	C++
mysqld-debug.exe!mysql_parse(THD * thd=0x03a55200, char * inBuf=0x03a73838, unsigned int length=60)  Line 5695 + 0x9 bytes	C++
mysqld-debug.exe!dispatch_command(enum_server_command command=COM_QUERY, THD * thd=0x03a55200, char * packet=0x03a6b789, unsigned int packet_length=61)  Line 1736 + 0x1d bytes	C++
mysqld-debug.exe!do_command(THD * thd=0x03a55200)  Line 1522 + 0x31 bytes	C++
mysqld-debug.exe!handle_one_connection(void * arg=0x03a55200)  Line 1165 + 0x9 bytes	C++
mysqld-debug.exe!pthread_start(void * param=0x0159fff0)  Line 63 + 0x7 bytes	C
mysqld-debug.exe!_callthreadstart()  Line 293 + 0xf bytes	C
mysqld-debug.exe!_threadstart(void * ptd=0x03a58b48)  Line 277	C
KERNEL32.DLL!77e5b388() 	
[Frames below may be incorrect and/or missing, no symbols loaded for KERNEL32.DLL]	
NTDLL.DLL!77fb2c0c() 	

要するに、やりたいのはRecordとかPageのダンプを適宜取りたいってことなんだけど、もうちょいやり方を考える必要ありそう。

というか、トレーニングとかでストレージエンジンの概念を説明するときに概念図だけでなくスタックトレースもつかってみると良いかもしれないとか思ったり。ちょっくら外出してきま(´・ω・`)