summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Install
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2013-02-18 03:41:50 +0100
committerDave Lawrence <dlawrence@mozilla.com>2013-02-18 03:41:50 +0100
commitce16ab89d78d2299c9afb8e18c2a1d6454fcbafe (patch)
tree17c768c0112c92724efd8604832f4da632f29bae /Bugzilla/Install
parent793f9d9c3900d37147494de72065ebc66e61d019 (diff)
downloadbugzilla-ce16ab89d78d2299c9afb8e18c2a1d6454fcbafe.tar.gz
bugzilla-ce16ab89d78d2299c9afb8e18c2a1d6454fcbafe.tar.xz
Bug 824346 - The flaginclusions and flagexclusions DB tables have no UNIQUE index
r/a=LpSolit
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r--Bugzilla/Install/DB.pm32
1 files changed, 32 insertions, 0 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index d86d6e177..104caac3b 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -693,6 +693,9 @@ sub update_table_definitions {
# 2012-08-02 dkl@mozilla.com - Bug 756953
_fix_dependencies_dupes();
+ # 2013-02-04 dkl@mozilla.com - Bug 824346
+ _fix_flagclusions_indexes();
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
@@ -3754,6 +3757,35 @@ sub _fix_dependencies_dupes {
}
}
+sub _fix_flagclusions_indexes {
+ my $dbh = Bugzilla->dbh;
+ foreach my $table ('flaginclusions', 'flagexclusions') {
+ my $index = $table . '_type_id_idx';
+ my $idx_info = $dbh->bz_index_info($table, $index);
+ if ($idx_info && $idx_info->{'TYPE'} ne 'UNIQUE') {
+ # Remove duplicated entries
+ my $dupes = $dbh->selectall_arrayref("
+ SELECT type_id, product_id, component_id, COUNT(*) AS count
+ FROM $table " .
+ $dbh->sql_group_by('type_id, product_id, component_id') . "
+ HAVING COUNT(*) > 1",
+ { Slice => {} });
+ print "Removing duplicated entries from the '$table' table...\n" if @$dupes;
+ foreach my $dupe (@$dupes) {
+ $dbh->do("DELETE FROM $table
+ WHERE type_id = ? AND product_id = ? AND component_id = ?",
+ undef, $dupe->{type_id}, $dupe->{product_id}, $dupe->{component_id});
+ $dbh->do("INSERT INTO $table (type_id, product_id, component_id) VALUES (?, ?, ?)",
+ undef, $dupe->{type_id}, $dupe->{product_id}, $dupe->{component_id});
+ }
+ $dbh->bz_drop_index($table, $index);
+ $dbh->bz_add_index($table, $index,
+ { FIELDS => [qw(type_id product_id component_id)],
+ TYPE => 'UNIQUE' });
+ }
+ }
+}
+
1;
__END__