diff options
author | mkanat%kerio.com <> | 2005-12-30 07:27:25 +0100 |
---|---|---|
committer | mkanat%kerio.com <> | 2005-12-30 07:27:25 +0100 |
commit | 782a89bc8bd905fa5ac3532c984ad2b4b149e8fd (patch) | |
tree | 647e8a668ebe18da266024aa68af393fc89f719e /Bugzilla/DB | |
parent | f4401b3f02b75e8dfe563b516702e249e60b7eb7 (diff) | |
download | bugzilla-782a89bc8bd905fa5ac3532c984ad2b4b149e8fd.tar.gz bugzilla-782a89bc8bd905fa5ac3532c984ad2b4b149e8fd.tar.xz |
Bug 311047: populating enum tables fails without localconfig, when upgrading
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> and Nick Barnes <nb+bz@ravenbrook.com> r=mkanat, r=LpSolit, a=justdave
Diffstat (limited to 'Bugzilla/DB')
-rw-r--r-- | Bugzilla/DB/Mysql.pm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm index e2e0e840f..e03fbc910 100644 --- a/Bugzilla/DB/Mysql.pm +++ b/Bugzilla/DB/Mysql.pm @@ -540,6 +540,38 @@ sub bz_setup_database { } +sub bz_enum_initial_values { + my ($self, $enum_defaults) = @_; + my %enum_values = %$enum_defaults; + # Get a complete description of the 'bugs' table; with DBD::MySQL + # there isn't a column-by-column way of doing this. Could use + # $dbh->column_info, but it would go slower and we would have to + # use the undocumented mysql_type_name accessor to get the type + # of each row. + my $sth = $self->prepare("DESCRIBE bugs"); + $sth->execute(); + # Look for the particular columns we are interested in. + while (my ($thiscol, $thistype) = $sth->fetchrow_array()) { + if (defined $enum_values{$thiscol}) { + # this is a column of interest. + my @value_list; + if ($thistype and ($thistype =~ /^enum\(/)) { + # it has an enum type; get the set of values. + while ($thistype =~ /'([^']*)'(.*)/) { + push(@value_list, $1); + $thistype = $2; + } + } + if (@value_list) { + # record the enum values found. + $enum_values{$thiscol} = \@value_list; + } + } + } + + return \%enum_values; +} + ##################################################################### # MySQL-specific Database-Reading Methods ##################################################################### |