aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-04-03 16:58:13 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-04-03 17:06:55 +0900
commit1799d9103555a6c33f1239ae59bc3ced764826cc (patch)
tree266bbec6b450d13b276b42aa5e9eae3ce8a4cc77
parent7020c6f9721c36616e58cba344549183aa091233 (diff)
downloadrails-1799d9103555a6c33f1239ae59bc3ced764826cc.tar.gz
rails-1799d9103555a6c33f1239ae59bc3ced764826cc.tar.bz2
rails-1799d9103555a6c33f1239ae59bc3ced764826cc.zip
`bytes_margin` is only needed when `previous_packet` exists
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
index 1199c0ad1b..a14394fe04 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
@@ -145,15 +145,12 @@ module ActiveRecord
elsif previous_packet.nil?
true
else
- (current_packet.bytesize + previous_packet.bytesize) > max_allowed_packet
+ (current_packet.bytesize + previous_packet.bytesize + 2) > max_allowed_packet
end
end
def max_allowed_packet
- @max_allowed_packet ||= begin
- bytes_margin = 2
- show_variable("max_allowed_packet") - bytes_margin
- end
+ @max_allowed_packet ||= show_variable("max_allowed_packet")
end
def exec_stmt_and_free(sql, name, binds, cache_stmt: false)