rails:3458
From: eiichi_maekawa@m...
Date: Fri, 2 Jul 2010 14:30:53 +0900
Subject: [rails:3458] MySQL DBI::libmysql.dllとの相性
前川です。宜しくお願いします。
Railsは、まだまだ、始めたばかりです。
MySQLをDBIで使うために、関連のインストールを行い、実行しましたが、Segmentation
fault が生じました。
libmysql.dllを色々試して、2028KBのlibmysql.dllであれば、使用できることが分
かりました。
libmysql.dllは、ruby.exeと同じフォルダ(ruby/bin)に入れています。
教えていただきたいのは、Ruby1.8.7 と libmysql.dl lとの相性です。
何故、2028KBの libmysql.dll 以外(2304KBlでしか試していませんが)で
は、Segmentation faultとなるのでしょうか??
固有のdllしか使えないのでしたら、DBI関連のgemファイルに含まれるのではな
いでしょうか??
ちなみに、2304KBのlibmysql.dllは、mysqlに含まれていたものです。
コード・デバッグ結果、バージョン等は、以下に記載しました。
宜しくお願いします。
#!D:/Ruby/bin/ruby.exe -Ks
require "dbi"
begin
dbh = DBI.connect('DBI:Mysql:DB名:サーバ名', 'ユーザ名', 'パスワード')
#sth = dbh.prepare("SHOW TABLES") #←OK
sth = dbh.prepare("SELECT * FROM aplist")
#sth = dbh.prepare("SHOW COLUMNS FROM aplist")
#sth = dbh.prepare('DESCRIBE aplist')
#sth = dbh.prepare("show databases") #OK
puts dbh
puts sth
sth.execute
puts 'count='+sth.rows.to_s #テーブル数のみ有効?
count = 0
sth.fetch { |row|
p row
count = count + 1
}
sth.finish
puts 'increment count='+count.to_s
#DB例外発生時の処理
rescue DBI::DatabaseError => e
p "An error occurred"
p "Error code: #{e.err}"
p "Error message: #{e.errstr}"
#切断漏れしないようにensureでdisconnectします。
ensure
dbh.disconnect if dbh
end
上記で、OKとあるのは、2304KBのlibmysql.dllを使用した時のものです。
それ以外(SELECT文、SHOW COLUMNS文等)は、すべて、Segmentation faultが発生
しました。
デバッグ記録は、以下です。
(rdb:1) s
D:/Ruby/lib/ruby/site_ruby/1.8/dbd/mysql/statement.rb:125:
indexed = (unique_key_flag | multiple_key_flag)
(rdb:1) s
D:/Ruby/lib/ruby/site_ruby/1.8/dbd/mysql/statement.rb:125:
indexed = (unique_key_flag | multiple_key_flag)
(rdb:1) s
D:/Ruby/lib/ruby/site_ruby/1.8/dbd/mysql/statement.rb:130:
@res_handle.fetch_fields.each {|col|
(rdb:1) s
D:/Ruby/lib/ruby/site_ruby/1.8/dbd/mysql/statement.rb:130: [BUG]
Segmentation fault
ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mswin32]
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
使用しているdbd(ダウンロードしたもの);;dbd-mysql-0.4.3.zip
使用しているdbi(ダウンロードしたもの);;dbi-0.4.3.zip
O/Sは、WINDOWS-XP、Rubyのバージョン等は、以下です。
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
D:\>ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mswin32]
D:\>gem list --local
*** LOCAL GEMS ***
actionmailer (2.3.4)
actionpack (2.3.4)
activerecord (2.3.4)
activeresource (2.3.4)
activesupport (2.3.4)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
deprecated (2.0.1)
eventmachine (0.12.10)
fastthread (1.0.1)
gem_plugin (0.2.3)
linecache (0.43)
mongrel (1.1.5)
mysql (2.8.1)
rack (1.0.0)
rails (2.3.4)
rake (0.8.7)
ruby-debug-base (0.10.3)
ruby-debug-ide (0.4.5)
sinatra (0.9.4)
sqlite3-ruby (1.2.5)
thin (1.2.4)
D:\>
--
ML: rails@r...
使い方: http://QuickML.com/