Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wlodi83 opened this issue Jun 16, 2013 · 5 comments
Open

Comments

@wlodi83
Copy link

wlodi83 commented Jun 16, 2013

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
Copy link
Author

wlodi83 commented Jun 17, 2013

Why RDBI doesn't support group_concat function?

Similar problem happens when database returns null value.

@pilcrow
Copy link
Member

pilcrow commented Jun 17, 2013

@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
Copy link
Author

wlodi83 commented Jun 17, 2013

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
Copy link
Author

wlodi83 commented Jun 21, 2013

Hi pilcrow,

do you know where could be the problem?

@pimeys
Copy link

pimeys commented Jul 18, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants