summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB/Schema/Mysql.pm
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-05-17 08:45:27 +0200
committermkanat%kerio.com <>2005-05-17 08:45:27 +0200
commit620f4ea2be07398a1d0f10293d413c06c44034cf (patch)
tree798448471377a40bbb49894ce7bff1f5a5754202 /Bugzilla/DB/Schema/Mysql.pm
parent7dc732e743222546373d6086376b0507ce72486d (diff)
downloadbugzilla-620f4ea2be07398a1d0f10293d413c06c44034cf.tar.gz
bugzilla-620f4ea2be07398a1d0f10293d413c06c44034cf.tar.xz
Bug 290677: Index rename time estimate is too short on large sites
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=jouni, a=justdave
Diffstat (limited to 'Bugzilla/DB/Schema/Mysql.pm')
-rw-r--r--Bugzilla/DB/Schema/Mysql.pm24
1 files changed, 24 insertions, 0 deletions
diff --git a/Bugzilla/DB/Schema/Mysql.pm b/Bugzilla/DB/Schema/Mysql.pm
index 21274f575..9ff8822fa 100644
--- a/Bugzilla/DB/Schema/Mysql.pm
+++ b/Bugzilla/DB/Schema/Mysql.pm
@@ -166,6 +166,30 @@ sub get_drop_index_ddl {
return ("DROP INDEX \`$name\` ON $table");
}
+# A special function for MySQL, for renaming a lot of indexes.
+# Index renames is a hash, where the key is a string - the
+# old names of the index, and the value is a hash - the index
+# definition that we're renaming to, with an extra key of "NAME"
+# that contains the new index name.
+# The indexes in %indexes must be in hashref format.
+sub get_rename_indexes_ddl {
+ my ($self, $table, %indexes) = @_;
+ my @keys = keys %indexes or return ();
+
+ my $sql = "ALTER TABLE $table ";
+
+ foreach my $old_name (@keys) {
+ my $name = $indexes{$old_name}->{NAME};
+ my $type = $indexes{$old_name}->{TYPE};
+ $type ||= 'INDEX';
+ my $fields = join(',', @{$indexes{$old_name}->{FIELDS}});
+ $sql .= " ADD $type $name ($fields), DROP INDEX $old_name,";
+ }
+ # Remove the last comma.
+ chop($sql);
+ return ($sql);
+}
+
# Converts a DBI column_info output to an abstract column definition.
# Expects to only be called by Bugzila::DB::Mysql::_bz_build_schema_from_disk,
# although there's a chance that it will also work properly if called