Merge pull request #42368 from engwan/postgresql-empty-query-check
Use an empty query instead of SELECT 1
This commit is contained in:
commit
ed3612e6d4
|
@ -1,3 +1,9 @@
|
||||||
|
* Use an empty query to check if the PostgreSQL connection is still active
|
||||||
|
|
||||||
|
An empty query is faster than `SELECT 1`.
|
||||||
|
|
||||||
|
*Heinrich Lee Yu*
|
||||||
|
|
||||||
* Add `ActiveRecord::Base#previously_persisted?`
|
* Add `ActiveRecord::Base#previously_persisted?`
|
||||||
|
|
||||||
Returns `true` if the object has been previously persisted but now it has been deleted.
|
Returns `true` if the object has been previously persisted but now it has been deleted.
|
||||||
|
|
|
@ -292,7 +292,7 @@ module ActiveRecord
|
||||||
# Is this connection alive and ready for queries?
|
# Is this connection alive and ready for queries?
|
||||||
def active?
|
def active?
|
||||||
@lock.synchronize do
|
@lock.synchronize do
|
||||||
@connection.query "SELECT 1"
|
@connection.query ";"
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
rescue PG::Error
|
rescue PG::Error
|
||||||
|
|
Loading…
Reference in New Issue