[ruby-list:46564] Re: DBI実行エラーについて
From:
"前川 映一" <eiichi_maekawa@...>
Date:
2009-11-17 05:37:15 UTC
List:
ruby-list #46564
前川です。
自己レスで葉にですが、関連をググってたら、
http://rubyforge.org/tracker/index.php?func=detail&aid=26791&group_id=234&atid=967
で、同様のバグレポートを見つけました。(英語は苦手なので、間違ってたら、ご
めんなさい。)
コメントの中で、
I've got the segmentation fault when I select all or some special
fields of my table.
Also there is a problem to identifiy my VARCHAR-fields.
My primary key-field is ok as INT(10) and a Fixnum in Ruby. My
first VARCHAR(100) is only a Fixnum with 0 or 1 in the result
hash.
を見つけました。
コメント全体は、segmentationfaultの
> D:/Ruby/lib/ruby/site_ruby/1.8/dbd/mysql/statement.rb:130: [BUG]
に関するものでした。
今でも、このバグは、解消されてないのでしょうか?
MySQLは、5.1.33を使用しています。
その後、どうなったか、ご存知でしたら、ご教示ください。
"前川 映一" <eiichi_maekawa@mhi.co.jp> wrote on 2009/11/17 14:11:47:
> 前川です。
> http://code.nanigac.com/source/wiki/view/496
> にあるサンプルプログラム(dbi確認用)を実行しましたが、エラーが生じまし
た。
> 回避策につきまして、ご教示ください。
>
> 使用したプログラム
> #!D:/Ruby/bin/ruby.exe -Ks
> require 'dbi'
> begin
> dbh = DBI.connect('DBI:Mysql:hellodb', 'root', 'dbkey')
> # dbh = DBI.connect('DBI:Mysql:fbsys', 'root', 'dbkey')
> sth = dbh.prepare('select * from dept')
> puts dbh
> puts sth
> sth.execute
> sth.fetch { |row|
> p row
> }
> sth.finish
> #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
>
> 実施結果
> 1.3行、2列のデータベースの場合
> hellodbのdbkeyのデータ
> 100,Sales
> 200,Manage
> 300,Execute
> Rubyのp row の結果
> #<DBI::DatabaseHandle:0x2cd67a0> #-> dbh DBI::DatabaseHandleオブジェクト
> #<DBI::StatementHandle:0x2cd637c> #-> sth SQL文stmtの実行準備し
> て、DBI::StatementHandleを戻す。
> [100, 0] #-> Sales が、0 となっている。以下同様。
> [200, 0] #->0となった列の定義は、CHAR(50)
> [300, 0]
> 2.55行、31列のデータベースの場合
> fbsysのaplistのデータ
> 以下のSegmentation faultが、発生しました。
> D:/Ruby/lib/ruby/site_ruby/1.8/dbd/mysql/statement.rb:130: [BUG]
> Segmentation fault
> ruby 1.8.7 (2009-06-12 patchlevel 174)
> [i386#<DBI::DatabaseHandle:0x2cd67a0>
> #<DBI::StatementHandle:0x2cd637c>
> -mswin32]
> This application has requested the Runtime to terminate it in an unusual
> way.
> Please contact the application's support team for more information.
> 3.パラメータのroot,dbkeyを別の値に変えた場合
> エラーとなり、例外発生処理が機能していることを確認できました。
> 以下のとおりです。
> "An error occurred"
> "Error code: 1045"
> "Error message: Access denied for user 'user'@'localhost' (using
password:
> YES)"
>
> ruby関連バージョンは、以下です。
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
> C:\Documents and Settings\M118543>ruby -v
> ruby 1.8.7 (2009-06-12 patchlevel 174) [i386-mswin32]
> C:\Documents and Settings\M118543>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)
> deprecated (2.0.1)
> linecache (0.43)
> 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)
> よろしくお願いします。