Skip to content

Commit

Permalink
Revert "Merge pull request #41232 from code4me/fix-malformed-packet-m…
Browse files Browse the repository at this point in the history
…aster"

This reverts commit 9f39d00.

Fixes #41403.
  • Loading branch information
rafaelfranca committed Feb 16, 2021
1 parent 7f343cb commit 4f5e6b5
Showing 1 changed file with 10 additions and 6 deletions.
Expand Up @@ -751,11 +751,6 @@ def configure_connection
wait_timeout = 2147483 unless wait_timeout.is_a?(Integer)
variables["wait_timeout"] = wait_timeout

# Set the collation of the connection character set.
if @config[:collation]
variables["collation_connection"] = @config[:collation]
end

defaults = [":default", :default].to_set

# Make MySQL reject illegal values rather than truncating or blanking them, see
Expand All @@ -775,6 +770,15 @@ def configure_connection
end
sql_mode_assignment = "@@SESSION.sql_mode = #{sql_mode}, " if sql_mode

# NAMES does not have an equals sign, see
# https://dev.mysql.com/doc/refman/en/set-names.html
# (trailing comma because variable_assignments will always have content)
if @config[:encoding]
encoding = +"NAMES #{@config[:encoding]}"
encoding << " COLLATE #{@config[:collation]}" if @config[:collation]
encoding << ", "
end

# Gather up all of the SET variables...
variable_assignments = variables.map do |k, v|
if defaults.include?(v)
Expand All @@ -786,7 +790,7 @@ def configure_connection
end.compact.join(", ")

# ...and send them all in one query
execute("SET #{sql_mode_assignment} #{variable_assignments}", "SCHEMA")
execute("SET #{encoding} #{sql_mode_assignment} #{variable_assignments}", "SCHEMA")
end

def column_definitions(table_name) # :nodoc:
Expand Down

0 comments on commit 4f5e6b5

Please sign in to comment.