[ruby-dbi-users] ntext fields with empty string crashing Ruby on OS X

Don Coleman dcoleman at chariotsolutions.com
Thu Apr 24 13:07:10 EDT 2008

Ruby is crashing with a Segmentation fault when selecting a ntext
column that contains an empty string.  I'm not sure if this is a dbi

This happens with SQLServer 2005 on Win2K3 and SQLServer 2005 Express on Win XP.

I can consistently reproduce this on different machines running OS X
10.5.2 with the Actual Technologies SQL Server driver and DBI 0.2.0.
I can use the Actual SQL Server driver and query the same table in
Excel without a problem.

I can not reproduce this on Linux with iODBC and FreeTDS.  It works
fine on Windows with ADO.

create table ntext_test (
     id int primary key,
     val ntext);

insert into ntext_test values (1, 'Some Data');
insert into ntext_test values (2, null);
insert into ntext_test values (3, '');

#!/usr/bin/env ruby

require "dbi"

  url = "DBI:ODBC:test"
  username = "user"
  password = "secret"

  dbh = DBI.connect(url, username, password)

  rows = dbh.select_all("select * from ntext_test where id < 3")
  puts rows

  rows = dbh.select_all("select * from ntext_test where id = 3")
  # Ruby crashes here
  # /Library/Ruby/Site/1.8/DBD/ODBC/ODBC.rb:237: [BUG] Segmentation fault
  # ruby 1.8.6 (2007-09-24) [universal-darwin9.0]
  dbh.disconnect if dbh

More information about the ruby-dbi-users mailing list