Segmentation fault in interpreter doing simple MySQL

J

Jon Rosen

I am a relative ruby-newbie (hey that rhymes!) but I am a python expert
so this error REALLY threw me. I am doing a VERY VERY simply SQL
program that executes two queries in a row:

require 'mysql'
db = Mysql.connect('localhost','myname','mypswd','information_schema')
q1 = db.query ("select * from table_constraints")
q1.each { |row| puts row.inspect }
q1.free
q2 = db.query ("select * from key_column_usage")
q2.each { |row| puts row.inspect }
q2.free
db.close

This SHOULD just print the data from the two schema tables.

When I execute this with EITHER of the sets of three lines for q1 or q2
commented out (i.e., only one query in the program), this works fine.
Each run gives me the correct results from the appropriate query.

When I execute this as above, I get the following:

C:\ruby>ruby sqlcompare1.rb
[nil, "qautil", "PRIMARY", "qautil", "qausers", "PRIMARY KEY"]
[nil, "qautil", "PRIMARY", "qautil", "siteuimap", "PRIMARY KEY"]
[nil, "qautil", "map_page_field", "qautil", "siteuimap", "UNIQUE"]
[nil, "qautil", "PRIMARY", "qautil", "testusers", "PRIMARY KEY"]
sqlcompare1.rb:6: [BUG] Segmentation fault
ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-mingw32]

-- control frame ----------
c:0008 p:---- s:0023 b:0023 l:000022 d:000022 CFUNC :inspect
c:0007 p:---- s:0021 b:0021 l:000020 d:000020 CFUNC :inspect
c:0006 p:0012 s:0018 b:0017 l:001264 d:000016 BLOCK sqlcompare1.rb:6
c:0005 p:---- s:0014 b:0014 l:000013 d:000013 FINISH
c:0004 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :each
c:0003 p:0065 s:0009 b:0009 l:001264 d:000b58 EVAL sqlcompare1.rb:6
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001264 d:001264 TOP
---------------------------
-- Ruby level backtrace
information-----------------------------------------
sqlcompare1.rb:6:in `inspect'
sqlcompare1.rb:6:in `inspect'
sqlcompare1.rb:6:in `block in <main>'
sqlcompare1.rb:6:in `each'
sqlcompare1.rb:6: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.

C:\ruby>

Needless to say, this looks REALLY nasty and doesn't instill a lot of
confidence in me about the stability of the MySQL/Ruby code. I am
running Ruby 1.9.1 and Mysql 2.8.1 which are the latest and greatest as
far as I know.

Also needless to say, the following python version of the same code:

import MySQLdb
db =
MySQLdb.connect('localhost','myname','mypswd','information_schema')
q = db.cursor()
q.execute("select * from table_constraints")
for row in q.fetchall():
print row
q.execute("select * from key_column_usage")
for row in q.fetchall():
print row

WORKS PERFECTLY! :)

Anybody got any ideas or could you point me to a place where I can
report a nasty bug like this?

I can't even imagine that with something this simple blowing up that
there are thousands of Ruby/MySQL applications out there running on
websites flawlessly. There must be REALLY something weird going on
here.

Thanks,

Jon "bleurose" Rosen
 
P

poseid

 I am
running Ruby 1.9.1 and Mysql 2.8.1 which are the latest and greatest as
far as I know.

Just a small comment: Your script works for my local environment
without problems:

ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10]
mysql5 Ver 14.14 Distrib 5.1.47, for apple-darwin10.3.0 (i386) using
readline 6.1

Patrick
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top