Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

PostgreSQL escape methods aren't thread-safe (in Ruby 1.8)

#3237

PostgreSQL adapter has code like that

def query_string(s)
  self.class.instance_eval do
    define_method(:query_string) do |s|
       @connection.query_string(s)
    end
  end
  query_string(s)
end

In ruby 1.8 it's not thread-safe because block's argument is bound to method's argument. So when you call this method in several threads it could return value you aren't expecting.

Patch renames methods' arguments original_value, so blocks' arguments are no longer bound to them.

Reported by Eugene Pimenov · September 20th, 2009 @ 11:39 AM

State: resolved
Milestone: 3.0.2
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: none

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from ruby 1.8.7, 1.8.6, activerecord, adapters, patch, postgres, postgresql to ruby 1.8.7, 1.8.6, activerecord, adapters, bugmash, patch, postgres, postgresql
    • Assigned user cleared.

    September 25th, 2009 @ 11:58 AM

  2. Rizwan Reza
    Rizwan Reza
    • Milestone cleared.
    • Tag changed from ruby 1.8.7, 1.8.6, activerecord, adapters, bugmash, patch, postgres, postgresql to ruby 1.8.7, 1.8.6, activerecord, adapters, patch, postgres, postgresql
    • State changed from new to verified
    • Assigned user set to Pratik

    Applies cleanly to master and 2-3-stable.

    January 20th, 2010 @ 11:51 AM

  3. Rizwan Reza
    Rizwan Reza
    • Assigned user changed from Pratik to Yehuda Katz (wycats)

    Can be applied to master cleanly. All tests pass on AR suite.

    March 27th, 2010 @ 01:31 PM

  4. Repository
    Repository
    • State changed from verified to resolved

    (from [fc6746fc3f102029020e3893cde5480a58470d59]) 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
    http://github.com/rails/rails/commit/fc6746fc3f102029020e3893cde548...

    March 29th, 2010 @ 02:04 AM

  5. Repository
    Repository

    (from [cec44f58388755dec8d4e739e0a3bc3263a7fe3f]) 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
    http://github.com/rails/rails/commit/cec44f58388755dec8d4e739e0a3bc...

    April 24th, 2010 @ 11:03 PM

  6. Jeremy Kemper