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
d4e9172a
Commit
d4e9172a
authored
Apr 19, 2007
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 377564: Indexes are not renamed when renaming tables
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
parent
40e63525
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
1 deletion
+41
-1
DB.pm
Bugzilla/DB.pm
+11
-0
Schema.pm
Bugzilla/DB/Schema.pm
+7
-0
DB.pm
Bugzilla/Install/DB.pm
+23
-1
No files found.
Bugzilla/DB.pm
View file @
d4e9172a
...
...
@@ -841,6 +841,17 @@ sub bz_table_columns {
return
$self
->
_bz_real_schema
->
get_table_columns
(
$table
);
}
sub
bz_table_indexes
{
my
(
$self
,
$table
)
=
@_
;
my
$indexes
=
$self
->
_bz_real_schema
->
get_table_indexes_abstract
(
$table
);
my
%
return_indexes
;
# We do this so that they're always hashes.
foreach
my
$name
(
keys
%
$indexes
)
{
$return_indexes
{
$name
}
=
$self
->
bz_index_info
(
$table
,
$name
);
}
return
\%
return_indexes
;
}
#####################################################################
# Protected "Real Database" Schema Information Methods
#####################################################################
...
...
Bugzilla/DB/Schema.pm
View file @
d4e9172a
...
...
@@ -1588,6 +1588,13 @@ sub get_table_columns {
}
#eosub--get_table_columns
sub
get_table_indexes_abstract
{
my
(
$self
,
$table
)
=
@_
;
my
$table_def
=
$self
->
get_table_abstract
(
$table
);
my
%
indexes
=
@
{
$table_def
->
{
INDEXES
}
||
[]
};
return
\%
indexes
;
}
sub
get_create_database_sql
{
my
(
$self
,
$name
)
=
@_
;
return
(
"CREATE DATABASE $name"
);
...
...
Bugzilla/Install/DB.pm
View file @
d4e9172a
...
...
@@ -504,6 +504,7 @@ sub update_table_definitions {
{
TYPE
=>
'MEDIUMSERIAL'
,
NOTNULL
=>
1
,
PRIMARYKEY
=>
1
});
_fix_uppercase_custom_field_names
();
_fix_uppercase_index_names
();
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
...
...
@@ -2750,7 +2751,28 @@ sub _fix_uppercase_custom_field_names {
undef
,
lc
(
$name
),
$name
);
}
}
}
sub
_fix_uppercase_index_names
{
# We forgot to fix indexes in the above code.
my
$dbh
=
Bugzilla
->
dbh
;
my
$fields
=
$dbh
->
selectcol_arrayref
(
'SELECT name FROM fielddefs WHERE type = ? AND custom = 1'
,
undef
,
FIELD_TYPE_SINGLE_SELECT
);
foreach
my
$field
(
@$fields
)
{
my
$indexes
=
$dbh
->
bz_table_indexes
(
$field
);
foreach
my
$name
(
keys
%
$indexes
)
{
next
if
$name
eq
lc
(
$name
);
my
$index
=
$indexes
->
{
$name
};
# Lowercase the name and everything in the definition.
my
$new_name
=
lc
(
$name
);
my
@new_fields
=
map
{
lc
(
$_
)}
@
{
$index
->
{
FIELDS
}};
my
$new_def
=
{
FIELDS
=>
\
@new_fields
,
TYPE
=>
$index
->
{
TYPE
}};
$new_def
=
\
@new_fields
if
!
$index
->
{
TYPE
};
$dbh
->
bz_drop_index
(
$field
,
$name
);
$dbh
->
bz_add_index
(
$field
,
$new_name
,
$new_def
);
}
}
}
1
;
...
...
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