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

Nil comparison error in cursor.rb when calling PL/SQL procedure #61

Closed
mike-bourgeous opened this Issue Aug 22, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@mike-bourgeous

mike-bourgeous commented Aug 22, 2014

Occasionally when I use the ruby-plsql gem to call a particular PL/SQL procedure, I get the following error in OCI8::Cursor:

comparison of Fixnum with nil failed
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-oci8-2.1.7/lib/oci8/cursor.rb:510:in `>'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-oci8-2.1.7/lib/oci8/cursor.rb:510:in `upto'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-oci8-2.1.7/lib/oci8/cursor.rb:510:in `define_columns'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-oci8-2.1.7/lib/oci8/cursor.rb:127:in `exec'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-plsql-0.5.0/lib/plsql/oci_connection.rb:97:in `exec'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-plsql-0.5.0/lib/plsql/oci_connection.rb:82:in `new_from_query'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-plsql-0.5.0/lib/plsql/oci_connection.rb:132:in `cursor_from_query'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-plsql-0.5.0/lib/plsql/connection.rb:102:in `select_first'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-plsql-0.5.0/lib/plsql/sql_statements.rb:5:in `select_first'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-plsql-0.5.0/lib/plsql/schema.rb:196:in `find_database_object'
    /home/username/.rvm/gems/ruby-2.1.1@gemset_name/gems/ruby-plsql-0.5.0/lib/plsql/schema.rb:179:in `method_missing'
    /home/username/devel/application/lib/application_name/oracle/module_name.rb:37:in `block in apply'

The PL/SQL method signature looks like this, and typically returns NULL in errbuf and retcode:

   PROCEDURE apply (p_id      IN NUMBER,
                    p_val1    IN VARCHAR2,
                    p_val2    IN VARCHAR2,
                    p_amount  IN NUMBER,
                    errbuf    OUT NOCOPY VARCHAR2,
                    retcode   OUT NOCOPY VARCHAR2);

I call the procedure like this:

plsql.package_name.apply(12345678, 'abcdefgh', 'ijklmnop', 0)
# => {:errbuf => nil, :retcode => nil}

I'm not sure what exactly the ruby-plsql gem does from there.

@mike-bourgeous

This comment has been minimized.

mike-bourgeous commented Aug 28, 2014

This can be reproduced using the scripts from issue #62: https://gist.github.com/mike-bourgeous/07d65f63d6b448de9a38

@kubo kubo closed this in 6dc961b Nov 16, 2014

@kubo

This comment has been minimized.

Owner

kubo commented Nov 16, 2014

#62 and this issue is caused by bugs in both ruby-oci8 and ruby-plsql.
Ruby-plsql may close cursors used in other threads and try to use a closed cursor.
In ruby-oci8, using a closed cursor causes various problems such as segmentation fault, nil comparison error in cursor.rb and so on. 6dc961b fix it by raising an exception in the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment