log every sql statement, even when they error
This commit is contained in:
parent
19fc88646b
commit
98e001641f
@ -772,32 +772,32 @@ def exec_no_cache(sql, name, binds)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def exec_cache(sql, name, binds)
|
def exec_cache(sql, name, binds)
|
||||||
log(sql, name, binds) do
|
stmt_key = prepare_statement(sql)
|
||||||
begin
|
|
||||||
stmt_key = prepare_statement(sql)
|
|
||||||
|
|
||||||
@connection.send_query_prepared(stmt_key, binds.map { |col, val|
|
log(sql, name, binds) do
|
||||||
type_cast(val, col)
|
@connection.send_query_prepared(stmt_key, binds.map { |col, val|
|
||||||
})
|
type_cast(val, col)
|
||||||
@connection.block
|
})
|
||||||
@connection.get_last_result
|
@connection.block
|
||||||
rescue PGError => e
|
@connection.get_last_result
|
||||||
# Get the PG code for the failure. Annoyingly, the code for
|
end
|
||||||
# prepared statements whose return value may have changed is
|
rescue ActiveRecord::StatementInvalid => e
|
||||||
# FEATURE_NOT_SUPPORTED. Check here for more details:
|
pgerror = e.original_exception
|
||||||
# http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/cache/plancache.c#l573
|
|
||||||
begin
|
# Get the PG code for the failure. Annoyingly, the code for
|
||||||
code = e.result.result_error_field(PGresult::PG_DIAG_SQLSTATE)
|
# prepared statements whose return value may have changed is
|
||||||
rescue
|
# FEATURE_NOT_SUPPORTED. Check here for more details:
|
||||||
raise e
|
# http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/cache/plancache.c#l573
|
||||||
end
|
begin
|
||||||
if FEATURE_NOT_SUPPORTED == code
|
code = pgerror.result.result_error_field(PGresult::PG_DIAG_SQLSTATE)
|
||||||
@statements.delete sql_key(sql)
|
rescue
|
||||||
retry
|
raise e
|
||||||
else
|
end
|
||||||
raise e
|
if FEATURE_NOT_SUPPORTED == code
|
||||||
end
|
@statements.delete sql_key(sql)
|
||||||
end
|
retry
|
||||||
|
else
|
||||||
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user