Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ビルドできるようにする #1

Closed
takatoshiono opened this issue May 30, 2015 · 6 comments
Closed

ビルドできるようにする #1

takatoshiono opened this issue May 30, 2015 · 6 comments

Comments

@takatoshiono
Copy link
Owner

まずは mycsv ストレージエンジンをビルドできるようにしたい。

@takatoshiono
Copy link
Owner Author

最初にやったこと

カスタムのストレージエンジンと言えばQ4Mなので、そのインストール方法を参考にすると、MySQLのソースツリーにコピーしてビルドするようなので真似をした。

コマンド

mysql-5.6.23 ディレクトリで。

$ ln -s `ghq list -p mysql-mycsv`/src storage/mycsv
$ cmake .
$ make

結果

... (長いので省略)
Scanning dependencies of target mysqld
[ 71%] Building CXX object sql/CMakeFiles/mysqld.dir/main.cc.o
Linking CXX executable mysqld
[ 71%] Built target mysqld
Scanning dependencies of target mycsv
[ 71%] Building CXX object storage/mycsv/CMakeFiles/mycsv.dir/ha_mycsv.cc.o
Linking CXX shared module ha_mycsv.so
clang: error: no such file or directory: '../../libservices/libmysqlservices.a'
make[2]: *** [storage/mycsv/ha_mycsv.so] Error 1
make[1]: *** [storage/mycsv/CMakeFiles/mycsv.dir/all] Error 2
make: *** [all] Error 2

@takatoshiono
Copy link
Owner Author

シンボリックリンクではダメみたいなのでちゃんとコピーしてもう一回。

$ rm storage/mycsv
$ mkdir storage/mycsv
$ cp -r `ghq list -p mycsv`/src/* storage/mycsv/

今度は通ったようだ。

[ 71%] Built target mysqld
Linking CXX shared module ha_mycsv.so
[ 71%] Built target mycsv
Scanning dependencies of target myisam_embedded
[ 71%] Building C object storage/myisam/CMakeFiles/myisam_embedded.dir/ft_boolean_search.c.o

@takatoshiono
Copy link
Owner Author

そうすると storage/mycsv/ha_mycsv.so ができる。
make install すると /usr/local/mysql にインストールされる。
ha_mycsv.so は lib/plugin にコピーされていた。

@takatoshiono
Copy link
Owner Author

MySQL 起動

$ scripts/mysql_install_db
$ bin/mysqld --port=13306

プラグインインストール

$ mysql -uroot -P13306
mysql> show storage engines ;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)

まだ表示されないので、INSTALL PLUGIN する。

https://dev.mysql.com/doc/refman/5.6/en/install-plugin.html

mysql> install plugin MYCSV soname 'ha_mycsv.so';
Query OK, 0 rows affected (0.07 sec)

mysql> show storage engines ;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MYCSV              | YES     | Example storage engine                                         | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)

出た!

@takatoshiono
Copy link
Owner Author

テーブルを作ってみよう

mysql> use test
Database changed
mysql> create table mycsv_test(id int not null, col1 int not null) engine=mycsv;
Query OK, 0 rows affected (0.08 sec)

mysql> show create table mycsv_test;
+------------+----------------------------------------------------------------------------------------------------------------------+
| Table      | Create Table                                                                                                         |
+------------+----------------------------------------------------------------------------------------------------------------------+
| mycsv_test | CREATE TABLE `mycsv_test` (
  `id` int(11) NOT NULL,
  `col1` int(11) NOT NULL
) ENGINE=MYCSV DEFAULT CHARSET=latin1 |
+------------+----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> insert into mycsv_test(id,col1) values(1,100);
Query OK, 1 row affected (0.00 sec)

mysql> select * from mycsv_test;
Empty set (0.00 sec)

mysql> show table status like 'mycsv_test' \G
*************************** 1. row ***************************
           Name: mycsv_test
         Engine: MYCSV
        Version: 10
     Row_format: Fixed
           Rows: 0
 Avg_row_length: 0
    Data_length: 0
Max_data_length: 0
   Index_length: 0
      Data_free: 0
 Auto_increment: NULL
    Create_time: NULL
    Update_time: NULL
     Check_time: NULL
      Collation: latin1_swedish_ci
       Checksum: NULL
 Create_options: 
        Comment: 
1 row in set (0.01 sec)
  • テーブルは作れる
  • INSERT 文は成功するけど...
  • SELECT してみると保存されていない

@takatoshiono
Copy link
Owner Author

デバッグモードでビルドする場合、cmake にオプションを渡す。

$ cmake -DWITH_DEBUG=1 .

https://dev.mysql.com/doc/refman/5.6/ja/compiling-for-debugging.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant