diff options
author | Edouard CHIN <edouard.chin@shopify.com> | 2018-01-23 14:21:58 -0500 |
---|---|---|
committer | Edouard CHIN <edouard.chin@shopify.com> | 2018-01-23 14:21:58 -0500 |
commit | 1d04baafa6e79ec8892f9159784617dca8deea1e (patch) | |
tree | 673668afeeaacd9b0c4e46b3afcc687a127e029d /activerecord/lib | |
parent | 9a5b1fad630e4d35b64bb62b92c00e6cc79046d4 (diff) | |
download | rails-1d04baafa6e79ec8892f9159784617dca8deea1e.tar.gz rails-1d04baafa6e79ec8892f9159784617dca8deea1e.tar.bz2 rails-1d04baafa6e79ec8892f9159784617dca8deea1e.zip |
Allow a 2 bytes margin:
- mysql will add a 2 bytes margin to the statement, so given a `max_allowed_packet` set to 1024 bytes, a 1024 bytes fixtures will no be inserted (mysql will throw an error)
- Preventing this by decreasing the max_allowed_packet by 2 bytes when doing the comparison with the actual statement size
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 5e6ab1c16d..072a5337a5 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -568,7 +568,8 @@ module ActiveRecord end def max_allowed_packet - @max_allowed_packet ||= show_variable("max_allowed_packet") + bytes_margin = 2 + @max_allowed_packet ||= (show_variable("max_allowed_packet") - bytes_margin) end def with_multi_statements |