diff options
author | mkanat%bugzilla.org <> | 2007-12-11 09:26:48 +0100 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-12-11 09:26:48 +0100 |
commit | 961cc62c23185442870583a9e9f61c55a9548428 (patch) | |
tree | b3c424ea82b56e2d5641574a124bb8ea708bb7d2 /Bugzilla/Install | |
parent | eb08f76a0dbac980de6792106537b6fa5d6fbe85 (diff) | |
download | bugzilla-961cc62c23185442870583a9e9f61c55a9548428.tar.gz bugzilla-961cc62c23185442870583a9e9f61c55a9548428.tar.xz |
Bug 153129: Bugzilla uses "mediumtext" as a DB data type when it's not necessary
Patch By Xiaoou Wu <xiaoou.wu@oracle.com> and Max Kanat-Alexander <mkanat@bugzilla.org> r=mkanat, a=mkanat
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r-- | Bugzilla/Install/DB.pm | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 9342959cf..3b44f3016 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -24,7 +24,7 @@ use strict; use Bugzilla::Constants; use Bugzilla::Hook; -use Bugzilla::Install::Util qw(indicate_progress); +use Bugzilla::Install::Util qw(indicate_progress install_string); use Bugzilla::Util; use Bugzilla::Series; @@ -483,7 +483,7 @@ sub update_table_definitions { $dbh->bz_add_column('setting', 'subclass', {TYPE => 'varchar(32)'}); $dbh->bz_alter_column('longdescs', 'thetext', - { TYPE => 'MEDIUMTEXT', NOTNULL => 1 }, ''); + {TYPE => 'LONGTEXT', NOTNULL => 1}, ''); # 2006-10-20 LpSolit@gmail.com - Bug 189627 $dbh->bz_add_column('group_control_map', 'editcomponents', @@ -514,6 +514,9 @@ sub update_table_definitions { # 2007-08-21 wurblzap@gmail.com - Bug 365378 _make_lang_setting_dynamic(); + + # 2007-11-29 xiaoou.wu@oracle.com - Bug 153129 + change_text_types(); # 2007-09-09 LpSolit@gmail.com - Bug 99215 _fix_attachment_modification_date(); @@ -2930,6 +2933,62 @@ sub _fix_attachment_modification_date { [qw(modification_time)]); } +sub change_text_types { + my $dbh = Bugzilla->dbh; + return if $dbh->bz_column_info('series', 'query')->{TYPE} eq 'LONGTEXT'; + _check_content_length('attachments', 'mimetype', 255); + _check_content_length('fielddefs', 'description', 255); + _check_content_length('attachments', 'description', 255); + + $dbh->bz_alter_column('bugs', 'bug_file_loc', + { TYPE => 'MEDIUMTEXT'}); + $dbh->bz_alter_column('longdescs', 'thetext', + { TYPE => 'LONGTEXT', NOTNULL => 1 }); + $dbh->bz_alter_column('attachments', 'description', + { TYPE => 'TINYTEXT', NOTNULL => 1 }); + $dbh->bz_alter_column('attachments', 'mimetype', + { TYPE => 'TINYTEXT', NOTNULL => 1 }); + $dbh->bz_alter_column('flagtypes', 'description', + { TYPE => 'MEDIUMTEXT', NOTNULL => 1 }); + $dbh->bz_alter_column('fielddefs', 'description', + { TYPE => 'TINYTEXT', NOTNULL => 1 }); + $dbh->bz_alter_column('namedqueries', 'query', + { TYPE => 'LONGTEXT', NOTNULL => 1 }); + $dbh->bz_alter_column('groups', 'description', + { TYPE => 'MEDIUMTEXT', NOTNULL => 1 }); + $dbh->bz_alter_column('quips', 'quip', + { TYPE => 'MEDIUMTEXT', NOTNULL => 1 }); + $dbh->bz_alter_column('series', 'query', + { TYPE => 'LONGTEXT', NOTNULL => 1 }); +} + +sub _check_content_length { + my ($table_name, $field_name, $max_length) = @_; + my $dbh = Bugzilla->dbh; + my $contents = $dbh->selectcol_arrayref( + "SELECT $field_name FROM $table_name + WHERE LENGTH($field_name) > ?", undef, $max_length); + + if (@$contents) { + my @trimmed; + foreach my $item (@$contents) { + # Don't dump the whole string--it could be 16MB. + if (length($item) > 80) { + push(@trimmed, substr($item, 0, 30) . "..." + . substr($item, -30) . "\n"); + } else { + push(@trimmed, $item); + } + } + print install_string('install_data_too_long', + { column => $field_name, + table => $table_name, + max_length => $max_length, + data => join("\n", @trimmed) }); + exit 3; + } +} + 1; __END__ |