Project

General

Profile

Actions

Bug #3577

closed

Segmentation fault doing simple MySQL queries

Added by bleurose (Jon Rosen) almost 14 years ago. Updated almost 13 years ago.

Status:
Third Party's Issue
Assignee:
-
ruby -v:
1.9.1
[ruby-core:31305]

Description

=begin
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 `'

[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.

Just for the record, 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! :-)

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
=end

Actions #1

Updated by bleurose (Jon Rosen) almost 14 years ago

=begin
Just one more note. When I said MySQL 2.8.1, I was referring to the version of the Ruby client "gem" that I installed. The version of MySQL Server I am using is 5.1.41 running on Windows (but it certainly isn't a server problem as both the python code and the individual queries in ruby work fine).

Thanks,

Jon
=end

Actions #2

Updated by luislavena (Luis Lavena) almost 14 years ago

=begin
Mysql gem has been compiled against 5.0.83, not 5.1 version of mysql.

Segmentation faults are caused by changes in libmysql.dll

Either downgrade to 5.0 or copy 5.0 dll inside ruby bin directory.
=end

Actions #3

Updated by usa (Usaku NAKAMURA) almost 14 years ago

  • Status changed from Open to Third Party's Issue

=begin

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0