mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
PostgreSQL adapter: escape_bytea, quote_string and unescape_bytea aren't thread-safe in Ruby 1.8 [#3237 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
This commit is contained in:
committed by
Jeremy Kemper
parent
c401102a27
commit
cec44f5838
@@ -298,7 +298,7 @@ module ActiveRecord
|
||||
# QUOTING ==================================================
|
||||
|
||||
# Escapes binary strings for bytea input to the database.
|
||||
def escape_bytea(value)
|
||||
def escape_bytea(original_value)
|
||||
if @connection.respond_to?(:escape_bytea)
|
||||
self.class.instance_eval do
|
||||
define_method(:escape_bytea) do |value|
|
||||
@@ -322,13 +322,13 @@ module ActiveRecord
|
||||
end
|
||||
end
|
||||
end
|
||||
escape_bytea(value)
|
||||
escape_bytea(original_value)
|
||||
end
|
||||
|
||||
# Unescapes bytea output from a database to the binary string it represents.
|
||||
# NOTE: This is NOT an inverse of escape_bytea! This is only to be used
|
||||
# on escaped binary output from database drive.
|
||||
def unescape_bytea(value)
|
||||
def unescape_bytea(original_value)
|
||||
# In each case, check if the value actually is escaped PostgreSQL bytea output
|
||||
# or an unescaped Active Record attribute that was just written.
|
||||
if PGconn.respond_to?(:unescape_bytea)
|
||||
@@ -368,7 +368,7 @@ module ActiveRecord
|
||||
end
|
||||
end
|
||||
end
|
||||
unescape_bytea(value)
|
||||
unescape_bytea(original_value)
|
||||
end
|
||||
|
||||
# Quotes PostgreSQL-specific data types for SQL input.
|
||||
@@ -393,7 +393,7 @@ module ActiveRecord
|
||||
end
|
||||
|
||||
# Quotes strings for use in SQL input in the postgres driver for better performance.
|
||||
def quote_string(s) #:nodoc:
|
||||
def quote_string(original_value) #:nodoc:
|
||||
if @connection.respond_to?(:escape)
|
||||
self.class.instance_eval do
|
||||
define_method(:quote_string) do |s|
|
||||
@@ -413,7 +413,7 @@ module ActiveRecord
|
||||
remove_method(:quote_string)
|
||||
end
|
||||
end
|
||||
quote_string(s)
|
||||
quote_string(original_value)
|
||||
end
|
||||
|
||||
# Checks the following cases:
|
||||
|
||||
Reference in New Issue
Block a user