Using fetch_fields in MySQL for Windows


Kind of new to ruby. I installed 1.9.1 on windows with my sql server.

I’m logging to the database and able to query the DB and get the results
properly. When I try to get meta data from the query like fetch_fields
I get and error and the program breaks. It says that this might be a
bug in the package.

Any help?

require ‘mysql’
con =‘localhost’, ‘root’, ‘password’, ‘test’)
@rs = con.query “select * from testTable”
@rs.fetch_fields.each_with_index do |info, i|

=> #Mysql::Result:0x2da6380
irb(main):005:0> re.fetch_fields
NameError: undefined local variable or method re' for main:Object from (irb):5 from C:/Ruby191/bin/irb:12:in
irb(main):006:0> rs.fetch_fields
(irb):6: [BUG] Segmentation fault
ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

– control frame ----------
c:0024 p:---- s:0085 b:0085 l:000084 d:000084 CFUNC :fetch_fields
c:0023 p:0011 s:0082 b:0082 l:001074 d:000081 EVAL (irb):6
c:0022 p:---- s:0080 b:0080 l:000079 d:000079 FINISH
c:0021 p:---- s:0078 b:0078 l:000077 d:000077 CFUNC :eval
c:0020 p:0027 s:0071 b:0071 l:000070 d:000070 METHOD
c:0019 p:0031 s:0064 b:0063 l:000062 d:000062 METHOD
c:0018 p:0030 s:0058 b:0058 l:001194 d:000057 BLOCK
c:0017 p:0039 s:0050 b:0050 l:000049 d:000049 METHOD
c:0016 p:0011 s:0045 b:0045 l:001194 d:000044 BLOCK
c:0015 p:0132 s:0041 b:0041 l:000024 d:000040 BLOCK
c:0014 p:---- s:0038 b:0038 l:000037 d:000037 FINISH
c:0013 p:---- s:0036 b:0036 l:000035 d:000035 CFUNC :loop
c:0012 p:0009 s:0033 b:0033 l:000024 d:000032 BLOCK
c:0011 p:---- s:0031 b:0031 l:000030 d:000030 FINISH
c:0010 p:---- s:0029 b:0029 l:000028 d:000028 CFUNC :catch
c:0009 p:0023 s:0025 b:0025 l:000024 d:000024 METHOD
c:0008 p:0042 s:0022 b:0022 l:001194 d:001194 METHOD
c:0007 p:0011 s:0019 b:0019 l:0011d4 d:000018 BLOCK
c:0006 p:---- s:0017 b:0017 l:000016 d:000016 FINISH
c:0005 p:---- s:0015 b:0015 l:000014 d:000014 CFUNC :catch
c:0004 p:0174 s:0011 b:0011 l:0011d4 d:0011d4 METHOD
c:0003 p:0039 s:0006 b:0006 l:00103c d:0024e4 EVAL
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:00103c d:00103c TOP

– Ruby level backtrace
(irb):6:in fetch_fields' (irb):6:inirb_binding’
C:/Ruby191/lib/ruby/1.9.1/irb/workspace.rb:80:in eval' C:/Ruby191/lib/ruby/1.9.1/irb/workspace.rb:80:inevaluate’
C:/Ruby191/lib/ruby/1.9.1/irb/context.rb:216:in evaluate' C:/Ruby191/lib/ruby/1.9.1/irb.rb:157:inblock (2 levels) in eval_input’
C:/Ruby191/lib/ruby/1.9.1/irb.rb:271:in signal_status' C:/Ruby191/lib/ruby/1.9.1/irb.rb:154:inblock in eval_input’
C:/Ruby191/lib/ruby/1.9.1/irb/ruby-lex.rb:244:in block (2 levels) in each_top_level_statement' C:/Ruby191/lib/ruby/1.9.1/irb/ruby-lex.rb:230:inloop’
C:/Ruby191/lib/ruby/1.9.1/irb/ruby-lex.rb:230:in block in each_top_level_statement' C:/Ruby191/lib/ruby/1.9.1/irb/ruby-lex.rb:229:incatch’
each_top_level_statement' C:/Ruby191/lib/ruby/1.9.1/irb.rb:153:ineval_input’
C:/Ruby191/lib/ruby/1.9.1/irb.rb:70:in block in start' C:/Ruby191/lib/ruby/1.9.1/irb.rb:69:incatch’
C:/Ruby191/lib/ruby/1.9.1/irb.rb:69:in start' C:/Ruby191/bin/irb:12:in

You may encounter a bug of Ruby interpreter. Bug reports are welcome.
For details:

This application has requested the Runtime to terminate it in an unusual
Please contact the application’s support team for more information.

Any ideas???



Any help?

(irb):6: [BUG] Segmentation fault
ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

probably a bug in the gem.
You could try a different version of ruby and see if that helps.
Or possibly the mysqlplus gem (except it doesn’t have any windows

Roger P. wrote:

Any help?

(irb):6: [BUG] Segmentation fault
ruby 1.9.1p430 (2010-08-16 revision 28998) [i386-mingw32]

probably a bug in the gem.
You could try a different version of ruby and see if that helps.
Or possibly the mysqlplus gem (except it doesn’t have any windows

I found a solution for the problem. The MySQL gem does not work with
the libmysql.dll of newer mysql versions.

Here is a link for the fix:

thanks for the reply,


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs