Commit 6f4d125a authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 508018: Speed up _fix_defaults for MySQL checksetup upgrades

Patch by Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=mkanat
parent e9024051
......@@ -814,22 +814,40 @@ sub _fix_defaults {
# a default.
return unless (defined $assi_default && $assi_default ne '');
my %fix_columns;
foreach my $table ($self->_bz_real_schema->get_table_list()) {
foreach my $column ($self->bz_table_columns($table)) {
my $abs_def = $self->bz_column_info($table, $column);
my $abs_def = $self->bz_column_info($table, $column);
# BLOB/TEXT columns never have defaults
next if $abs_def->{TYPE} =~ /BLOB|TEXT/i;
if (!defined $abs_def->{DEFAULT}) {
# Get the exact default from the database without any
# "fixing" by bz_column_info_real.
my $raw_info = $self->_bz_raw_column_info($table, $column);
my $raw_default = $raw_info->{COLUMN_DEF};
if (defined $raw_default) {
$self->bz_alter_column_raw($table, $column, $abs_def);
$raw_default = "''" if $raw_default eq '';
print "Removed incorrect DB default: $raw_default\n";
if ($raw_default eq '') {
# Only (var)char columns can have empty strings as
# defaults, so if we got an empty string for some
# other default type, then it's bogus.
next unless $abs_def->{TYPE} =~ /char/i;
$raw_default = "''";
}
$fix_columns{$table} ||= [];
push(@{ $fix_columns{$table} }, $column);
print "$table.$column has incorrect DB default: $raw_default\n";
}
}
} # foreach $column
} # foreach $table
print "Fixing defaults...\n";
foreach my $table (reverse sort keys %fix_columns) {
my @alters = map("ALTER COLUMN $_ DROP DEFAULT",
@{ $fix_columns{$table} });
my $sql = "ALTER TABLE $table " . join(',', @alters);
$self->do($sql);
}
}
# There is a bug in MySQL 4.1.0 - 4.1.15 that makes certain SELECT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment