diff options
author | Akira Matsuda <ronnie@dio.jp> | 2013-01-05 14:45:18 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2013-01-06 15:41:14 +0900 |
commit | 70ae89c321444eef42c0c011b522f926250e7acd (patch) | |
tree | 0f7abe41af87a17deb5c90465d1e9a190e4a70a9 /activerecord/lib | |
parent | 3e8134a750bee5c4f7ede67f33263d36e4ff1474 (diff) | |
download | rails-70ae89c321444eef42c0c011b522f926250e7acd.tar.gz rails-70ae89c321444eef42c0c011b522f926250e7acd.tar.bz2 rails-70ae89c321444eef42c0c011b522f926250e7acd.zip |
Remove unnecessary begin..rescue..end, use only rescue
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index c106215bd5..72e476be90 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -647,32 +647,30 @@ module ActiveRecord end def exec_cache(sql, binds) + stmt_key = prepare_statement sql + + # Clear the queue + @connection.get_last_result + @connection.send_query_prepared(stmt_key, binds.map { |col, val| + type_cast(val, col) + }) + @connection.block + @connection.get_last_result + rescue PGError => e + # Get the PG code for the failure. Annoyingly, the code for + # prepared statements whose return value may have changed is + # FEATURE_NOT_SUPPORTED. Check here for more details: + # http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/cache/plancache.c#l573 begin - stmt_key = prepare_statement sql - - # Clear the queue - @connection.get_last_result - @connection.send_query_prepared(stmt_key, binds.map { |col, val| - type_cast(val, col) - }) - @connection.block - @connection.get_last_result - rescue PGError => e - # Get the PG code for the failure. Annoyingly, the code for - # prepared statements whose return value may have changed is - # FEATURE_NOT_SUPPORTED. Check here for more details: - # http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/cache/plancache.c#l573 - begin - code = e.result.result_error_field(PGresult::PG_DIAG_SQLSTATE) - rescue - raise e - end - if FEATURE_NOT_SUPPORTED == code - @statements.delete sql_key(sql) - retry - else - raise e - end + code = e.result.result_error_field(PGresult::PG_DIAG_SQLSTATE) + rescue + raise e + end + if FEATURE_NOT_SUPPORTED == code + @statements.delete sql_key(sql) + retry + else + raise e end end |