Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
39595d63
Commit
39595d63
authored
Feb 17, 2013
by
Dave Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 824346 - The flaginclusions and flagexclusions DB tables have no UNIQUE index
r/a=LpSolit
parent
8d30313d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
4 deletions
+36
-4
Schema.pm
Bugzilla/DB/Schema.pm
+4
-4
DB.pm
Bugzilla/Install/DB.pm
+32
-0
No files found.
Bugzilla/DB/Schema.pm
View file @
39595d63
...
...
@@ -638,8 +638,8 @@ use constant ABSTRACT_SCHEMA => {
DELETE
=>
'CASCADE'
}},
],
INDEXES
=>
[
flaginclusions_type_id_idx
=>
[
qw(type_id product_id component_id)
]
,
flaginclusions_type_id_idx
=>
{
FIELDS
=>
[
qw(type_id product_id component_id)
],
TYPE
=>
'UNIQUE'
}
,
],
},
...
...
@@ -659,8 +659,8 @@ use constant ABSTRACT_SCHEMA => {
DELETE
=>
'CASCADE'
}},
],
INDEXES
=>
[
flagexclusions_type_id_idx
=>
[
qw(type_id product_id component_id)
]
,
flagexclusions_type_id_idx
=>
{
FIELDS
=>
[
qw(type_id product_id component_id)
],
TYPE
=>
'UNIQUE'
}
,
],
},
...
...
Bugzilla/Install/DB.pm
View file @
39595d63
...
...
@@ -703,6 +703,9 @@ sub update_table_definitions {
# 2012-12-23 LpSolit@gmail.com - Bug 824361
_fix_longdescs_indexes
();
# 2013-02-04 dkl@mozilla.com - Bug 824346
_fix_flagclusions_indexes
();
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
...
...
@@ -3787,6 +3790,35 @@ sub _shorten_long_quips {
$dbh
->
bz_alter_column
(
'quips'
,
'quip'
,
{
TYPE
=>
'varchar(512)'
,
NOTNULL
=>
1
});
}
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
=>
{}
});
say
"Removing duplicated entries from the '$table' table..."
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__
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment