aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
Commit message (Collapse)AuthorAgeFilesLines
* Append sql_mode instead of overwriting in strict modeRyuta Kamizono2016-03-131-3/+12
| | | | For keep the default SQL mode.
* Merge pull request #23797 from ↵Rafael França2016-03-111-3/+3
|\ | | | | | | | | kamipo/case_sensitive_comparison_for_non_string_column The BINARY Operator is only needed for string columns
| * The BINARY Operator is only needed for string columnsRyuta Kamizono2016-02-221-3/+3
| | | | | | | | Follow up to #13040.
* | Passing `table_name` to `Column#initialize` to avoid `instance_variable_set`Ryuta Kamizono2016-03-081-5/+3
| |
* | Initialize `column.table_name` immediately for `column.serial?` correctly ↵Ryuta Kamizono2016-03-081-9/+16
| | | | | | | | | | | | | | | | working Currently the results of `column.serial?` is not correct. For `column.serial?` correctly working, initialize `column.table_name` immediately.
* | No need to extract a limit for a boolean typeRyuta Kamizono2016-03-041-1/+1
|/
* Remove needless `case_insensitive_comparison` in mysql2 adapterRyuta Kamizono2016-02-171-6/+3
| | | | Simply it is sufficient to override `can_perform_case_insensitive_comparison_for?`.
* Active Record supports MySQL >= 5.0Ryuta Kamizono2016-02-041-10/+7
| | | | | Currently some features uses `information_schema` (e.g. foreign key support). `information_schema` introduced since MySQL 5.0.
* Avoid extra `show variables` in migrationRyuta Kamizono2016-02-011-7/+5
| | | | | | | | | | | | | `initialize_schema_migrations_table` is called in every migrations. https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/migration.rb#L1080 https://github.com/rails/rails/blob/v5.0.0.beta1/activerecord/lib/active_record/schema.rb#L51 This means that extra `show variables` is called regardless of the existence of `schema_migrations` table. This change is to avoid extra `show variables` if `schema_migrations` table exists.
* Extract `ExplainPrettyPrinter` to appropriate filesRyuta Kamizono2016-02-011-66/+2
|
* Remove unused `LOST_CONNECTION_ERROR_MESSAGES`Ryuta Kamizono2016-01-311-6/+0
| | | | | `LOST_CONNECTION_ERROR_MESSAGES` was added by f384582. But currently unused from anywhere.
* Remove `limit: 11` as backward-compatibility with Rails 2.0Ryuta Kamizono2016-01-271-1/+0
| | | | | | | Integer limit as a byte size was introduced from Rails 2.1. `limit: 11` is not a byte size, but take care for backward-compatibility with Rails 2.0 (a892af6). Integer limit out of range should be allowed to raise by #6349. I think we should remove this backward-compatibility.
* Fix extract default with CURRENT_TIMESTUMPRyuta Kamizono2016-01-131-2/+6
|
* Extract `MySQL::TypeMetadata` class to ↵Ryuta Kamizono2016-01-111-28/+2
| | | | `connection_adapters/mysql/type_metadata.rb`
* Extract `MySQL::Column` class to `connection_adapters/mysql/column.rb`Ryuta Kamizono2016-01-111-46/+2
|
* Merge pull request #22967 from schneems/schneems/generic-metadataSean Griffin2016-01-081-0/+1
|\ | | | | Prevent destructive action on production database
| * [ci skip] Add comment to remove silenced code.schneems2016-01-071-0/+1
| |
* | `{update|delete}_sql` are almost the same as `{update|delete}`Ryuta Kamizono2016-01-081-5/+0
| | | | | | | | Simply `{update|delete}_sql` aliases to `{update|delete}`.
* | Fix `unsigned?` and `blob_or_text_column?` for Enum columns in MySQLRyuta Kamizono2016-01-041-3/+3
| |
* | Refactor `case_{sensitive|insensitive}_comparison`Ryuta Kamizono2016-01-011-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ``` SELECT 1 AS one FROM "topics" WHERE "topics"."title" = 'abc' LIMIT $1 [["LIMIT", 1]] ``` After: ``` SELECT 1 AS one FROM "topics" WHERE "topics"."title" = $1 LIMIT $2 [["title", "abc"], ["LIMIT", 1]] ```
* | Merge pull request #22241 from kamipo/add_columns_for_distinct_for_mysql57Rafael França2015-12-301-3/+20
|\ \ | | | | | | Add `columns_for_distinct` for MySQL 5.7 with ONLY_FULL_GROUP_BY
| * | Add `columns_for_distinct` for MySQL 5.7 with ONLY_FULL_GROUP_BYRyuta Kamizono2015-12-231-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | In MySQL 5.7.5 and up, ONLY_FULL_GROUP_BY affects handling of queries that use DISTINCT and ORDER BY. It requires the ORDER BY columns in the select list for distinct queries, and requires that the ORDER BY include the distinct column. See https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html
| * | Avoid `distinct` if a subquery has already materializedRyuta Kamizono2015-12-231-3/+5
| | | | | | | | | | | | Follow up to #19359 and avoid #22241.
* | | Merge pull request #22547 from kamipo/fix_create_table_info_cacheRafael França2015-12-291-2/+6
|\ \ \ | | | | | | | | Correctly cache create_table_info
| * | | Correctly cache create_table_infoRyuta Kamizono2015-12-171-2/+6
| | |/ | |/| | | | | | | Follow up to #21664.
* | | Fix varbinary with default ''Ryuta Kamizono2015-12-241-13/+0
| | | | | | | | | | | | | | | | | | | | | A `(?:var)?binary` with default '' is a correct definition. Remove `missing_default_forged_as_empty_string?` method for fixing this issue because this method is a workaround for older mysql legacy adapter (19c99ac, f7015336).
* | | Merge pull request #22620 from kamipo/join_to_delete_is_same_as_join_to_updateRafael França2015-12-221-1/+1
|\ \ \ | | | | | | | | `join_to_delete` is same as `join_to_update`
| * | | `join_to_delete` is same as `join_to_update`Ryuta Kamizono2015-12-171-1/+1
| | | | | | | | | | | | | | | | Reapply #22615.
* | | | Remove legacy mysql adapterRyuta Kamizono2015-12-211-7/+6
| | | | | | | | | | | | | | | | Follow up to #22642.
* | | | mysql2 adapter instead of mysql [ci skip]Rajarshi Das2015-12-201-2/+2
| |_|/ |/| |
* | | Remove legacy mysql adapterAbdelkader Boudih2015-12-171-3/+0
|/ /
* | Revert "Merge pull request #22615 from ↵Rafael Mendonça França2015-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | kamipo/join_to_delete_is_same_as_join_to_update" This reverts commit 4d06ea9a829de8f6f5a345589828e182eacab6a3, reversing changes made to e9d15072a94e2ae4dec5b7a121c84a5db38547b8. Reason: This will break oracle-enhanced, see https://github.com/rsim/oracle-enhanced/blob/3c42131db82b64ac41645db3affc6e4650289df6/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb#L1254
* | `join_to_delete` is same as `join_to_update`Ryuta Kamizono2015-12-171-1/+1
|/
* Refactor `AbstractAdapter#initialize`Ryuta Kamizono2015-11-301-2/+1
| | | | `pool` in args is unused anymore. And `config` is used in all adapters.
* `connection_options` is only needed for `MysqlAdapter`Ryuta Kamizono2015-11-291-1/+1
| | | | Not needed for `Mysql2Adapter` and `AbstractMysqlAdapter`.
* Revert "Add prepared statements support for `Mysql2Adapter`"Sean Griffin2015-11-261-45/+3
|
* Add prepared statements support for `Mysql2Adapter`Ryuta Kamizono2015-11-261-3/+45
|
* Merge pull request #22214 from ↵Rafael França2015-11-241-1/+1
|\ | | | | | | | | kamipo/not_passing_native_database_types_to_table_definition Not passing `native_database_types` to `TableDefinition`
| * Not passing `native_database_types` to `TableDefinition`Ryuta Kamizono2015-11-081-1/+1
| | | | | | | | | | | | The `native_database_types` only used in `TableDefinition` for look up the default `:limit` option. But this is duplicated process with `type_to_sql`. Passing `native_database_types` is not needed.
* | `set_field_encoding` is only needed for `MysqlAdapter`Ryuta Kamizono2015-11-241-4/+2
| | | | | | | | Not needed for `Mysql2Adapter` and `AbstractMysqlAdapter`.
* | Revert "Allow specifying the default table options for mysql adapters"Sean Griffin2015-11-191-2/+1
| | | | | | | | | | | | | | This reverts commit 8246b593bff71f2cebf274c133bb8917f1e094c8. There was concern about this modifying the behavior of past migrations. We're going to add an way to modify the migration generator instead.
* | Allow specifying the default table options for mysql adaptersSean Griffin2015-11-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | It's often the case that you want to have an option that you cannot specify at the database level, but want applied to *all* tables that you create. For example, you might want to specify `ROW_FORMAT=DYNAMIC` to not have to limit text columns to length 171 for indexing when using utf8mb4. This allows an easy way to specify this in your database configuration. While this change affects both MySQL and MySQL2, the test only covers MySQL2, as the legacy mysql adapter appears to always return ASCII strings, and is tangential to what we're actually doing.
* | Rename 'key' to 'lock_id' or 'lock_name' for advisory lockingSam Davies2015-11-181-4/+4
| | | | | | | | | | | | | | | | | | - key was a poor choice of name. A key implies something that will unlock a lock. The concept is actually more like a 'lock identifier' - mysql documentation calls this a 'lock name' - postgres documentation calls it a 'lock_id' - Updated variable names to reflect the preferred terminology for the database in question
* | Remove not needed `NATIVE_DATABASE_TYPES` entriesRyuta Kamizono2015-11-161-2/+0
| |
* | Deprecate `#table_exists?`, `#tables` and passing arguments to `#talbes`yui-knk2015-11-091-2/+26
|/ | | | | | | | | | Reported on #21509, how views is treated by `#tables` are differ by each adapters. To fix this different behavior, after Rails 5.0 is released, deprecate `#tables`. And `#table_exists?` would check both tables and views. To make their behavior consistent with `#tables`, after Rails 5.0 is released, deprecate `#table_exists?`.
* Deprecate exception#original_exception in favor of exception#causeYuki Nishijima2015-11-031-2/+2
|
* Use advisory locks to prevent concurrent migrationsSam Davies2015-10-301-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Addresses issue #22092 - Works on Postgres and MySQL - Uses advisory locks because of two important properties: 1. The can be obtained outside of the context of a transaction 2. They are automatically released when the session ends, so if a migration process crashed for whatever reason the lock is not left open perpetually - Adds get_advisory_lock and release_advisory_lock methods to database adapters - Attempting to run a migration while another one is in process will raise a ConcurrentMigrationError instead of attempting to run in parallel with undefined behavior. This could be rescued and the migration could exit cleanly instead. Perhaps as a configuration option? Technical Notes ============== The Migrator uses generate_migrator_advisory_lock_key to build the key for the lock. In order to be compatible across multiple adapters there are some constraints on this key. - Postgres limits us to 64 bit signed integers - MySQL advisory locks are server-wide so we have to scope to the database - To fulfil these requirements we use a Migrator salt (a randomly chosen signed integer with max length of 31 bits) that identifies the Rails migration process as the owner of the lock. We multiply this salt with a CRC32 unsigned integer hash of the database name to get a signed 64 bit integer that can also be converted to a string to act as a lock key in MySQL databases. - It is important for subsequent versions of the Migrator to use the same salt, otherwise different versions of the Migrator will not see each other's locks.
* Remove `#tables` extra args againRyuta Kamizono2015-10-221-8/+3
| | | | | | This issue was resolved by #21687 already. But re-add args by #18856. `#tables` extra args was only using by `#table_exists?`. This is for internal API. This commit will remove these extra args again.
* Fix merge conflicts for #18856Sean Griffin2015-10-201-2/+10
|\
| * Match table names exactly on MySQLMatt Jones2015-02-081-3/+5
| | | | | | | | | | | | | | | | The `SHOW TABLES LIKE` command accepts metacharacters `%` and `_` in potentially unexpected ways. This can be avoided by querying `information_schema.tables` directly. Fixes #17897