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
ba3ebf7b
Commit
ba3ebf7b
authored
Jul 09, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 577793: Improve the Pg SERIAL-altering code now that we require 8.3
r=mkanat, a=mkanat (module owner)
parent
5d9a3172
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
Pg.pm
Bugzilla/DB/Schema/Pg.pm
+8
-10
No files found.
Bugzilla/DB/Schema/Pg.pm
View file @
ba3ebf7b
...
...
@@ -100,11 +100,9 @@ sub get_rename_column_ddl {
my
@sql
=
(
"ALTER TABLE $table RENAME COLUMN $old_name TO $new_name"
);
my
$def
=
$self
->
get_column_abstract
(
$table
,
$old_name
);
if
(
$def
->
{
TYPE
}
=~
/SERIAL/i
)
{
# We have to rename the series also, and fix the default of the series.
push
(
@sql
,
"ALTER TABLE ${table}_${old_name}_seq
RENAME TO ${table}_${new_name}_seq"
);
push
(
@sql
,
"ALTER TABLE $table ALTER COLUMN $new_name
SET DEFAULT NEXTVAL('${table}_${new_name}_seq')"
);
# We have to rename the series also.
push
(
@sql
,
"ALTER SEQUENCE ${table}_${old_name}_seq
RENAME TO ${table}_${new_name}_seq"
);
}
return
@sql
;
}
...
...
@@ -147,7 +145,8 @@ sub _get_alter_type_sql {
TYPE $type"
);
if
(
$new_def
->
{
TYPE
}
=~
/serial/i
&&
$old_def
->
{
TYPE
}
!~
/serial/i
)
{
push
(
@statements
,
"CREATE SEQUENCE ${table}_${column}_seq"
);
push
(
@statements
,
"CREATE SEQUENCE ${table}_${column}_seq
OWNED BY $table.$column"
);
push
(
@statements
,
"SELECT setval('${table}_${column}_seq',
MAX($table.$column))
FROM $table"
);
...
...
@@ -160,10 +159,9 @@ sub _get_alter_type_sql {
if
(
$old_def
->
{
TYPE
}
=~
/serial/i
&&
$new_def
->
{
TYPE
}
!~
/serial/i
)
{
push
(
@statements
,
"ALTER TABLE $table ALTER COLUMN $column
DROP DEFAULT"
);
# XXX Pg actually won't let us drop the sequence, even though it's
# no longer in use. So we harmlessly leave behind a sequence
# that does nothing.
#push(@statements, "DROP SEQUENCE ${table}_${column}_seq");
push
(
@statements
,
"ALTER SEQUENCE ${table}_${column}_seq
OWNED BY NONE"
);
push
(
@statements
,
"DROP SEQUENCE ${table}_${column}_seq"
);
}
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