aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract
Commit message (Collapse)AuthorAgeFilesLines
* These are already required through AS/railsAkira Matsuda2013-01-071-1/+0
| | | | | | * dependencies/autoload * concern * deprecation
* Fix calling quote column name in interpolated stringCarlos Antonio da Silva2012-12-211-1/+1
|
* Differentiate between remove_column and remove_columns. Make remove_column ↵Marc-Andre Lafortune2012-12-212-7/+20
| | | | | | reversible. [#8267]
* Make drop_table reversible [#8267]Marc-Andre Lafortune2012-12-211-0/+4
|
* Add drop_join_table [#8267]Marc-Andre Lafortune2012-12-211-0/+11
|
* Simplify change_table and avoid duplicated logicMarc-Andre Lafortune2012-12-211-14/+2
|
* Replace some global Hash usages with the new thread safe cache.thedarkone2012-12-141-9/+16
| | | | | | | | | | | | | | | | Summary of the changes: * Add thread_safe gem. * Use thread safe cache for digestor caching. * Replace manual synchronization with ThreadSafe::Cache in Relation::Delegation. * Replace @attribute_method_matchers_cache Hash with ThreadSafe::Cache. * Use TS::Cache to avoid the synchronisation overhead on listener retrieval. * Replace synchronisation with TS::Cache usage. * Use a preallocated array for performance/memory reasons. * Update the controllers cache to the new AS::Dependencies::ClassCache API. The original @controllers cache no longer makes much sense after @tenderlove's changes in 7b6bfe84f3 and f345e2380c. * Use TS::Cache in the connection pool to avoid locking overhead. * Use TS::Cache in ConnectionHandler.
* Move to the schema-migrations-metadata branch.Jeremy Kemper2012-12-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | Pending work on graceful app upgrades. Revert "Merge pull request #8439 from joshsusser/fixes" This reverts commit ce8ac39338f86388e70356b3a470b3ea443802ae, reversing changes made to b0e7b6f67c984d4b1502e801781ed75fad681633. Revert "Merge pull request #8431 from joshsusser/schemadump" This reverts commit 036d3e1c2b65c4b8cbd23de2e20ad67b9b756182, reversing changes made to 0c692f4d121792117b6a71e5ed590a31c3b9d12e. Revert "Merge branch 'joshsusser-master' into merge" This reverts commit 0c692f4d121792117b6a71e5ed590a31c3b9d12e, reversing changes made to 2e299fca715b083a60222a85e48f9d3b8dd8ce93. Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb activerecord/test/cases/schema_dumper_test.rb
* revises a RDoc example to make it idiomaticXavier Noria2012-12-071-8/+8
| | | | | | The force flag suggests the original was probably copied from some db/schema.rb. Thanks to Josh Susser for spotting and reporting this.
* Use CURRENT_TIMESTAMP since it has apparently better cross db supportCarlos Antonio da Silva2012-12-061-1/+1
| | | | | LOCALTIMESTAMP is not support by sqlite3, and travis was giving us these errors: https://travis-ci.org/rails/rails/jobs/3535241/#L570
* Add migration history to schema.rb dumpJosh Susser2012-12-021-2/+2
|
* Add metadata to schema_migrationsJosh Susser2012-12-011-3/+3
| | | | | migrated_at: timestamp when migration run fingerprint: md5 hash of migration source name: filename without version or extension
* Fix memory leak in development modeJon Leighton2012-11-301-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keying these hashes by klass causes reloadable classes to never get freed. Thanks to @thedarkone for pointing this out in the comments on 221571beb6b4bb7437989bdefaf421f993ab6002. This doesn't seem to make a massive difference to performance. Benchmark --------- require 'active_record' require 'benchmark/ips' class Post < ActiveRecord::Base establish_connection adapter: 'sqlite3', database: ':memory:' end GC.disable Benchmark.ips(20) do |r| r.report { Post.connection } end Before ------ Calculating ------------------------------------- 5632 i/100ms ------------------------------------------------- 218671.0 (±1.9%) i/s - 4364800 in 19.969401s After ----- Calculating ------------------------------------- 8743 i/100ms ------------------------------------------------- 206525.9 (±17.8%) i/s - 4039266 in 19.992590s
* schema cache already has the columns as a hash, so use thatAaron Patterson2012-11-251-1/+1
|
* speed up fixture loading by querying the schema cache for column namesAaron Patterson2012-11-251-1/+1
|
* TypoChris Patuzzo2012-11-211-1/+1
|
* Add rename_index to change_table.Jarek Radosz2012-11-191-0/+8
|
* Properly deprecate ConnectionHandler#connection_poolsJon Leighton2012-11-091-6/+14
| | | | | | | | Rather than just changing it and hoping for the best. Requested by @jeremy: https://github.com/rails/rails/commit/ba1544d71628abff2777c9c514142d7e9a159111#commitcomment-2106059
* Check if the options value is present before to send the deprecationRafael Mendonça França2012-11-031-4/+6
| | | | message
* Remove old commentRafael Mendonça França2012-11-021-1/+1
| | | | | | | | | | | | | | | This comment is not valid since that `if` is there to make possible to do: remove_index :users, :name Instead of: remove_index :users, column: :name What is a valid use case. [ci skip]
* Deprecate passing a string as third argument of `add_index`Rafael Mendonça França2012-11-021-0/+6
| | | | | | | This was there due historical reasons since 7dc45818dc43c163700efc9896a0f3feafa31138 to give the user the possibility to create unique indexes passing "UNIQUE" as the third argument
* Raise an ArgumentError when passing an invalid option to add_indexRafael Mendonça França2012-11-021-1/+4
| | | | Closes #8104
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-11-033-46/+46
|\ | | | | | | | | | | | | Conflicts: actionpack/lib/action_controller/metal/mime_responds.rb activerecord/lib/active_record/attribute_methods.rb guides/source/working_with_javascript_in_rails.md
| * Migration of docs to 1.9 hash syntaxAvnerCohen2012-10-233-46/+46
| |
* | raise `ArgumentError` when redefining the primary key column. Closes #6378Yves Senn2012-10-281-0/+9
| |
* | Remove ActiveRecord::ModelJon Leighton2012-10-261-4/+4
|/ | | | | | | | | | In the end I think the pain of implementing this seamlessly was not worth the gain provided. The intention was that it would allow plain ruby objects that might not live in your main application to be subclassed and have persistence mixed in. But I've decided that the benefit of doing that is not worth the amount of complexity that the implementation introduced.
* Support for partial inserts.Jon Leighton2012-09-281-1/+1
| | | | | | | | | | | When inserting new records, only the fields which have been changed from the defaults will actually be included in the INSERT statement. The other fields will be populated by the database. This is more efficient, and also means that it will be safe to remove database columns without getting subsequent errors in running app processes (so long as the code in those processes doesn't contain any references to the removed column).
* Support for specifying transaction isolation levelJon Leighton2012-09-212-15/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If your database supports setting the isolation level for a transaction, you can set it like so: Post.transaction(isolation: :serializable) do # ... end Valid isolation levels are: * `:read_uncommitted` * `:read_committed` * `:repeatable_read` * `:serializable` You should consult the documentation for your database to understand the semantics of these different levels: * http://www.postgresql.org/docs/9.1/static/transaction-iso.html * https://dev.mysql.com/doc/refman/5.0/en/set-transaction.html An `ActiveRecord::TransactionIsolationError` will be raised if: * The adapter does not support setting the isolation level * You are joining an existing open transaction * You are creating a nested (savepoint) transaction The mysql, mysql2 and postgresql adapters support setting the transaction isolation level. However, support is disabled for mysql versions below 5, because they are affected by a bug (http://bugs.mysql.com/bug.php?id=39170) which means the isolation level gets persisted outside the transaction.
* rename AR::Model::Tag to AR::Tag - fixes #7714Francesco Rodriguez2012-09-201-3/+3
|
* Merge pull request #7547 from danmcclain/pg-arraysRafael Mendonça França2012-09-161-0/+56
|\ | | | | Adds migration and type casting support for PostgreSQL Array datatype
| * Moves column dump specific code to a module included in AbstractAdapterDan McClain2012-09-141-0/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having column related schema dumper code in the AbstractAdapter. The code remains the same, but by placing it in the AbstractAdapter, we can then overwrite it with Adapter specific methods that will help with Adapter specific data types. The goal of moving this code here is to create a new migration key for PostgreSQL's array type. Since any datatype can be an array, the goal is to have ':array => true' as a migration option, turning the datatype into an array. I've implemented this in postgres_ext, the syntax is shown here: https://github.com/dockyard/postgres_ext#arrays Adds array migration support Adds array_test.rb outlining the test cases for array data type Adds pg_array_parser to Gemfile for testing Adds pg_array_parser to postgresql_adapter (unused in this commit) Adds schema dump support for arrays Adds postgres array type casting support Updates changelog, adds note for inet and cidr support, which I forgot to add before Removing debugger, Adds pg_array_parser to JRuby platform Removes pg_array_parser requirement, creates ArrayParser module used by PostgreSQLAdapter
* | simplify rescueJon Leighton2012-09-151-3/+3
| |
* | Fix testJon Leighton2012-09-151-13/+19
| | | | | | | | Accidentally checked in commented test code. Fail. >_<
* | Remove our use of #outside_transaction?Jon Leighton2012-09-151-32/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-152-14/+21
| |
* | Alter the naming structure a bitJon Leighton2012-09-152-107/+105
| |
* | 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-152-6/+24
| | | | | | | | This avoids us having to manually increment and decrement it.
* | Start to tease out transaction handling into a state machineJon Leighton2012-09-152-79/+152
| |
* | Revert "create a transaction object and point AR objects at that object ↵Jon Leighton2012-09-151-5/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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!
* 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
| |
* | create a transaction object and point AR objects at that object during aAaron Patterson2012-09-071-3/+5
|/ | | | transaction.
* 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.