diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-17 06:06:21 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-17 09:37:08 +0900 |
commit | 0ad70eb2d063cab577a559f6c3d28e787ca1dca8 (patch) | |
tree | da8193ff9d12a38c826250a50fc98844bf0eb0e0 /activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | |
parent | 8ed636511779ed1472f4f88362ded34f61005f4a (diff) | |
download | rails-0ad70eb2d063cab577a559f6c3d28e787ca1dca8.tar.gz rails-0ad70eb2d063cab577a559f6c3d28e787ca1dca8.tar.bz2 rails-0ad70eb2d063cab577a559f6c3d28e787ca1dca8.zip |
Make `truncate_tables` to bulk statements
Before:
```
(16.4ms) TRUNCATE TABLE `author_addresses`
(20.5ms) TRUNCATE TABLE `authors`
(19.4ms) TRUNCATE TABLE `posts`
```
After:
```
Truncate Tables (19.5ms) TRUNCATE TABLE `author_addresses`;
TRUNCATE TABLE `authors`;
TRUNCATE TABLE `posts`
```
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 33 |
1 files changed, 0 insertions, 33 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 5ceddf449c..8ca2cfa9ed 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -512,12 +512,6 @@ module ActiveRecord index.using == :btree || super end - def insert_fixtures_set(fixture_set, tables_to_delete = []) - with_multi_statements do - super { discard_remaining_results } - end - end - def build_insert_sql(insert) # :nodoc: sql = +"INSERT #{insert.into} #{insert.values_list}" @@ -539,33 +533,6 @@ module ActiveRecord end end - def combine_multi_statements(total_sql) - total_sql.each_with_object([]) do |sql, total_sql_chunks| - previous_packet = total_sql_chunks.last - sql << ";\n" - if max_allowed_packet_reached?(sql, previous_packet) || total_sql_chunks.empty? - total_sql_chunks << sql - else - previous_packet << sql - end - end - end - - def max_allowed_packet_reached?(current_packet, previous_packet) - if current_packet.bytesize > max_allowed_packet - raise ActiveRecordError, "Fixtures set is too large #{current_packet.bytesize}. Consider increasing the max_allowed_packet variable." - elsif previous_packet.nil? - false - else - (current_packet.bytesize + previous_packet.bytesize) > max_allowed_packet - end - end - - def max_allowed_packet - bytes_margin = 2 - @max_allowed_packet ||= (show_variable("max_allowed_packet") - bytes_margin) - end - def initialize_type_map(m = type_map) super |