From: mkanat%kerio.com <> Date: Sat, 3 Sep 2005 06:32:47 +0000 (+0000) Subject: Bug 299230: Schema-Modification Functions Shouldn't Die on A DB-side Deletion Failure X-Git-Tag: bugzilla-2.20~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=684fa6b06aaa25c675f5f0ded0e02460d3d9f62f;p=thirdparty%2Fbugzilla.git Bug 299230: Schema-Modification Functions Shouldn't Die on A DB-side Deletion Failure Patch By Max Kanat-Alexander r=joel, a=justdave --- diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 4f7b3b1f65..c5f38d17bc 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -512,7 +512,10 @@ sub bz_drop_column { $table, $column); print "Deleting unused column $column from table $table ...\n"; foreach my $sql (@statements) { - $self->do($sql); + # Because this is a deletion, we don't want to die hard if + # we fail because of some local customization. If something + # is already gone, that's fine with us! + eval { $self->do($sql); } or warn "Failed SQL: [$sql] Error: $@"; } $self->_bz_real_schema->delete_column($table, $column); $self->_bz_store_real_schema; @@ -552,7 +555,12 @@ sub bz_drop_index_raw { my @statements = $self->_bz_schema->get_drop_index_ddl( $table, $name); print "Removing index '$name' from the $table table...\n" unless $silent; - $self->do($_) foreach (@statements); + foreach my $sql (@statements) { + # Because this is a deletion, we don't want to die hard if + # we fail because of some local customization. If something + # is already gone, that's fine with us! + eval { $self->do($sql) } or warn "Failed SQL: [$sql] Error: $@"; + } } sub bz_drop_table { @@ -563,7 +571,12 @@ sub bz_drop_table { if ($table_exists) { my @statements = $self->_bz_schema->get_drop_table_ddl($name); print "Dropping table $name...\n"; - $self->do($_) foreach (@statements); + foreach my $sql (@statements) { + # Because this is a deletion, we don't want to die hard if + # we fail because of some local customization. If something + # is already gone, that's fine with us! + eval { $self->do($sql); } or warn "Failed SQL: [$sql] Error: $@"; + } $self->_bz_real_schema->delete_table($name); $self->_bz_store_real_schema; }