aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
Commit message (Collapse)AuthorAgeFilesLines
...
* | Remove our use of #outside_transaction?Jon Leighton2012-09-152-32/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This method was first seen in 045713ee240fff815edb5962b25d668512649478, and subsequently reimplemented in fb2325e35855d62abd2c76ce03feaa3ca7992e4f. According to @jeremy, this is okay to remove. He thinks it was added because at the time we didn't have much transaction state to keep track of, and he viewed it as a hack for us to track it internally, thinking it was better to ask the connection for the transaction state. Over the years we have added more and more state to track, a lot of which is impossible to ask the connection for. So it seems that this is just a relic of the passed and we will just track the state internally only.
* | Remove the transaction_open variableJon Leighton2012-09-151-21/+28
| |
* | Move transaction joinability into the transaction objectJon Leighton2012-09-153-17/+25
| |
* | Alter the naming structure a bitJon Leighton2012-09-153-108/+111
| |
* | Split Open into Real and SavepointJon Leighton2012-09-151-25/+38
| |
* | DRYJon Leighton2012-09-151-4/+8
| |
* | Don't do the rollback in #commitJon Leighton2012-09-152-18/+7
| | | | | | | | | | The caller needs to have knowledge of the rollback either way, so do it all in the caller (#transaction)
* | Store the transaction number in the transaction objectJon Leighton2012-09-154-11/+30
| | | | | | | | This avoids us having to manually increment and decrement it.
* | Start to tease out transaction handling into a state machineJon Leighton2012-09-153-79/+153
| |
* | Revert "create a transaction object and point AR objects at that object ↵Jon Leighton2012-09-152-25/+6
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | during a" This reverts commit c24c885209ac2334dc6f798c394a821ee270bec6. Here's the explanation I just sent to @tenderlove: Hey, I've been thinking about about the transaction memory leak thing that we were discussing. Example code: post = nil Post.transaction do N.times { post = Post.create } end Post.transaction is going to create a real transaction and there will also be a (savepoint) transaction inside each Post.create. In an idea world, we'd like all but the last Post instance to be GC'd, and for the last Post instance to receive its after_commit callback when Post.transaction returns. I can't see how this can work using your solution where the Post itself holds a reference to the transaction it is in; when Post.transaction returns, control does not switch to any of Post's instance methods, so it can't trigger the callbacks itself. What we really want is for the transaction itself to hold weak references to the objects within the transaction. So those objects can be GC'd, but if they are not GC'd then the transaction can iterate them and execute their callbacks. I've looked into WeakRef implementations that are available. On 1.9.3, the stdlib weakref library is broken and we shouldn't use it. There is a better implementation here: https://github.com/bdurand/ref/blob/master/lib/ref/weak_reference/pure_ruby.rb We could use that, either by pulling in the gem or just copying the code in, but it still suffers from the limitation that it uses ObjectSpace finalizers. In my testing, this finalizers make GC quite expensive: https://gist.github.com/3722432 Ruby 2.0 will have a native WeakRef implementation (via ObjectSpace::WeakMap), hence won't be reliant on finalizers: http://bugs.ruby-lang.org/issues/4168 So the ultimate solution will be for everyone to use Ruby 2.0, and for us to just use ObjectSpace::WeakMap. In the meantime, we have basically 3 options: The first is to leave it as it is. The second is to use a finalizer-based weakref implementation and take the GC perf hit. The final option is to store object ids rather than the actual objects. Then use ObjectSpace._id2ref to deference the objects at the end of the transaction, if they exist. This won't stop memory use growing within the transaction, but it'll grow more slowly. I benchmarked the performance of _id2ref this if the object does or does not exist: https://gist.github.com/3722550 If it does exist it seems decent, but it's hugely more expensive if it doesn't, probably because we have to do the rescue nil. Probably most of the time the objects will exist. However the point of doing this optimisation is to allow people to create a large number of objects inside a transaction and have them be GC'd. So for that use case, we'd be replacing one problem with another. I'm not sure which of the two problems is worse. My feeling is that we should just leave this for now and come back to it when Ruby 2.0 is out. I'm going to revert your commit because I can't see how it solves this. Hope you don't mind... if I've misunderstood then let me know! Jon
* update ConnectionAdaptar::Column#type_cast_code to be compatible with 3.2 branchThiago Pradi2012-09-131-1/+1
|
* Merge pull request #7521 from graceliu/fix_database_url_supportRafael Mendonça França2012-09-121-1/+1
|\ | | | | Fixed support for DATABASE_URL for rake db tasks
| * fixed support for DATABASE_URL for rake db tasksGrace Liu2012-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | - added tests to confirm establish_connection uses DATABASE_URL and Rails.env correctly even when no arguments are passed in. - updated rake db tasks to support DATABASE_URL, and added tests to confirm correct behavior for these rake tasks. (Removed establish_connection call from some tasks since in those cases the :environment task already made sure the function would be called) - updated Resolver so that when it resolves the database url, it removes hash values with empty strings from the config spec (e.g. to support connection to postgresql when no username is specified).
* | warning removed.Arun Agrawal2012-09-121-1/+0
|/ | | | | 1. Unused variable 2. possibly useless use of a variable in void context
* ConnectionPool, unify exceptions, ConnectionTimeoutErrorJonathan Rochkind2012-09-111-17/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As a result of different commits, ConnectionPool had become of two minds about exceptions, sometimes using PoolFullError and sometimes using ConnectionTimeoutError. In fact, it was using ConnectionTimeoutError internally, but then recueing and re-raising as a PoolFullError. There's no reason for this bifurcation, standardize on ConnectionTimeoutError, which is the rails2 name and still accurately describes semantics at this point. History In Rails2, ConnectionPool raises a ConnectionTimeoutError if it can't get a connection within timeout. Originally in master/rails3, @tenderlove had planned on removing wait/blocking in connectionpool entirely, at that point he changed exception to PoolFullError. But then later wait/blocking came back, but exception remained PoolFullError. Then in 02b233556377 pmahoney introduced fair waiting logic, and brought back ConnectionTimeoutError, introducing the weird bifurcation. ConnectionTimeoutError accurately describes semantics as of this point, and is backwards compat with rails2, there's no reason for PoolFullError to be introduced, and no reason for two different exception types to be used internally, no reason to rescue one and re-raise as another. Unify!
* Remove expired comment. This method is used from other place.kennyj2012-09-111-2/+0
|
* indent fix [ci skip]Vijay Dev2012-09-091-1/+1
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-09-091-1/+1
|\ | | | | | | | | Conflicts: activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
| * Fix a typoAndreas Loupasakis2012-09-061-1/+1
| |
| * Fix indenentation in comment to stop the end of comment from appearing in a ↵Anuj Dutta2012-09-031-1/+1
| | | | | | | | <pre> block.
* | Merge pull request #7545 from senny/7518_postgres_type_detectionAaron Patterson2012-09-071-1/+1
|\ \ | | | | | | postgres, map scaled intervals to string datatype
| * | postgres, map scaled intervals to string datatype (#7518)Yves Senn2012-09-061-1/+1
| | |
* | | create a transaction object and point AR objects at that object during aAaron Patterson2012-09-072-6/+25
|/ / | | | | | | transaction.
* | ActiveRecord support to PostgreSQL 9.2 JSON typeDickson S. Guedes2012-09-055-3/+44
| | | | | | | | | | | | | | | | | | This implements the support to encode/decode JSON data to/from database and creating columns of type JSON using a native type [1] supported by PostgreSQL from version 9.2. [1] http://www.postgresql.org/docs/9.2/static/datatype-json.html
* | Merge pull request #7337 from adzap/string_to_dummy_timeRafael Mendonça França2012-09-051-1/+7
|\ \ | | | | | | Fix for time type columns with invalid time value
| * | Fix for time type columns with invalid timeAdam Meehan2012-09-051-1/+7
| |/ | | | | | | | | | | The string_to_dummy_time method was blindly parsing the dummy time string with Date._parse which returns a hash for the date part regardless of whether the time part is an invalid time string.
* / Modularize postgresql adapterKonstantin Shabanov2012-09-056-985/+1038
|/
* Cache the connection pool for a given classJon Leighton2012-08-311-20/+35
|
* One hash is enoughJon Leighton2012-08-311-17/+13
| | | | We don't need separate @class_to_pool and @connection_pool hashes.
* Refactor connection handlerJon Leighton2012-08-311-22/+14
|
* Make connection pool retrieval fasterJon Leighton2012-08-311-10/+13
| | | | | | * Loop rather than recurse in retrieve_connection_pool * Key the hash by class rather than class name. This avoids creating unnecessary strings.
* use Hash#fetch to eliminate conditionalAaron Patterson2012-08-241-8/+3
|
* Refactor AR::Result or inherits. Because we have redundant codes aboutkennyj2012-08-222-16/+2
|
* This method is useless without a block, so remove testAaron Patterson2012-08-201-11/+9
|
* remove unused variableAaron Patterson2012-08-201-1/+1
|
* initialize instance variables to avoid conditionalsAaron Patterson2012-08-201-2/+7
|
* column default extraction should handle newlines.Aaron Patterson2012-08-171-2/+2
| | | | Fixes #7374
* Fix occasional microsecond conversion inaccuracyAri Pollak2012-08-151-2/+2
| | | | | | | | | ActiveRecord::ConnectionAdapters::Column#microseconds did an unnecessary conversion to from Rational to float when calculating the integer number of microseconds. Some terminating decimal numbers in base10 are repeating decimal numbers in base2 (the format of float), and occasionally this causes a rounding error. Patch & explanation originally from Logan Bowers.
* load active_support/deprecation in active_support/railsXavier Noria2012-08-023-3/+0
|
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-023-3/+0
|
* Deprecate Relation#all.Jon Leighton2012-07-271-1/+1
| | | | | | It has been moved to active_record_deprecated_finders. Use #to_a instead.
* Merge pull request #6654 from stevecj/postgresql-auto-reconnect-2Aaron Patterson2012-07-251-1/+2
|\ | | | | Postgresql auto reconnect 2
| * Simulated & actual (manual/skipped) PostgreSQL auto-reconnection tests.Steve Jorgensen2012-07-161-0/+1
| |
| * Don't crash exception translation w/ nil result attribute.Steve Jorgensen2012-07-161-1/+1
| | | | | | | | | | | | Exception.result is nil when attempting a query after PostgreSQL disconnect, resulting in new exception: NoMethodError: undefined method `error_field' for nil:NilClass
* | Add fkey attributes to `join_table` migration generatorAleksey Magusev2012-07-191-3/+3
| |
* | revert Default timestamps to non-nullDave Kroondyk2012-07-181-1/+1
| | | | | | | | | | | | | | Commit 3dbedd2 added NOT NULL constraints to timestamps. Commit fcef728 started to revert this, but was incomplete. With this commit, 3dbedd2 should be fully reverted and timestamps will no longer default to NOT NULL.
* | Merge pull request #7028 from lexmag/join_table_indexesJosé Valim2012-07-181-2/+5
|\ \ | |/ |/| Add indexes to create_join_table method
| * Add join table migration generatorAleksey Magusev2012-07-181-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | For instance, running rails g migration CreateMediaJoinTable artists musics:uniq will create a migration with create_join_table :artists, :musics do |t| # t.index [:artist_id, :music_id] t.index [:music_id, :artist_id], unique: true end
* | teaching the mysql adapter how to typecast strings returned from the databaseAaron Patterson2012-07-131-2/+132
| |
* | Fixing texts; down to three failing tests.Jeremy Cole2012-07-132-15/+24
| | | | | | | | | | Conflicts: activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb