}
- # Figure out if any existing tables are of type ISAM and convert them
- # to type MyISAM if so. ISAM tables are deprecated in MySQL 3.23,
- # which Bugzilla now requires, and they don't support more than 16
- # indexes per table, which Bugzilla needs.
- my $table_status = $self->selectall_arrayref("SHOW TABLE STATUS");
+ my %table_status = @{ $self->selectcol_arrayref("SHOW TABLE STATUS",
+ {Columns=>[1,2]}) };
my @isam_tables;
- foreach my $row (@$table_status) {
- my ($name, $type) = @$row;
- push(@isam_tables, $name) if $type eq "ISAM";
+ foreach my $name (keys %table_status) {
+ push(@isam_tables, $name) if $table_status{$name} eq "ISAM";
}
if(scalar(@isam_tables)) {
# We want to convert tables to InnoDB, but it's possible that they have
# fulltext indexes on them, and conversion will fail unless we remove
# the indexes.
- if (grep($_ eq 'bugs', @tables)) {
+ if (grep($_ eq 'bugs', @tables)
+ and !grep($_ eq 'bugs_fulltext', @tables))
+ {
if ($self->bz_index_info_real('bugs', 'short_desc')) {
$self->bz_drop_index_raw('bugs', 'short_desc');
}
$sd_index_deleted = 1; # Used for later schema cleanup.
}
}
- if (grep($_ eq 'longdescs', @tables)) {
+ if (grep($_ eq 'longdescs', @tables)
+ and !grep($_ eq 'bugs_fulltext', @tables))
+ {
if ($self->bz_index_info_real('longdescs', 'thetext')) {
$self->bz_drop_index_raw('longdescs', 'thetext');
}
# Upgrade tables from MyISAM to InnoDB
my @myisam_tables;
- foreach my $row (@$table_status) {
- my ($name, $type) = @$row;
- if ($type =~ /^MYISAM$/i
+ foreach my $name (keys %table_status) {
+ if ($table_status{$name} =~ /^MYISAM$/i
&& !grep($_ eq $name, Bugzilla::DB::Schema::Mysql::MYISAM_TABLES))
{
push(@myisam_tables, $name) ;
foreach my $desc (keys %events) {
my $event = $events{$desc};
- my $sth = $dbh->prepare("SELECT COUNT(*) FROM email_setting
- WHERE event = $event");
- $sth->execute();
- if (!($sth->fetchrow_arrayref()->[0])) {
+ my $have_events = $dbh->selectrow_array(
+ "SELECT 1 FROM email_setting WHERE event = $event "
+ . $dbh->sql_limit(1));
+
+ if (!$have_events) {
# No settings in the table yet, so we assume that this is the
# first time it's being set.
print "Initializing \"$desc\" email_setting ...\n";
# and mark these statuses as 'closed', even if some of these statuses are
# expected to be open statuses. Bug statuses we have no information about
# are left as 'open'.
- my @closed_statuses =
- @{$dbh->selectcol_arrayref('SELECT DISTINCT bug_status FROM bugs
- WHERE resolution != ?', undef, '')};
-
- # Append the default list of closed statuses *unless* we detect at least
+ #
+ # We append the default list of closed statuses *unless* we detect at least
# one closed state in the DB (i.e. with is_open = 0). This would mean that
# the DB has already been updated at least once and maybe the admin decided
# that e.g. 'RESOLVED' is now an open state, in which case we don't want to
WHERE is_open = 0');
if (!$num_closed_states) {
+ my @closed_statuses =
+ @{$dbh->selectcol_arrayref('SELECT DISTINCT bug_status FROM bugs
+ WHERE resolution != ?', undef, '')};
@closed_statuses =
map {$dbh->quote($_)} (@closed_statuses, qw(RESOLVED VERIFIED CLOSED));