Skip to content
This repository
Browse code

Do not shallow the original exception in exec_cache

when result_error_field is not defined on result raise the original
exception.

Fixes #11260
  • Loading branch information...
commit d704c1cb9850bd563b7ad99762e75b9b3cb7aebf 1 parent c4ad10e
Rafael Mendonça França authored July 09, 2013
6  activerecord/CHANGELOG.md
Source Rendered
... ...
@@ -1,5 +1,11 @@
1 1
 ## unreleased ##
2 2
 
  3
+*   Do not shallow the original exception in `exec_cache` on PostgreSQL adapter.
  4
+
  5
+    Fixes #11260.
  6
+
  7
+    *Rafael Mendonça França*
  8
+
3 9
 *   Fix `ActiveRecord::Store` incorrectly tracking changes of its attributes.
4 10
     Fixes #10373.
5 11
 
6  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -1179,7 +1179,11 @@ def exec_cache(sql, binds)
1179 1179
             # prepared statements whose return value may have changed is
1180 1180
             # FEATURE_NOT_SUPPORTED.  Check here for more details:
1181 1181
             # http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/cache/plancache.c#l573
1182  
-            code = e.result.result_error_field(PGresult::PG_DIAG_SQLSTATE)
  1182
+            begin
  1183
+              code = e.result.result_error_field(PGresult::PG_DIAG_SQLSTATE)
  1184
+            rescue
  1185
+              raise e
  1186
+            end
1183 1187
             if FEATURE_NOT_SUPPORTED == code
1184 1188
               @statements.delete sql_key(sql)
1185 1189
               retry

0 notes on commit d704c1c

Please sign in to comment.
Something went wrong with that request. Please try again.