Fix version detection for RENAME INDEX support. Fixes #15931.

This commit is contained in:
Jeff Browning 2014-06-27 10:04:18 -04:00 committed by Rafael Mendonça França
parent 473b09f616
commit 1133818326
4 changed files with 24 additions and 6 deletions

@ -1,3 +1,9 @@
* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
Fixes #15931.
*Jeff Browning*
* Fix the schema dump generated for tables without constraints and with
primary key with default value of custom PostgreSQL function result.

@ -473,7 +473,7 @@ def drop_table(table_name, options = {})
end
def rename_index(table_name, old_name, new_name)
if (version[0] == 5 && version[1] >= 7) || version[0] >= 6
if supports_rename_index?
execute "ALTER TABLE #{quote_table_name(table_name)} RENAME INDEX #{quote_table_name(old_name)} TO #{quote_table_name(new_name)}"
else
super
@ -774,10 +774,22 @@ def remove_timestamps_sql(table_name)
private
def version
@version ||= full_version.scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i }
end
def mariadb?
!!(full_version =~ /mariadb/i)
end
def supports_views?
version[0] >= 5
end
def supports_rename_index?
mariadb? ? false : (version[0] == 5 && version[1] >= 7) || version[0] >= 6
end
def configure_connection
variables = @config.fetch(:variables, {}).stringify_keys

@ -269,8 +269,8 @@ def configure_connection
super
end
def version
@version ||= @connection.info[:version].scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i }
def full_version
@full_version ||= @connection.info[:version]
end
def set_field_encoding field_name

@ -470,9 +470,9 @@ def select(sql, name = nil, binds = [])
rows
end
# Returns the version of the connected MySQL server.
def version
@version ||= @connection.server_info.scan(/^(\d+)\.(\d+)\.(\d+)/).flatten.map { |v| v.to_i }
# Returns the full version of the connected MySQL server.
def full_version
@full_version ||= @connection.server_info
end
def set_field_encoding field_name