summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2008-10-28 06:59:00 +0100
committermkanat%bugzilla.org <>2008-10-28 06:59:00 +0100
commitf5afeb3841a89bd58cfd12832ab05bf7eae75439 (patch)
treeee3e189e2c16251c0714c5079658d74c9975f53b /Bugzilla
parent7caa3a5c4707b0941fe722891ba0989ca1f379d0 (diff)
downloadbugzilla-f5afeb3841a89bd58cfd12832ab05bf7eae75439.tar.gz
bugzilla-f5afeb3841a89bd58cfd12832ab05bf7eae75439.tar.xz
Bug 141951: Set the max_packet_size for attachments (and bugs_fulltext) when connecting to MySQL
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm3
-rw-r--r--Bugzilla/Constants.pm3
-rw-r--r--Bugzilla/DB/Mysql.pm18
3 files changed, 21 insertions, 3 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 95e6f6d31..0d1ec66f2 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -230,9 +230,6 @@ use constant UPDATE_COMMENT_COLUMNS => qw(
# activity table.
use constant MAX_LINE_LENGTH => 254;
-# Used in _check_comment(). Gives the max length allowed for a comment.
-use constant MAX_COMMENT_LENGTH => 65535;
-
#####################################################################
sub new {
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 601ea52b2..c08156335 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -84,6 +84,7 @@ use File::Basename;
LIST_OF_BUGS
COMMENT_COLS
+ MAX_COMMENT_LENGTH
CMT_NORMAL
CMT_DUPE_OF
@@ -264,6 +265,8 @@ use constant LIST_OF_BUGS => 1;
# The column length for displayed (and wrapped) bug comments.
use constant COMMENT_COLS => 80;
+# Used in _check_comment(). Gives the max length allowed for a comment.
+use constant MAX_COMMENT_LENGTH => 65535;
# The type of bug comments.
use constant CMT_NORMAL => 0;
diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm
index 2f42f9f34..601be102b 100644
--- a/Bugzilla/DB/Mysql.pm
+++ b/Bugzilla/DB/Mysql.pm
@@ -51,6 +51,11 @@ use Bugzilla::DB::Schema::Mysql;
use List::Util qw(max);
use Text::ParseWords;
+# This is how many comments of MAX_COMMENT_LENGTH we expect on a single bug.
+# In reality, you could have a LOT more comments than this, because
+# MAX_COMMENT_LENGTH is big.
+use constant MAX_COMMENTS => 50;
+
# This module extends the DB interface via inheritance
use base qw(Bugzilla::DB);
@@ -93,6 +98,19 @@ sub new {
}
}
+ # The "comments" field of the bugs_fulltext table could easily exceed
+ # MySQL's default max_allowed_packet. Also, MySQL should never have
+ # a max_allowed_packet smaller than our max_attachment_size. However,
+ # if we've already set a max_allowed_packet in MySQL bigger than all
+ # of those, we should keep it.
+ my (undef, $current_max_allowed) = $self->selectrow_array(
+ q{SHOW VARIABLES LIKE 'max\_allowed\_packet'});
+ my $min_max_allowed_packet = MAX_COMMENTS * MAX_COMMENT_LENGTH;
+ my $max_allowed_packet = max($min_max_allowed_packet,
+ $current_max_allowed,
+ Bugzilla->params->{'maxattachmentsize'});
+ $self->do("SET SESSION max_allowed_packet = $max_allowed_packet");
+
return $self;
}