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
d59420c8
Commit
d59420c8
authored
Aug 06, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 508186: Speed up UTF-8 table conversion in checksetup
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=mkanat
parent
5539de9f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
32 deletions
+28
-32
Mysql.pm
Bugzilla/DB/Mysql.pm
+28
-32
No files found.
Bugzilla/DB/Mysql.pm
View file @
d59420c8
...
...
@@ -717,6 +717,7 @@ EOT
foreach
my
$table
(
$self
->
bz_table_list_real
)
{
my
$info_sth
=
$self
->
prepare
(
"SHOW FULL COLUMNS FROM $table"
);
$info_sth
->
execute
();
my
(
@binary_sql
,
@utf8_sql
);
while
(
my
$column
=
$info_sth
->
fetchrow_hashref
)
{
# Our conversion code doesn't work on enum fields, but they
# all go away later in checksetup anyway.
...
...
@@ -729,31 +730,13 @@ EOT
{
my
$name
=
$column
->
{
Field
};
# The code below doesn't work on a field with a FULLTEXT
# index. So we drop it, which we'd do later anyway.
if
(
$table
eq
'longdescs'
&&
$name
eq
'thetext'
)
{
$self
->
bz_drop_index
(
'longdescs'
,
'longdescs_thetext_idx'
);
}
if
(
$table
eq
'bugs'
&&
$name
eq
'short_desc'
)
{
$self
->
bz_drop_index
(
'bugs'
,
'bugs_short_desc_idx'
);
}
my
%
ft_indexes
;
if
(
$table
eq
'bugs_fulltext'
)
{
%
ft_indexes
=
$self
->
_bz_real_schema
->
get_indexes_on_column_abstract
(
'bugs_fulltext'
,
$name
);
foreach
my
$index
(
keys
%
ft_indexes
)
{
$self
->
bz_drop_index
(
'bugs_fulltext'
,
$index
);
}
}
print
"$table.$name needs to be converted to UTF-8...\n"
;
my
$dropped
=
$self
->
bz_drop_related_fks
(
$table
,
$name
);
push
(
@dropped_fks
,
@$dropped
);
print
"Converting $table.$name to be stored as UTF-8...\n"
;
my
$col_info
=
my
$col_info
=
$self
->
bz_column_info_real
(
$table
,
$name
);
# CHANGE COLUMN doesn't take PRIMARY KEY
delete
$col_info
->
{
PRIMARYKEY
};
my
$sql_def
=
$self
->
_bz_schema
->
get_type_ddl
(
$col_info
);
...
...
@@ -765,20 +748,33 @@ EOT
# right after the type, which will always come first.
my
(
$binary
,
$utf8
)
=
(
$sql_def
,
$sql_def
);
my
$type
=
$self
->
_bz_schema
->
convert_type
(
$col_info
->
{
TYPE
});
$binary
=~
s/(\Q$type\E)/$1 CHARACTER SET binary/
;
$utf8
=~
s/(\Q$type\E)/$1 CHARACTER SET utf8/
;
$self
->
do
(
"ALTER TABLE $table CHANGE COLUMN $name $name
$binary"
);
$self
->
do
(
"ALTER TABLE $table CHANGE COLUMN $name $name
$utf8"
);
if
(
$table
eq
'bugs_fulltext'
)
{
foreach
my
$index
(
keys
%
ft_indexes
)
{
$self
->
bz_add_index
(
'bugs_fulltext'
,
$index
,
$ft_indexes
{
$index
});
}
push
(
@binary_sql
,
"MODIFY COLUMN $name $binary"
);
push
(
@utf8_sql
,
"MODIFY COLUMN $name $utf8"
);
}
}
# foreach column
if
(
@binary_sql
)
{
my
%
indexes
=
%
{
$self
->
bz_table_indexes
(
$table
)
};
foreach
my
$index_name
(
keys
%
indexes
)
{
my
$index
=
$indexes
{
$index_name
};
if
(
$index
->
{
TYPE
}
and
$index
->
{
TYPE
}
eq
'FULLTEXT'
)
{
$self
->
bz_drop_index
(
$table
,
$index_name
);
}
else
{
delete
$indexes
{
$index_name
};
}
}
print
"Converting the $table table to UTF-8...\n"
;
my
$bin
=
"ALTER TABLE $table "
.
join
(
', '
,
@binary_sql
);
my
$utf
=
"ALTER TABLE $table "
.
join
(
', '
,
@utf8_sql
);
$self
->
do
(
$bin
);
$self
->
do
(
$utf
);
# Re-add any removed FULLTEXT indexes.
foreach
my
$index
(
keys
%
indexes
)
{
$self
->
bz_add_index
(
$table
,
$index
,
$indexes
{
$index
});
}
}
$self
->
do
(
"ALTER TABLE $table DEFAULT CHARACTER SET utf8"
);
...
...
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