RDBI / rdbi-driver-odbc

ODBC driver for RDBI
MIT License
1 stars 11 forks source link

RDBI group_concat: `fetch': negative string size (or size too big) #5

Open wlodi83 opened 11 years ago

wlodi83 commented 11 years ago

Hi, when I use RDBI and query with group_concat function I am getting following error:

.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:in `fetch': negative string size (or size too big) (ArgumentError)

wlodi83 commented 11 years ago

Why RDBI doesn't support group_concat function?

Similar problem happens when database returns null value.

pilcrow commented 11 years ago

@wlodi83, can you provide a concise, complete, and correct code sample that reproduces your symptoms?

Can you also supply relevant versions for: rdbi, rdbi-driver-odbc, ruby-odbc, your system odbc library, and the backend database? Also, what is the backend database, MySQL or HSQLDB?

wlodi83 commented 11 years ago

Hello,

I am using following gems:

gem list

* LOCAL GEMS *

bundler (1.3.5) dbd-odbc (0.2.5) dbi (0.4.5) deprecated (2.0.1) epoxy (0.3.1) methlab (0.1.0) rake (10.0.4) rdbi (0.9.1) rdbi-driver-odbc (0.1.2) ruby-odbc (0.99995, 0.99992) rubygems-bundler (1.1.1) rvm (1.11.3.7) typelib (0.1.0)

I am using unixODBC library on Ubuntu 12.04. Database is EXASOL.

This is example of code:

require 'rdbi-driver-odbc' dbh = RDBI.connect :ODBC, :db => "EXA", :user => "test", :password => "test" rs = dbh.execute "select nvl(tar.aff_status, 0), tar.s_status, count(*), group_concat(toc.country_code) from ids.track_conversions as tar join ids.track_click as toc on tar.subid = toc.subid where toc.aff_id = '52' and toc.CREATED_AT >= curdate()-3 group by 1,2" print rs.fetch(:all) dbh.disconnect

it returns an error:

/home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:in fetch': negative string size (or size too big) (ArgumentError) from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:ininitialize' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:223:in new' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:223:innew_execution' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-0.9.1/lib/rdbi/statement.rb:163:in execute' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-0.9.1/lib/rdbi/database.rb:189:inexecute' from rdbi.rb:5:in `

' WARNING: #ODBC::Statement:0x233cb40 was not dropped before garbage collection.

If I will remove the group_concat function everything is OK.

Regarding null values:

I am getting following error if I will remove "nvl" function from the code:

/home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:in fetch': failed to allocate memory (NoMemoryError) from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:106:ininitialize' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:223:in new' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-driver-odbc-0.1.2/lib/rdbi/driver/odbc.rb:223:innew_execution' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-0.9.1/lib/rdbi/statement.rb:163:in execute' from /home/lukasz/.rvm/gems/ruby-2.0.0-p0@rdbi/gems/rdbi-0.9.1/lib/rdbi/database.rb:189:inexecute' from rdbi.rb:5:in `

'

require 'rdbi-driver-odbc' dbh = RDBI.connect :ODBC, :db => "EXA", :user => "test", :password => "test" rs = dbh.execute "select tar.aff_status, tar.s_status, count(*) from ids.track_conversions as tar join ids.track_click as toc on tar.subid = toc.subid where toc.aff_id = '52' and toc.CREATED_AT >= curdate()-3 group by 1,2" print rs.fetch(:all) dbh.disconnect

wlodi83 commented 11 years ago

Hi pilcrow,

do you know where could be the problem?

pimeys commented 11 years ago

I'm also having this problem. Using 2.0.0-p247.