Using fetch_fields in MySQL for Windows

Y

Yuval Rooz

Hey,

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 = Mysql.new('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 `<main>'
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:/Ruby191/lib/ruby/1.9.1/irb/workspace.rb:80
c:0019 p:0031 s:0064 b:0063 l:000062 d:000062 METHOD
C:/Ruby191/lib/ruby/1.9.1/irb/context.rb:216
c:0018 p:0030 s:0058 b:0058 l:001194 d:000057 BLOCK
C:/Ruby191/lib/ruby/1.9.1/irb.rb:157
c:0017 p:0039 s:0050 b:0050 l:000049 d:000049 METHOD
C:/Ruby191/lib/ruby/1.9.1/irb.rb:271
c:0016 p:0011 s:0045 b:0045 l:001194 d:000044 BLOCK
C:/Ruby191/lib/ruby/1.9.1/irb.rb:154
c:0015 p:0132 s:0041 b:0041 l:000024 d:000040 BLOCK
C:/Ruby191/lib/ruby/1.9.1/irb/ruby-lex.rb:244
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:/Ruby191/lib/ruby/1.9.1/irb/ruby-lex.rb:230
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:/Ruby191/lib/ruby/1.9.1/irb/ruby-lex.rb:229
c:0008 p:0042 s:0022 b:0022 l:001194 d:001194 METHOD
C:/Ruby191/lib/ruby/1.9.1/irb.rb:153
c:0007 p:0011 s:0019 b:0019 l:0011d4 d:000018 BLOCK
C:/Ruby191/lib/ruby/1.9.1/irb.rb:70
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:/Ruby191/lib/ruby/1.9.1/irb.rb:69
c:0003 p:0039 s:0006 b:0006 l:00103c d:0024e4 EVAL
C:/Ruby191/bin/irb:12
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
information-----------------------------------------
(irb):6:in `fetch_fields'
(irb):6:in `irb_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:in `evaluate'
C:/Ruby191/lib/ruby/1.9.1/irb/context.rb:216:in `evaluate'
C:/Ruby191/lib/ruby/1.9.1/irb.rb:157:in `block (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:in `block 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:in `loop'
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:in `catch'
C:/Ruby191/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in
`each_top_level_statement'
C:/Ruby191/lib/ruby/1.9.1/irb.rb:153:in `eval_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:in `catch'
C:/Ruby191/lib/ruby/1.9.1/irb.rb:69:in `start'
C:/Ruby191/bin/irb:12:in `<main>'

[NOTE]
You may encounter a bug of Ruby interpreter. Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html


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

Any ideas????

thanks,

Yuval
 
R

Roger Pack

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
binaries...)
-r
 
Y

Yuval Rooz

Roger said:
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
binaries...)
-r

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:

http://www.fuyun.org/2010/01/ruby-mysql-adapter-on-windows/

thanks for the reply,

Y
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,057
Messages
2,570,443
Members
47,115
Latest member
DorothyLus

Latest Threads

Top