summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2007-12-11 09:26:48 +0100
committermkanat%bugzilla.org <>2007-12-11 09:26:48 +0100
commit961cc62c23185442870583a9e9f61c55a9548428 (patch)
treeb3c424ea82b56e2d5641574a124bb8ea708bb7d2 /Bugzilla
parenteb08f76a0dbac980de6792106537b6fa5d6fbe85 (diff)
downloadbugzilla-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')
-rw-r--r--Bugzilla/DB/Schema.pm32
-rw-r--r--Bugzilla/DB/Schema/Mysql.pm3
-rw-r--r--Bugzilla/DB/Schema/Pg.pm2
-rw-r--r--Bugzilla/Install/DB.pm63
4 files changed, 79 insertions, 21 deletions
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 61f894f83..a4c1019b8 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -218,7 +218,7 @@ use constant ABSTRACT_SCHEMA => {
bug_id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1,
PRIMARYKEY => 1},
assigned_to => {TYPE => 'INT3', NOTNULL => 1},
- bug_file_loc => {TYPE => 'TEXT'},
+ bug_file_loc => {TYPE => 'MEDIUMTEXT'},
bug_severity => {TYPE => 'varchar(64)', NOTNULL => 1},
bug_status => {TYPE => 'varchar(64)', NOTNULL => 1},
creation_ts => {TYPE => 'DATETIME'},
@@ -322,7 +322,7 @@ use constant ABSTRACT_SCHEMA => {
bug_when => {TYPE => 'DATETIME', NOTNULL => 1},
work_time => {TYPE => 'decimal(5,2)', NOTNULL => 1,
DEFAULT => '0'},
- thetext => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+ thetext => {TYPE => 'LONGTEXT', NOTNULL => 1},
isprivate => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'FALSE'},
already_wrapped => {TYPE => 'BOOLEAN', NOTNULL => 1,
@@ -373,8 +373,8 @@ use constant ABSTRACT_SCHEMA => {
bug_id => {TYPE => 'INT3', NOTNULL => 1},
creation_ts => {TYPE => 'DATETIME', NOTNULL => 1},
modification_time => {TYPE => 'DATETIME', NOTNULL => 1},
- description => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
- mimetype => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+ description => {TYPE => 'TINYTEXT', NOTNULL => 1},
+ mimetype => {TYPE => 'TINYTEXT', NOTNULL => 1},
ispatch => {TYPE => 'BOOLEAN'},
filename => {TYPE => 'varchar(100)', NOTNULL => 1},
submitter_id => {TYPE => 'INT3', NOTNULL => 1,
@@ -469,7 +469,7 @@ use constant ABSTRACT_SCHEMA => {
id => {TYPE => 'SMALLSERIAL', NOTNULL => 1,
PRIMARYKEY => 1},
name => {TYPE => 'varchar(50)', NOTNULL => 1},
- description => {TYPE => 'TEXT'},
+ description => {TYPE => 'MEDIUMTEXT'},
cc_list => {TYPE => 'varchar(200)'},
target_type => {TYPE => 'char(1)', NOTNULL => 1,
DEFAULT => "'b'"},
@@ -527,7 +527,7 @@ use constant ABSTRACT_SCHEMA => {
DEFAULT => FIELD_TYPE_UNKNOWN},
custom => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'FALSE'},
- description => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+ description => {TYPE => 'TINYTEXT', NOTNULL => 1},
mailhead => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'FALSE'},
sortkey => {TYPE => 'INT2', NOTNULL => 1},
@@ -781,7 +781,7 @@ use constant ABSTRACT_SCHEMA => {
COLUMN => 'userid',
DELETE => 'CASCADE'}},
name => {TYPE => 'varchar(64)', NOTNULL => 1},
- query => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+ query => {TYPE => 'LONGTEXT', NOTNULL => 1},
query_type => {TYPE => 'BOOLEAN', NOTNULL => 1},
],
INDEXES => [
@@ -869,7 +869,7 @@ use constant ABSTRACT_SCHEMA => {
id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1,
PRIMARYKEY => 1},
name => {TYPE => 'varchar(255)', NOTNULL => 1},
- description => {TYPE => 'TEXT', NOTNULL => 1},
+ description => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
isbuggroup => {TYPE => 'BOOLEAN', NOTNULL => 1},
userregexp => {TYPE => 'TINYTEXT', NOTNULL => 1,
DEFAULT => "''"},
@@ -1067,7 +1067,7 @@ use constant ABSTRACT_SCHEMA => {
name => {TYPE => 'varchar(64)', NOTNULL => 1},
frequency => {TYPE => 'INT2', NOTNULL => 1},
last_viewed => {TYPE => 'DATETIME'},
- query => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+ query => {TYPE => 'LONGTEXT', NOTNULL => 1},
is_public => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'FALSE'},
],
@@ -1169,7 +1169,7 @@ use constant ABSTRACT_SCHEMA => {
quipid => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1,
PRIMARYKEY => 1},
userid => {TYPE => 'INT3'},
- quip => {TYPE => 'TEXT', NOTNULL => 1},
+ quip => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
approved => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'TRUE'},
],
@@ -2475,18 +2475,16 @@ An auto-increment L</INT4>
=item C<TINYTEXT>
-Variable length string of characters up to 255 (2^8 - 1) characters wide
-or more depending on the character set used.
+Variable length string of characters up to 255 (2^8 - 1) characters wide.
=item C<MEDIUMTEXT>
-Variable length string of characters up to 16M (2^24 - 1) characters wide
-or more depending on the character set used.
+Variable length string of characters up to 4000 characters wide.
+May be longer on some databases.
-=item C<TEXT>
+=item C<LONGTEXT>
-Variable length string of characters up to 64K (2^16 - 1) characters wide
-or more depending on the character set used.
+Variable length string of characters up to 16M (2^24 - 1) characters wide.
=item C<LONGBLOB>
diff --git a/Bugzilla/DB/Schema/Mysql.pm b/Bugzilla/DB/Schema/Mysql.pm
index c867dc0fc..300b1a0f1 100644
--- a/Bugzilla/DB/Schema/Mysql.pm
+++ b/Bugzilla/DB/Schema/Mysql.pm
@@ -81,6 +81,7 @@ use constant REVERSE_MAPPING => {
SMALLINT => 'INT2',
MEDIUMINT => 'INT3',
INTEGER => 'INT4',
+
# All the other types have the same name in their abstract version
# as in their db-specific version, so no reverse mapping is needed.
};
@@ -111,7 +112,7 @@ sub _initialize {
TINYTEXT => 'tinytext',
MEDIUMTEXT => 'mediumtext',
- TEXT => 'text',
+ LONGTEXT => 'mediumtext',
LONGBLOB => 'longblob',
diff --git a/Bugzilla/DB/Schema/Pg.pm b/Bugzilla/DB/Schema/Pg.pm
index 7a951e2db..070c0b03e 100644
--- a/Bugzilla/DB/Schema/Pg.pm
+++ b/Bugzilla/DB/Schema/Pg.pm
@@ -75,7 +75,7 @@ sub _initialize {
TINYTEXT => 'varchar(255)',
MEDIUMTEXT => 'text',
- TEXT => 'text',
+ LONGTEXT => 'text',
LONGBLOB => 'bytea',
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__