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
4d94e416
Commit
4d94e416
authored
Aug 03, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 508023: Speed up MySQL's bz_alter_column for when we're just adding or removing a DEFAULT
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=mkanat
parent
6f4d125a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
Mysql.pm
Bugzilla/DB/Schema/Mysql.pm
+22
-2
No files found.
Bugzilla/DB/Schema/Mysql.pm
View file @
4d94e416
...
...
@@ -178,13 +178,33 @@ sub get_alter_column_ddl {
delete
$new_def_copy
{
PRIMARYKEY
};
}
my
$new_ddl
=
$self
->
get_type_ddl
(
\%
new_def_copy
);
my
@statements
;
push
(
@statements
,
"UPDATE $table SET $column = $set_nulls_to
WHERE $column IS NULL"
)
if
defined
$set_nulls_to
;
push
(
@statements
,
"ALTER TABLE $table CHANGE COLUMN
# Calling SET DEFAULT or DROP DEFAULT is *way* faster than calling
# CHANGE COLUMN, so just do that if we're just changing the default.
my
%
old_defaultless
=
%
$old_def
;
my
%
new_defaultless
=
%
$new_def
;
delete
$old_defaultless
{
DEFAULT
};
delete
$new_defaultless
{
DEFAULT
};
if
(
$self
->
columns_equal
(
\%
new_defaultless
,
\%
old_defaultless
))
{
if
(
defined
$old_def
->
{
DEFAULT
}
and
!
defined
$new_def
->
{
DEFAULT
})
{
push
(
@statements
,
"ALTER TABLE $table ALTER COLUMN $column DROP DEFAULT"
);
}
else
{
push
(
@statements
,
"ALTER TABLE $table ALTER COLUMN $column
SET DEFAULT "
.
$new_def
->
{
DEFAULT
});
}
}
else
{
my
$new_ddl
=
$self
->
get_type_ddl
(
\%
new_def_copy
);
push
(
@statements
,
"ALTER TABLE $table CHANGE COLUMN
$column $column $new_ddl"
);
}
if
(
$old_def
->
{
PRIMARYKEY
}
&&
!
$new_def
->
{
PRIMARYKEY
})
{
# Dropping a PRIMARY KEY needs an explicit DROP PRIMARY KEY
push
(
@statements
,
"ALTER TABLE $table DROP PRIMARY KEY"
);
...
...
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