Allow edit summaries to be up to 767 bytes long

This is just the db part. The changes to UI validation code will
come in a dependent patch later.

This changes the max size of various *_comment, *_description
and *_reason fields to be 767 bytes. This size is chosen to
be consistent with the largest we can get away with while
still having covering indexes.

It also unifies the various data types of these fields to
varbinary. (Note, this was previously done and reverted in
r80547, but I don't think the reason for revert applies to
the edit summary fields)

MyISAM has a much smaller max index size, and this wouldn't
work with that storage engine. However, none of these fields
are used in default indexes (only in WMF indexes), so this
should not be an issue for anyone using MyISAM. Postgress
and sqlite already supported the larger edit summary size.

Note: This patch increases min mysql version to 5.0.3.

Bug: T6715
Change-Id: I8558e80a18e4591f07f2c3e80f792ea4435c4e71
This commit is contained in:
Brian Wolff 2015-02-19 20:31:31 -04:00 committed by Springle
parent bfe07bed33
commit 5d9b67e09e
6 changed files with 90 additions and 11 deletions

View file

@ -47,7 +47,7 @@ class MysqlInstaller extends DatabaseInstaller {
public $supportedEngines = array( 'InnoDB', 'MyISAM' ); public $supportedEngines = array( 'InnoDB', 'MyISAM' );
public $minimumVersion = '5.0.2'; public $minimumVersion = '5.0.3';
public $webUserPrivs = array( public $webUserPrivs = array(
'DELETE', 'DELETE',

View file

@ -271,6 +271,8 @@ class MysqlUpdater extends DatabaseUpdater {
array( 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ), array( 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ),
array( 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ), array( 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ),
array( 'doUserNewTalkUseridUnsigned' ), array( 'doUserNewTalkUseridUnsigned' ),
// note this patch covers other _comment and _description fields too
array( 'modifyField', 'recentchanges', 'rc_comment', 'patch-editsummary-length.sql' ),
); );
} }

View file

@ -142,6 +142,7 @@ class SqliteUpdater extends DatabaseUpdater {
array( 'dropTable', 'hitcounter' ), array( 'dropTable', 'hitcounter' ),
array( 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ), array( 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ),
array( 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ), array( 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ),
array( 'modifyField', 'filearchive', 'fa_deleted_reason', 'patch-editsummary-length.sql' ),
); );
} }

View file

@ -0,0 +1,11 @@
ALTER TABLE /*_*/revision MODIFY rev_comment varbinary(767) NOT NULL;
ALTER TABLE /*_*/archive MODIFY ar_comment varbinary(767) NOT NULL;
ALTER TABLE /*_*/image MODIFY img_description varbinary(767) NOT NULL;
ALTER TABLE /*_*/oldimage MODIFY oi_description varbinary(767) NOT NULL;
ALTER TABLE /*_*/filearchive MODIFY fa_description varbinary(767);
ALTER TABLE /*_*/filearchive MODIFY fa_deleted_reason varbinary(767) default '';
ALTER TABLE /*_*/recentchanges MODIFY rc_comment varbinary(767) NOT NULL default '';
ALTER TABLE /*_*/logging MODIFY log_comment varbinary(767) NOT NULL default '';
ALTER TABLE /*_*/ipblocks MODIFY ipb_reason varbinary(767) NOT NULL;
ALTER TABLE /*_*/protected_titles MODIFY pt_reason varbinary(767);

View file

@ -0,0 +1,65 @@
CREATE TABLE /*_*/filearchive_tmp (
-- Unique row id
fa_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
-- Original base filename; key to image.img_name, page.page_title, etc
fa_name varchar(255) binary NOT NULL default '',
-- Filename of archived file, if an old revision
fa_archive_name varchar(255) binary default '',
-- Which storage bin (directory tree or object store) the file data
-- is stored in. Should be 'deleted' for files that have been deleted;
-- any other bin is not yet in use.
fa_storage_group varbinary(16),
-- SHA-1 of the file contents plus extension, used as a key for storage.
-- eg 8f8a562add37052a1848ff7771a2c515db94baa9.jpg
--
-- If NULL, the file was missing at deletion time or has been purged
-- from the archival storage.
fa_storage_key varbinary(64) default '',
-- Deletion information, if this file is deleted.
fa_deleted_user int,
fa_deleted_timestamp binary(14) default '',
fa_deleted_reason varbinary(767) default '',
-- Duped fields from image
fa_size int unsigned default 0,
fa_width int default 0,
fa_height int default 0,
fa_metadata mediumblob,
fa_bits int default 0,
fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown",
fa_minor_mime varbinary(100) default "unknown",
fa_description varbinary(767),
fa_user int unsigned default 0,
fa_user_text varchar(255) binary,
fa_timestamp binary(14) default '',
-- Visibility of deleted revisions, bitfield
fa_deleted tinyint unsigned NOT NULL default 0,
-- sha1 hash of file content
fa_sha1 varbinary(32) NOT NULL default ''
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/filearchive_tmp
SELECT fa_id, fa_name, fa_archive_name, fa_storage_group, fa_storage_key, fa_deleted_user, fa_deleted_timestamp,
fa_deleted_reason, fa_size, fa_width, fa_height, fa_metadata, fa_bits, fa_media_type, fa_major_mime,
fa_minor_mime, fa_description, fa_user, fa_user_text, fa_timestamp, fa_deleted, fa_sha1
FROM /*_*/filearchive;
DROP TABLE /*_*/filearchive;
ALTER TABLE /*_*/filearchive_tmp RENAME TO /*_*/filearchive;
CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
CREATE INDEX /*i*/fa_storage_group ON /*_*/filearchive (fa_storage_group, fa_storage_key);
CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
CREATE INDEX /*i*/fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
CREATE INDEX /*i*/fa_sha1 ON /*_*/filearchive (fa_sha1(10));

View file

@ -304,7 +304,7 @@ CREATE TABLE /*_*/revision (
-- Text comment summarizing the change. -- Text comment summarizing the change.
-- This text is shown in the history and other changes lists, -- This text is shown in the history and other changes lists,
-- rendered in a subset of wiki markup by Linker::formatComment() -- rendered in a subset of wiki markup by Linker::formatComment()
rev_comment tinyblob NOT NULL, rev_comment varbinary(767) NOT NULL,
-- Key to user.user_id of the user who made this edit. -- Key to user.user_id of the user who made this edit.
-- Stores 0 for anonymous edits and for some mass imports. -- Stores 0 for anonymous edits and for some mass imports.
@ -411,7 +411,7 @@ CREATE TABLE /*_*/archive (
ar_text mediumblob NOT NULL, ar_text mediumblob NOT NULL,
-- Basic revision stuff... -- Basic revision stuff...
ar_comment tinyblob NOT NULL, ar_comment varbinary(767) NOT NULL,
ar_user int unsigned NOT NULL default 0, ar_user int unsigned NOT NULL default 0,
ar_user_text varchar(255) binary NOT NULL, ar_user_text varchar(255) binary NOT NULL,
ar_timestamp binary(14) NOT NULL default '', ar_timestamp binary(14) NOT NULL default '',
@ -748,7 +748,7 @@ CREATE TABLE /*_*/ipblocks (
ipb_by_text varchar(255) binary NOT NULL default '', ipb_by_text varchar(255) binary NOT NULL default '',
-- Text comment made by blocker. -- Text comment made by blocker.
ipb_reason tinyblob NOT NULL, ipb_reason varbinary(767) NOT NULL,
-- Creation (or refresh) date in standard YMDHMS form. -- Creation (or refresh) date in standard YMDHMS form.
-- IP blocks expire automatically. -- IP blocks expire automatically.
@ -846,7 +846,7 @@ CREATE TABLE /*_*/image (
-- Description field as entered by the uploader. -- Description field as entered by the uploader.
-- This is displayed in image upload history and logs. -- This is displayed in image upload history and logs.
img_description tinyblob NOT NULL, img_description varbinary(767) NOT NULL,
-- user_id and user_name of uploader. -- user_id and user_name of uploader.
img_user int unsigned NOT NULL default 0, img_user int unsigned NOT NULL default 0,
@ -888,7 +888,7 @@ CREATE TABLE /*_*/oldimage (
oi_width int NOT NULL default 0, oi_width int NOT NULL default 0,
oi_height int NOT NULL default 0, oi_height int NOT NULL default 0,
oi_bits int NOT NULL default 0, oi_bits int NOT NULL default 0,
oi_description tinyblob NOT NULL, oi_description varbinary(767) NOT NULL,
oi_user int unsigned NOT NULL default 0, oi_user int unsigned NOT NULL default 0,
oi_user_text varchar(255) binary NOT NULL, oi_user_text varchar(255) binary NOT NULL,
oi_timestamp binary(14) NOT NULL default '', oi_timestamp binary(14) NOT NULL default '',
@ -936,7 +936,7 @@ CREATE TABLE /*_*/filearchive (
-- Deletion information, if this file is deleted. -- Deletion information, if this file is deleted.
fa_deleted_user int, fa_deleted_user int,
fa_deleted_timestamp binary(14) default '', fa_deleted_timestamp binary(14) default '',
fa_deleted_reason text, fa_deleted_reason varbinary(767) default '',
-- Duped fields from image -- Duped fields from image
fa_size int unsigned default 0, fa_size int unsigned default 0,
@ -947,7 +947,7 @@ CREATE TABLE /*_*/filearchive (
fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL, fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown", fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown",
fa_minor_mime varbinary(100) default "unknown", fa_minor_mime varbinary(100) default "unknown",
fa_description tinyblob, fa_description varbinary(767),
fa_user int unsigned default 0, fa_user int unsigned default 0,
fa_user_text varchar(255) binary, fa_user_text varchar(255) binary,
fa_timestamp binary(14) default '', fa_timestamp binary(14) default '',
@ -1045,7 +1045,7 @@ CREATE TABLE /*_*/recentchanges (
rc_title varchar(255) binary NOT NULL default '', rc_title varchar(255) binary NOT NULL default '',
-- as in revision... -- as in revision...
rc_comment varchar(255) binary NOT NULL default '', rc_comment varbinary(767) NOT NULL default '',
rc_minor tinyint unsigned NOT NULL default 0, rc_minor tinyint unsigned NOT NULL default 0,
-- Edits by user accounts with the 'bot' rights key are -- Edits by user accounts with the 'bot' rights key are
@ -1253,7 +1253,7 @@ CREATE TABLE /*_*/logging (
log_page int unsigned NULL, log_page int unsigned NULL,
-- Freeform text. Interpreted as edit history comments. -- Freeform text. Interpreted as edit history comments.
log_comment varchar(255) NOT NULL default '', log_comment varbinary(767) NOT NULL default '',
-- miscellaneous parameters: -- miscellaneous parameters:
-- LF separated list (old system) or serialized PHP array (new system) -- LF separated list (old system) or serialized PHP array (new system)
@ -1412,7 +1412,7 @@ CREATE TABLE /*_*/protected_titles (
pt_namespace int NOT NULL, pt_namespace int NOT NULL,
pt_title varchar(255) binary NOT NULL, pt_title varchar(255) binary NOT NULL,
pt_user int unsigned NOT NULL, pt_user int unsigned NOT NULL,
pt_reason tinyblob, pt_reason varbinary(767),
pt_timestamp binary(14) NOT NULL, pt_timestamp binary(14) NOT NULL,
pt_expiry varbinary(14) NOT NULL default '', pt_expiry varbinary(14) NOT NULL default '',
pt_create_perm varbinary(60) NOT NULL pt_create_perm varbinary(60) NOT NULL