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
70adf1be
Commit
70adf1be
authored
Dec 19, 2005
by
mkanat%kerio.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 310231: MySQL-specific get_alter_column_ddl will not drop primary key
Patch By Olav Vitters <bugzilla-mozilla@bkor.dhs.org> r=mkanat, a=justdave
parent
8b20187d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
Mysql.pm
Bugzilla/DB/Schema/Mysql.pm
+14
-1
No files found.
Bugzilla/DB/Schema/Mysql.pm
View file @
70adf1be
...
...
@@ -153,12 +153,25 @@ sub _get_create_index_ddl {
# MySQL has a simpler ALTER TABLE syntax than ANSI.
sub
get_alter_column_ddl
{
my
(
$self
,
$table
,
$column
,
$new_def
,
$set_nulls_to
)
=
@_
;
my
$new_ddl
=
$self
->
get_type_ddl
(
$new_def
);
my
$old_def
=
$self
->
get_column
(
$table
,
$column
);
my
%
new_def_copy
=
%
$new_def
;
if
(
$old_def
->
{
PRIMARYKEY
}
&&
$new_def
->
{
PRIMARYKEY
})
{
# If a column stays a primary key do NOT specify PRIMARY KEY in the
# ALTER TABLE statement. This avoids a MySQL error that two primary
# keys are not allowed.
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
$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"
);
}
return
@statements
;
}
...
...
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