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

Getting invalid connection option "prepared_statement" (PG::Error) #8784

Closed
SamSaffron opened this issue Jan 6, 2013 · 11 comments
Closed

Getting invalid connection option "prepared_statement" (PG::Error) #8784

SamSaffron opened this issue Jan 6, 2013 · 11 comments

Comments

@SamSaffron
Copy link
Contributor

Just attempted to upgrade to Rails 4 and got:

/home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:703:in `initialize': invalid connection option "prepared_statement" (PG::Error)
  from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:703:in `new'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:703:in `connect'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:469:in `initialize'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `new'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:38:in `postgresql_connection'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `new_connection'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:456:in `checkout_new_connection'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:427:in `acquire_connection'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `block in checkout'
    from /home/sam/.rvm/rubies/ruby-1.9.3-p194-perf/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:363:in `checkout'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:273:in `block in connection'
    from /home/sam/.rvm/rubies/ruby-1.9.3-p194-perf/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:272:in `connection'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:551:in `retrieve_connection'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
    from /home/sam/.rvm/gems/ruby-1.9.3-p194-perf/bundler/gems/rails-9ee65aaaadfe/activerecord/lib/active_record/connection_handling.rb:53:in `connection'
    from /home/sam/Source/app/lib/site_setting_extension.rb:65:in `table_exists?'

pg 0.14.1 is in Gemfile.lock

@rafaelfranca
Copy link
Member

What is you config/database.yml content?

@SamSaffron
Copy link
Contributor Author

development:
  adapter: postgresql
  database: mydb
  host: localhost
  prepared_statement: false
  pool: 5
  timeout: 5000

@rafaelfranca
Copy link
Member

The name of option is prepared_statements

@SamSaffron
Copy link
Contributor Author

thanks !

@SamSaffron
Copy link
Contributor Author

This does though raise an issue @rafaelfranca , in the past you could hang additional options off connection and now you can not so I think this should be re-opened.

For example for my multisite stuff I hang this off the connection:

host: site.com

in 4 its going to cause breakage, on one hand the change is good, cause it helps you catch typos, on the other hand it does not allow you to hang additional info off the connection you may want in other spots.

@rafaelfranca
Copy link
Member

I didn't get your problem. Could you explain better what you can't do now?

@SamSaffron
Copy link
Contributor Author

If my config is:

development:
  adapter: postgresql
  database: mydb
  host: localhost
  pool: 5
  timeout: 5000
  host_name: site.com

afaik in rails 3.2 it works, in 4 it fails.

I want an option in database.yml that is ignored by postgres I need to look at the code, but as far as I can tell from this bug, it seems there was some whitelisting of params that happened in 3.2 that no longer happens in 4.

@rafaelfranca
Copy link
Member

I don't think we should support this, the database configuration is supposed to be used only to database configuration. If you want to store data I don't think this is the right place.

@SamSaffron
Copy link
Contributor Author

I can work around this in my gem, but pool and adapter are already options that are not passed all the way into the pg provider and stripped out.

Is there a mechanism for my gem to expand on what I call "db configuration", for me I am saying the db "developement" is only for users that hit the host "site.com"

Additionally, this is a big breaking change, the error message really should be improved somehow if possible.

@rafaelfranca
Copy link
Member

@SamSaffron I'm discussing to change this from backlist to whitelist, so you will not need to work around.

@SamSaffron
Copy link
Contributor Author

Thanks!

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

2 participants