- 컴파일하기 // mysql library path를 잡은 경우 . shell)gcc -shared -o ishangul.so ishangul.c // myslq library path를 잡지 않은경우(mysql을 /usr/local/mysql에 컴파일했을경우) . shell)gcc -shared -o ishangul.so ishangul.c -I/usr/local/mysql/include/mysql -L/usr/local/mysql/lib/mysql/lib -lmysqlclient
ishangul.so를 공유라이브러리폴더로 복사 . shell)cp ishangul.so /usr/lib;
- mysql 접속 - shell)mysql -uroot xxxxxx
- 등록 - mysql>create function ishangul returns integer soname "ishangul.so";
- 확인 - mysql>use mysql; mysql>select * from func; +----------+-----+-------------+----------+ | name | ret | dl | type | +----------+-----+-------------+----------+ | ishangul | 0 | ishangul.so | function | +----------+-----+-------------+----------+ 1 rows in set (0.00 sec)
- 테스트 - mysql> select ishangul('한'); +----------------+ | ishangul('한') | +----------------+ | 1 | +----------------+ 1 row in set (0.00 sec)
mysql> select ishangul('H'); +---------------+ | ishangul('H') | +---------------+ | 0 | +---------------+ 1 row in set (0.00 sec)
더 자세한 정보는..아래 링크를 참조하세요. http://www.mysql.com/doc/en/Adding_functions.html