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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Ivlev
bugzilla
Commits
cd73cd98
Commit
cd73cd98
authored
Jan 24, 2012
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 718183: Rename duplicated series names before inserting the new index in the series table
r=dkl a=LpSolit
parent
6822aab9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
DB.pm
Bugzilla/Install/DB.pm
+31
-0
No files found.
Bugzilla/Install/DB.pm
View file @
cd73cd98
...
@@ -3477,6 +3477,37 @@ sub _fix_series_indexes {
...
@@ -3477,6 +3477,37 @@ sub _fix_series_indexes {
return
if
$dbh
->
bz_index_info
(
'series'
,
'series_category_idx'
);
return
if
$dbh
->
bz_index_info
(
'series'
,
'series_category_idx'
);
$dbh
->
bz_drop_index
(
'series'
,
'series_creator_idx'
);
$dbh
->
bz_drop_index
(
'series'
,
'series_creator_idx'
);
# Fix duplicated names under the same category/subcategory before
# adding the more restrictive index.
my
$duplicated_series
=
$dbh
->
selectall_arrayref
(
'SELECT s1.series_id, s1.category, s1.subcategory, s1.name
FROM series AS s1
INNER JOIN series AS s2
ON s1.category = s2.category
AND s1.subcategory = s2.subcategory
AND s1.name = s2.name
WHERE s1.series_id != s2.series_id'
);
my
$sth_series_update
=
$dbh
->
prepare
(
'UPDATE series SET name = ? WHERE series_id = ?'
);
my
$sth_series_query
=
$dbh
->
prepare
(
'SELECT 1 FROM series WHERE name = ?
AND category = ? AND subcategory = ?'
);
my
%
renamed_series
;
foreach
my
$series
(
@$duplicated_series
)
{
my
(
$series_id
,
$category
,
$subcategory
,
$name
)
=
@$series
;
# Leave the first series alone, then rename duplicated ones.
if
(
$renamed_series
{
"${category}_${subcategory}_${name}"
}
++
)
{
print
"Renaming series ${category}/${subcategory}/${name}...\n"
;
my
$c
=
0
;
my
$exists
=
1
;
while
(
$exists
)
{
$sth_series_query
->
execute
(
$name
.
++
$c
,
$category
,
$subcategory
);
$exists
=
$sth_series_query
->
fetchrow_array
;
}
$sth_series_update
->
execute
(
$name
.
$c
,
$series_id
);
}
}
$dbh
->
bz_add_index
(
'series'
,
'series_creator_idx'
,
[
'creator'
]);
$dbh
->
bz_add_index
(
'series'
,
'series_creator_idx'
,
[
'creator'
]);
$dbh
->
bz_add_index
(
'series'
,
'series_category_idx'
,
$dbh
->
bz_add_index
(
'series'
,
'series_category_idx'
,
{
FIELDS
=>
[
qw(category subcategory name)
],
TYPE
=>
'UNIQUE'
});
{
FIELDS
=>
[
qw(category subcategory name)
],
TYPE
=>
'UNIQUE'
});
...
...
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