From 28ac958d3cf5951a2e75d53581d6ddd4ded30119 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Thu, 9 Jul 2015 14:24:47 +0800 Subject: Bug 1180570: store attachment size in the database --- Bugzilla/Install/DB.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Bugzilla/Install') diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 7e7362443..92015f22f 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -730,6 +730,8 @@ sub update_table_definitions { $dbh->bz_add_index('user_api_keys', 'user_api_keys_user_id_app_id_idx', [qw(user_id app_id)]); + _add_attach_size(); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ @@ -3829,6 +3831,22 @@ sub _fix_user_api_keys_indexes { } } +sub _add_attach_size { + my $dbh = Bugzilla->dbh; + + return if $dbh->bz_column_info('attachments', 'attach_size'); + + $dbh->bz_add_column('attachments', 'attach_size', + {TYPE => 'INT4', NOTNULL => 1, DEFAULT => 0}); + + print "Setting attach_size...\n"; + $dbh->do(" + UPDATE attachments + INNER JOIN attach_data ON attach_data.id = attachments.attach_id + SET attachments.attach_size = LENGTH(attach_data.thedata) + "); +} + 1; __END__ -- cgit v1.2.3-24-g4f1b