Closed
Bug 286527
Opened 20 years ago
Closed 20 years ago
Cross-DB bz_rename_column and bz_drop_column
Categories
(Bugzilla :: Bugzilla-General, enhancement, P1)
Tracking
()
RESOLVED
FIXED
Bugzilla 2.20
People
(Reporter: mkanat, Assigned: mkanat)
References
Details
Attachments
(1 file, 3 obsolete files)
(deleted),
patch
|
mkanat
:
review+
|
Details | Diff | Splinter Review |
Just like bz_rename_field, but cross-database compatible! Wow!
Assignee | ||
Updated•20 years ago
|
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → Bugzilla 2.20
Assignee | ||
Comment 1•20 years ago
|
||
It turns out that I'll pretty much have to implement DROP at the same time, so
let's just do that. They're both easy anyhow.
Summary: Cross-DB bz_rename_column → Cross-DB bz_rename_column and bz_drop_column
Assignee | ||
Comment 2•20 years ago
|
||
Tested on PostgreSQL and on MySQL. Once again, this contains various fixes for
previous patches. I apologies for mixing them together, but I think that this
method of doing things is better than taking out a branch and then having to
merge it back in.
Attachment #177730 -
Flags: review?(Tomas.Kopal)
Assignee | ||
Comment 3•20 years ago
|
||
Oops, I'd left two debug "print" statements in there.
Attachment #177730 -
Attachment is obsolete: true
Attachment #177731 -
Flags: review?(Tomas.Kopal)
Comment 4•20 years ago
|
||
Comment on attachment 177731 [details] [diff] [review]
v1.1
>+ # Handle any fields that were NULL before. We *must* have a DEFAULT.
>+ push(@statements, "UPDATE $table SET $column = $default"
>+ . " WHERE $column IS NULL");
Just for the record, you just created the column so there can't be any sensible
data, so leaving out the WHERE and changing all values would be as good as
this. But we don't need extra performance so let's play safe.
>+ my $abstract_fields = $self->{abstract_schema}{$table}{FIELDS};
>+ my $name_position = lsearch($abstract_fields, $column);
>+ # Delete the key/value pair from the array.
>+ splice(@$abstract_fields, $name_position, 2);
>+
I would really like to see a check for sensible value in $name_position here,
as a safeguard. I don't like trusting output from functions like lsearch to be
always valid, i.e. the substring always found :-).
>--- mkanat4/Bugzilla/DB.pm 2005-03-17 06:14:53.000000000 -0800
>+++ mkanat/Bugzilla/DB.pm 2005-03-17 06:20:06.000000000 -0800
>+sub bz_drop_column {
>+sub bz_rename_column {
Missing PODs for these.
Also, I was just thinking if it wouldn't be handy if these methods in DB.pm
returned true/false if any change were performed. Then you could easily do some
migration code (or rollback some chages, or whatever is needed) based on the
return value. Does it make sense, in the context of your idea how it should be
used?
Attachment #177731 -
Flags: review?(Tomas.Kopal) → review-
Updated•20 years ago
|
Attachment #177730 -
Flags: review?(Tomas.Kopal)
Assignee | ||
Comment 5•20 years ago
|
||
OK, I addressed all the comments.
Attachment #177731 -
Attachment is obsolete: true
Attachment #177837 -
Flags: review?(Tomas.Kopal)
Comment 6•20 years ago
|
||
Comment on attachment 177837 [details] [diff] [review]
v2
>--- Bugzilla/DB/Schema.pm 18 Mar 2005 03:28:52 -0000 1.13
>+++ Bugzilla/DB/Schema.pm 18 Mar 2005 07:09:21 -0000
>+ push(@statements, "UPDATE $table SET $column = $default"
>+ . " WHERE $column IS NULL");
>--- Bugzilla/DB/Schema/Pg.pm 18 Mar 2005 03:28:53 -0000 1.6
>+++ Bugzilla/DB/Schema/Pg.pm 18 Mar 2005 07:09:21 -0000
>+ push(@statements, "UPDATE $table SET $column = $default");
Is there any reason you changed this only for Postgres?
Just to be clear, I don't mind having the WHERE there, quite the opposite, we
are not shooting for extra speed here (it's just setup, nothing run by
thousands of users every second).
Otherwise, it looks perfect.
Attachment #177837 -
Flags: review?(Tomas.Kopal) → review+
Assignee | ||
Comment 7•20 years ago
|
||
(In reply to comment #6)
> Is there any reason you changed this only for Postgres?
Yeah, one of those is ADD COLUMN and the other one is ALTER COLUMN.
Comment 8•20 years ago
|
||
(In reply to comment #7)
> (In reply to comment #6)
> > Is there any reason you changed this only for Postgres?
>
> Yeah, one of those is ADD COLUMN and the other one is ALTER COLUMN.
Ooops :-). Ok, then, no problems with the patch :-).
Assignee | ||
Updated•20 years ago
|
Flags: approval?
Assignee | ||
Comment 9•20 years ago
|
||
Just a bitrot fix; carrying forward r+.
Assignee | ||
Updated•20 years ago
|
Attachment #177837 -
Attachment is obsolete: true
Attachment #178791 -
Flags: review+
Updated•20 years ago
|
Flags: approval? → approval+
Assignee | ||
Comment 10•20 years ago
|
||
Checking in Bugzilla/DB.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/DB.pm,v <-- DB.pm
new revision: 1.42; previous revision: 1.41
done
Checking in Bugzilla/DB/Schema.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/DB/Schema.pm,v <-- Schema.pm
new revision: 1.18; previous revision: 1.17
done
Checking in Bugzilla/DB/Schema/Mysql.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/DB/Schema/Mysql.pm,v <-- Mysql.pm
new revision: 1.5; previous revision: 1.4
done
Checking in Bugzilla/DB/Schema/Pg.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/DB/Schema/Pg.pm,v <-- Pg.pm
new revision: 1.7; previous revision: 1.6
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•