Attempt to fix conversion proc refresh. #551

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

uhoh-itsmaciek commented Sep 15, 2012

This is not a pretty fix (I'm not much of a Rubyist), but it works. Without this, I get the error below when including hstore, because reset_conversion_procs calls fetch_rows_set_cols, which depends on having some conversion procs to decode the output.

home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:717:in `block in fetch_rows_set_cols': undefined method `[]' for nil:NilClass (NoMethodError)
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:716:in `times'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:716:in `fetch_rows_set_cols'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:547:in `block in fetch_rows'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:134:in `execute'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:431:in `_execute'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:234:in `block (2 levels) in execute'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:443:in `check_database_errors'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:234:in `block in execute'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/database/connecting.rb:229:in `block in synchronize'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/connection_pool/threaded.rb:105:in `hold'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/database/connecting.rb:229:in `synchronize'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:234:in `execute'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/dataset/actions.rb:762:in `execute'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:547:in `fetch_rows'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/dataset/actions.rb:151:in `each'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/dataset/actions.rb:392:in `map'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/dataset/actions.rb:392:in `map'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/dataset/actions.rb:714:in `_select_map_multiple'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/dataset/actions.rb:748:in `_select_map'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/dataset/actions.rb:500:in `select_map'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/shared/postgres.rb:694:in `get_conversion_procs'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/shared/postgres.rb:410:in `reset_conversion_procs'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/shared/postgres.rb:738:in `initialize_postgres_adapter'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/adapters/postgres.rb:170:in `initialize'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/database/connecting.rb:78:in `new'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/database/connecting.rb:78:in `connect'
        from /home/maciek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sequel-3.39.0/lib/sequel/core.rb:147:in `connect'
Owner

jeremyevans commented Sep 15, 2012

This is definitely a bug. I think the reason that you are the first to hit this is that most people don't load the extension until after connecting, via: DB.extension(:pg_hstore). I think I'll fix this slightly differently than you did, in initialize_postgres_adapter. Thanks for the heads up!

Owner

jeremyevans commented Sep 15, 2012

Can you try the patch at http://pastie.org/pastes/4727446/text and let me know if it fixes the issue?

Contributor

uhoh-itsmaciek commented Sep 15, 2012

Yep, your patch does the trick (and makes more sense). Thanks!

Owner

jeremyevans commented Sep 17, 2012

This should be fixed by a097312

Contributor

uhoh-itsmaciek commented Sep 17, 2012

Confirmed. Thanks again for the quick response!

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