ããã¯MySQL Casual Advent Calendar 2011 - MySQL Casualã®8æ¥ç®ã®è¨äºã§ãï¼
UDFã§FizzBuzz
id:sugyanãããã¹ãã¢ãããã·ã¼ã¸ã£ã§FizzBuzzããã£ã¦ããã®ã§MySQLã®UDF(user-defined function)ã§ããã£ã¦ã¿ã¾ããã
kamipo/mysql_fizzbuzz · GitHub
git clone git://github.com/kamipo/mysql_fizzbuzz.git cd mysql_fizzbuzz g++ -shared -fPIC -Wall -g mysql_fizzbuzz.cc -o mysql_fizzbuzz.so cp mysql_fizzbuzz.so /usr/local/mysql/lib/mysql/plugin mysql -u root -e "create function fizzbuzz returns string soname 'mysql_fizzbuzz.so'"
mysql -u root -NE -e "SELECT fizzbuzz(100)" *************************** 1. row *************************** 1 2 Fizz 4 Buzz Fizz 7 ...
ãããªã«ã³ã¸ã§UDFã§ãã«ã¸ã¥ã¢ã«ã«FizzBuzzã§ãã¾ãããï¼
æ¬é¡
@xaicronããã¨@kazeburoããã¨ã¤ã³ã¹ãã¼ã«ã¹ã¯ãªãããã¿ã§ãã¶ã£ã¦ããã©æ°ã«ããªã(+ï½Ï´+)
æè¿ã¯perlbrewã¨ãrvmã¨ãnvmã¨ãã§ç°¡åã«èªåç¨ã®perlã¨ãrubyã¨ãnodeã¨ãã¤ã³ã¹ãã¼ã«ã§ãããããªãã§ããã
ããã§MySQLãããã¨åããããã«ã¸ã¥ã¢ã«ã«ã¤ã³ã¹ãã¼ã«ãããããã§ããã
ããã§ä»æ¥æ¸ãã¦ãã®ãkamipo/mysql-build · GitHubã§ãã
ã¨ãããããã¾ã¯sstephenson/ruby-build · GitHubã®ã»ã¨ãã©ã³ãããªãã§ãã
git clone git://github.com/kamipo/mysql-build.git cd mysql-build
githubããcloneãã¦ãã¦ããã£ã¦
./bin/mysql-build --definitions 4.0.30 5.1.59 5.5.14-spider-2.27 5.5.18
ã¤ã³ã¹ãã¼ã«ã§ããMySQLã®ä¸è¦§ãã¿ããã®ã§
./bin/mysql-build -v 5.1.59 ~/opt/mysql/5.1.59
ããã ãã§ã¤ã³ã¹ãã¼ã«ã§ãã¾ãï¼ï¼
MySQL 5.5以éã¯ãã«ãããã®ã«cmakeãå¿ è¦ãªãã§ããããããããcmakeãå ¥ãã¦ããã°
./bin/mysql-build -v 5.5.18 ~/opt/mysql/5.5.18
ãããªã«ç°¡åã«ã¤ã³ã¹ãã¼ã«ã§ãã¾ãï¼ï¼ï¼ï¼
ãã¤ã¯ãã£ãç¥ã£ããã§ããæè¿ã®Spiderã¹ãã¬ã¼ã¸ã¨ã³ã¸ã³ã¯Q4Mã¨HandlerSocketããã³ãã«ããã¦ãã¿ãããããªãã§ããããããå ¥ãã¦ã¿ã¾ãããã
./bin/mysql-build -v 5.5.14-spider-2.27 ~/opt/mysql/5.5.14-spider-2.27 ... BUILD FAILED Inspect or clean up the working tree at /tmp/mysql-build.20111208231547.62780 Results logged to /tmp/mysql-build.20111208231547.62780.log Last 10 log lines: [ 93%] Building CXX object storage/spider/CMakeFiles/spider.dir/hs_client/config.cpp.o [ 93%] Building CXX object storage/spider/CMakeFiles/spider.dir/hs_client/escape.cpp.o [ 93%] Building CXX object storage/spider/CMakeFiles/spider.dir/hs_client/fatal.cpp.o [ 93%] Building CXX object storage/spider/CMakeFiles/spider.dir/hs_client/hstcpcli.cpp.o [ 94%] Building CXX object storage/spider/CMakeFiles/spider.dir/hs_client/socket.cpp.o [ 94%] Building CXX object storage/spider/CMakeFiles/spider.dir/hs_client/string_util.cpp.o Linking CXX shared module ha_spider.so ld: warning: directory '/Users/kamipo/opt/mysql/5.5.14-spider-2.27/lib' following -L not found [ 94%] Built target spider make: *** [all] Error 2
ãã«ãã«å¤±æãã¾ããï¼ï¼ããã¯ããããã¦@xaicronããã®ä¸çºã§ã¤ã³ã¹ãã¼ã«ã§ããã¹ã¯ãªããã使ã£ã¦ããã¦ãã ããï¼ï¼
æ°ãåãç´ãã¦MySQL 4.0ã®ææ°ãã¼ã¸ã§ã³ã®MySQL 4.0.30ãå ¥ãã¦ã¿ã¾ãããã
./bin/mysql-build -v 4.0.30 ~/opt/mysql/4.0.30 ... BUILD FAILED Inspect or clean up the working tree at /tmp/mysql-build.20111208230555.14795 Results logged to /tmp/mysql-build.20111208230555.14795.log Last 10 log lines: longlong2str.s:123:suffix or operands invalid for `pop' longlong2str.s:132:Unknown pseudo-op: .size longlong2str.s:132:Rest of line ignored. 1st junk character valued 108 (l). longlong2str.s:135:Unknown pseudo-op: .type longlong2str.s:135:Rest of line ignored. 1st junk character valued 108 (l). longlong2str.s:140:Unknown pseudo-op: .size longlong2str.s:140:Rest of line ignored. 1st junk character valued 108 (l). make[2]: *** [longlong2str-x86.o] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2
ã¾ããã«ãã«å¤±æãã¾ããï¼ï¼MySQL 4.0ã®ãã¨ã¯@kazeburoããã«èããªãã¨ããããããªãã®ã§ä»åã¯ããããã¾ãããï¼ï¼
ã追è¨ã
(ãã«ãã«å¤±æããã®ã¯Mac OS X 10.6.8ã§ã®ãã¨ã§ãUbuntu 10.04ã§ã¯ã©ã¡ãããã«ãæåãã¾ãã)