Commit message (Collapse) | Author | Age | Files | Lines | ||
---|---|---|---|---|---|---|
... | ||||||
* | Only use prepared statements when bind variables are present | Jeremy Cole | 2012-07-13 | 1 | -34/+40 | |
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prepared statements (prepare/execute/close) were being used unnecessarily when no bind variables were present, and disabling prepared statement using prepared_statements:false was principally broken. While bind variables were correctly substituted with prepared_statements:false, the prepared statement interface was still used, costing an extra two round trips per query. In addition to making this behavioral change, I also cleaned up the internals of exec_stmt and exec_without_stmt so that they behave the same (calling log and constructing the ActiveRecord::Result in the same way). Moving the check for binds.empty? to exec_query also will mean that several code paths explicitly calling exec_without_stmt could be cleaned up to once again call exec_query instead. I have also left the check for binds.empty? in exec_stmt, since it is not a private method and could be called directly with an empty binds array. For the sake of clarity in this patch, I have not made those changes. = The previous behavior = When issuing a Foo.find(1) with prepared_statements:true, the bind variable is present in the prepared query, and execute shows a value passed: Connect root@localhost on rails_test Query SET SQL_AUTO_IS_NULL=0 Statistics Query SHOW FULL FIELDS FROM `foos` Query SHOW TABLES LIKE 'foos' Query SHOW CREATE TABLE `foos` Prepare SELECT `foos`.* FROM `foos` WHERE `foos`.`id` = ? LIMIT 1 Execute SELECT `foos`.* FROM `foos` WHERE `foos`.`id` = 1 LIMIT 1 Close stmt Quit When issuing a Foo.find(1) with prepared_statements:false, the bind variable has already been removed and substituted with the value, but the prepared statement interface is used anyway: Connect root@localhost on rails_test Query SET SQL_AUTO_IS_NULL=0 Statistics Query SHOW FULL FIELDS FROM `foos` Query SHOW TABLES LIKE 'foos' Query SHOW CREATE TABLE `foos` Prepare SELECT `foos`.* FROM `foos` WHERE `foos`.`id` = 1 LIMIT 1 Execute SELECT `foos`.* FROM `foos` WHERE `foos`.`id` = 1 LIMIT 1 Close stmt Quit = With this patch applied = When issuing a Foo.find(1) with prepared_statements:true, the bind variable is present in the prepared query, and execute shows a value passed: Connect root@localhost on rails_test Query SET SQL_AUTO_IS_NULL=0 Statistics Query SHOW FULL FIELDS FROM `foos` Query SHOW TABLES LIKE 'foos' Query SHOW CREATE TABLE `foos` Prepare SELECT `foos`.* FROM `foos` WHERE `foos`.`id` = ? LIMIT 1 Execute SELECT `foos`.* FROM `foos` WHERE `foos`.`id` = 1 LIMIT 1 Close stmt Quit When issuing a Foo.find(1) with prepared_statements:false, the bind variable has been removed and substituted with the value, and the query interface is used instead of the prepared statement interface: Connect root@localhost on rails_test Query SET SQL_AUTO_IS_NULL=0 Statistics Query SHOW FULL FIELDS FROM `foos` Query SHOW TABLES LIKE 'foos' Query SHOW CREATE TABLE `foos` Query SELECT `foos`.* FROM `foos` WHERE `foos`.`id` = 1 LIMIT 1 Quit | |||||
* | Add config option, rdoc, tests for mysql(2) STRICT_ALL_TABLES mode. | Michael Pearson | 2012-05-05 | 1 | -2/+5 | |
| | ||||||
* | Default to 'strict mode' in MySQL | Michael Pearson | 2012-05-05 | 1 | -0/+5 | |
| | ||||||
* | use Process.pid rather than $$ | Aaron Patterson | 2012-02-16 | 1 | -1/+1 | |
| | ||||||
* | made the result set object act more like an array | Aaron Patterson | 2012-01-31 | 1 | -1/+1 | |
| | ||||||
* | Support establishing connection on ActiveRecord::Model. | Jon Leighton | 2011-12-28 | 1 | -1/+1 | |
| | | | | | This is the 'top level' connection, inherited by any models that include ActiveRecord::Model or inherit from ActiveRecord::Base. | |||||
* | remove checks for encodings availability | Sergey Nartimov | 2011-12-25 | 1 | -46/+42 | |
| | ||||||
* | I herd you like modules. | Jon Leighton | 2011-12-24 | 1 | -2/+2 | |
| | ||||||
* | Only use LOWER for mysql case insensitive uniqueness check when column has a ↵ | Joseph Palermo | 2011-10-09 | 1 | -2/+2 | |
| | | | | case sensitive collation. | |||||
* | LRU cache in mysql and sqlite are now per-process caches. | Aaron Patterson | 2011-09-07 | 1 | -11/+16 | |
| | ||||||
* | Database adapters use a statement pool. | Aaron Patterson | 2011-09-06 | 1 | -1/+2 | |
| | | | | | | Database adapters use a statement pool for limiting the number of open prepared statments on the database. The limit defaults to 1000, but can be adjusted in your database config by changing 'statement_limit'. | |||||
* | adding a statement pool for mysql and sqlite3 | Aaron Patterson | 2011-09-06 | 1 | -4/+29 | |
| | ||||||
* | Move the bulk alter table code into the abstract mysql adapter, hence it is ↵ | Jon Leighton | 2011-08-29 | 1 | -47/+0 | |
| | | | | supported for mysql2 as well now. | |||||
* | Extract simplified_type into the abstract class | Jon Leighton | 2011-08-29 | 1 | -7/+3 | |
| | ||||||
* | Create an AbstractMysqlAdapter to abstract the common code between ↵ | Jon Leighton | 2011-08-29 | 1 | -569/+98 | |
| | | | | MysqlAdapter and Mysql2Adapter. | |||||
* | prevent sql injection attacks by escaping quotes in column names | Aaron Patterson | 2011-08-16 | 1 | -1/+1 | |
| | ||||||
* | Use new SelectManager#source method | Jon Leighton | 2011-08-15 | 1 | -1/+1 | |
| | ||||||
* | Use new SelectManager#projections= method | Jon Leighton | 2011-08-15 | 1 | -1/+1 | |
| | ||||||
* | use update.key instead of update.ast.key. make better use of select manager. | Jon Leighton | 2011-08-15 | 1 | -12/+8 | |
| | ||||||
* | Use a SelectCore rather than a full SelectManager | Jon Leighton | 2011-08-15 | 1 | -2/+3 | |
| | ||||||
* | Refactor building the update manager | Jon Leighton | 2011-08-15 | 1 | -3/+2 | |
| | ||||||
* | Support for multi-table updates with limits, offsets and orders | Jon Leighton | 2011-08-15 | 1 | -1/+22 | |
| | ||||||
* | Support updates with joins. Fixes #522. | Jon Leighton | 2011-08-15 | 1 | -0/+4 | |
| | ||||||
* | Make it the responsibility of the connection to hold onto an ARel visitor ↵ | Jon Leighton | 2011-08-08 | 1 | -0/+4 | |
| | | | | for generating SQL. This improves the code architecture generally, and solves some problems with marshalling. Adapter authors please take note: you now need to define an Adapter.visitor_for method, but it degrades gracefully with a deprecation warning for now. | |||||
* | Remove unused 'quoted_column_names' variable. | Sebastian Martinez | 2011-06-08 | 1 | -1/+1 | |
| | ||||||
* | No need to override for just calling super | Akira Matsuda | 2011-05-29 | 1 | -4/+0 | |
| | ||||||
* | Merge branch 'master' of github.com:rails/rails | Xavier Noria | 2011-05-25 | 1 | -18/+0 | |
|\ | ||||||
| * | removed deprecated methods, and related tests, from ActiveRecord | Josh Kalderimis | 2011-05-25 | 1 | -18/+0 | |
| | | ||||||
* | | Merge branch 'master' of git://github.com/lifo/docrails | Xavier Noria | 2011-05-25 | 1 | -2/+2 | |
|\ \ | |/ |/| | | | | | | | Conflicts: actionmailer/lib/action_mailer/base.rb activesupport/lib/active_support/core_ext/kernel/requires.rb | |||||
| * | Remove extra white spaces on ActiveRecord docs. | Sebastian Martinez | 2011-05-23 | 1 | -2/+2 | |
| | | ||||||
* | | Remove extra white-space on some exception messages. | Sebastian Martinez | 2011-05-23 | 1 | -1/+1 | |
| | | ||||||
* | | Removed AS core_ext/kernel/requires as it's not used and is bad practice. | Josh Kalderimis | 2011-05-23 | 1 | -1/+0 | |
|/ | ||||||
* | Merge branch 'master' of git://github.com/lifo/docrails | Xavier Noria | 2011-05-04 | 1 | -0/+2 | |
|\ | ||||||
| * | Added #recreate_database docs | Sebastian Martinez | 2011-05-03 | 1 | -0/+2 | |
| | | ||||||
* | | favor collect over each in mysql* adapters | Josh Kalderimis | 2011-05-03 | 1 | -4/+2 | |
|/ | ||||||
* | Merge branch 'master' of git://github.com/lifo/docrails | Xavier Noria | 2011-05-01 | 1 | -2/+10 | |
|\ | | | | | | | | | Conflicts: railties/guides/source/contributing_to_ruby_on_rails.textile | |||||
| * | Merge branch 'master' of github.com:lifo/docrails | Dan Pickett | 2011-04-29 | 1 | -2/+10 | |
| |\ | ||||||
| | * | Added docs for #version on mysql_adapter | Sebastian Martinez | 2011-04-22 | 1 | -0/+1 | |
| | | | ||||||
| | * | Make this docs more consistent with the rest of the docs present | Sebastian Martinez | 2011-04-22 | 1 | -2/+3 | |
| | | | ||||||
| | * | Added docs for #rename_table on some adapters | Sebastian Martinez | 2011-04-22 | 1 | -0/+4 | |
| | | | ||||||
| | * | Added docs for #columns on some adapters | Sebastian Martinez | 2011-04-22 | 1 | -0/+1 | |
| | | | ||||||
| | * | Merge branch 'master' of git://github.com/rails/rails | Xavier Noria | 2011-04-23 | 1 | -4/+0 | |
| | |\ | ||||||
| | * | | Added docs for #indexes on adapters | Sebastian Martinez | 2011-04-22 | 1 | -0/+1 | |
| | | | | ||||||
* | | | | using bind parameters for updates | Aaron Patterson | 2011-04-30 | 1 | -0/+1 | |
|/ / / | ||||||
* | | | lean on rubygems to provide error messages about missing gems | Aaron Patterson | 2011-04-29 | 1 | -9/+2 | |
| | | | ||||||
* | | | refactor exec_delete to reuse the statement cache from exec_query | Aaron Patterson | 2011-04-29 | 1 | -70/+44 | |
| | | | ||||||
* | | | statement cache for deletes working on mysql | Aaron Patterson | 2011-04-29 | 1 | -0/+39 | |
| | | | ||||||
* | | | clearing statement from cache on exception in order to support older ↵ | Aaron Patterson | 2011-04-28 | 1 | -3/+13 | |
| |/ |/| | | | | | versions of mysql | |||||
* | | Merge branch 'master' of git://github.com/lifo/docrails | Xavier Noria | 2011-04-23 | 1 | -2/+11 | |
|\| | | | | | | | | | Conflicts: activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | |||||
| * | copy-edits 0e2644c | Xavier Noria | 2011-04-23 | 1 | -1/+1 | |
| | |