Convert UNIQUE keys into PRIMARY KEY

WMF DBAs have been doing a massive effort to convert UNIQUE KEYS into
PRIMARY KEY.

Having a PK is essential to do maintenance, specially on large tasks.
By not having a PK it is impossible to add it in a safe way if not done
directly on the master.

Having a PK means that we can easily change the PK into another one if
needed in the future. The ones we chose might not be the best ones, but
will allow us to get them changed.

Bug: T172514
Change-Id: Id635297838938c7c5dfe65d45285a4d16d65152d
This commit is contained in:
Reedy 2017-08-04 14:43:50 +02:00
parent 6939a99e57
commit 0f13fff160
35 changed files with 448 additions and 43 deletions

View file

@ -185,8 +185,12 @@ changes to languages because of Phabricator reports.
* EditPage::isOouiEnabled() is deprecated and will always return true.
* Parser::getRandomString() (deprecated in 1.26) was removed.
* Parser::uniqPrefix() (deprecated in 1.26) was removed.
* Parser::extractTagsAndParams() now only accepts three arguments. The fourth,
* Parser::extractTagsAndParams() now only accepts three arguments. The fourth,
$uniq_prefix was deprecated in 1.26 and has now been removed.
* (T172514) The following tables have had their UNIQUE indexes turned into proper
PRIMARY KEYs for increased maintainability: categorylinks, imagelinks, iwlinks,
langlinks, log_search, module_deps, objectcache, pagelinks, query_cache, site_stats,
templatelinks, text, transcache, user_former_groups, user_properties.
== Compatibility ==
MediaWiki 1.30 requires PHP 5.5.9 or later. There is experimental support for

View file

@ -137,7 +137,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
$order[] = $this->prefix . '_title' . $sort;
$this->addOption( 'ORDER BY', $order );
$this->addOption( 'USE INDEX', $this->prefix . '_from' );
$this->addOption( 'USE INDEX', [ $this->table => 'PRIMARY' ] );
$this->addOption( 'LIMIT', $params['limit'] + 1 );
$res = $this->select( __METHOD__ );

View file

@ -305,6 +305,27 @@ class MysqlUpdater extends DatabaseUpdater {
// 1.30
[ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
[ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
[ 'renameIndex', 'categorylinks', 'cl_from', 'PRIMARY', false,
'patch-categorylinks-fix-pk.sql' ],
[ 'renameIndex', 'templatelinks', 'tl_from', 'PRIMARY', false,
'patch-templatelinks-fix-pk.sql' ],
[ 'renameIndex', 'pagelinks', 'pl_from', 'PRIMARY', false, 'patch-pagelinks-fix-pk.sql' ],
[ 'renameIndex', 'text', 'old_id', 'PRIMARY', false, 'patch-text-fix-pk.sql' ],
[ 'renameIndex', 'imagelinks', 'il_from', 'PRIMARY', false, 'patch-imagelinks-fix-pk.sql' ],
[ 'renameIndex', 'iwlinks', 'iwl_from', 'PRIMARY', false, 'patch-iwlinks-fix-pk.sql' ],
[ 'renameIndex', 'langlinks', 'll_from', 'PRIMARY', false, 'patch-langlinks-fix-pk.sql' ],
[ 'renameIndex', 'log_search', 'ls_field_val', 'PRIMARY', false, 'patch-log_search-fix-pk.sql' ],
[ 'renameIndex', 'module_deps', 'md_module_skin', 'PRIMARY', false,
'patch-module_deps-fix-pk.sql' ],
[ 'renameIndex', 'objectcache', 'keyname', 'PRIMARY', false, 'patch-objectcache-fix-pk.sql' ],
[ 'renameIndex', 'querycache_info', 'qci_type', 'PRIMARY', false,
'patch-querycache_info-fix-pk.sql' ],
[ 'renameIndex', 'site_stats', 'ss_row_id', 'PRIMARY', false, 'patch-site_stats-fix-pk.sql' ],
[ 'renameIndex', 'transcache', 'tc_url_idx', 'PRIMARY', false, 'patch-transcache-fix-pk.sql' ],
[ 'renameIndex', 'user_former_groups', 'ufg_user_group', 'PRIMARY', false,
'patch-user_former_groups-fix-pk.sql' ],
[ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
'patch-user_properties-fix-pk.sql' ],
];
}

View file

@ -169,6 +169,27 @@ class SqliteUpdater extends DatabaseUpdater {
// 1.30
[ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
[ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
[ 'renameIndex', 'categorylinks', 'cl_from', 'PRIMARY', false,
'patch-categorylinks-fix-pk.sql' ],
[ 'renameIndex', 'templatelinks', 'tl_from', 'PRIMARY', false,
'patch-templatelinks-fix-pk.sql' ],
[ 'renameIndex', 'pagelinks', 'pl_from', 'PRIMARY', false, 'patch-pagelinks-fix-pk.sql' ],
[ 'renameIndex', 'text', 'old_id', 'PRIMARY', false, 'patch-text-fix-pk.sql' ],
[ 'renameIndex', 'imagelinks', 'il_from', 'PRIMARY', false, 'patch-imagelinks-fix-pk.sql' ],
[ 'renameIndex', 'iwlinks', 'iwl_from', 'PRIMARY', false, 'patch-iwlinks-fix-pk.sql' ],
[ 'renameIndex', 'langlinks', 'll_from', 'PRIMARY', false, 'patch-langlinks-fix-pk.sql' ],
[ 'renameIndex', 'log_search', 'ls_field_val', 'PRIMARY', false, 'patch-log_search-fix-pk.sql' ],
[ 'renameIndex', 'module_deps', 'md_module_skin', 'PRIMARY', false,
'patch-module_deps-fix-pk.sql' ],
[ 'renameIndex', 'objectcache', 'keyname', 'PRIMARY', false, 'patch-objectcache-fix-pk.sql' ],
[ 'renameIndex', 'querycache_info', 'qci_type', 'PRIMARY', false,
'patch-querycache_info-fix-pk.sql' ],
[ 'renameIndex', 'site_stats', 'ss_row_id', 'PRIMARY', false, 'patch-site_stats-fix-pk.sql' ],
[ 'renameIndex', 'transcache', 'tc_url_idx', 'PRIMARY', false, 'patch-transcache-fix-pk.sql' ],
[ 'renameIndex', 'user_former_groups', 'ufg_user_group', 'PRIMARY', false,
'patch-user_former_groups-fix-pk.sql' ],
[ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
'patch-user_properties-fix-pk.sql' ],
];
}

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/categorylinks DROP KEY /*i*/cl_from, ADD PRIMARY KEY (cl_from,cl_to);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/imagelinks DROP KEY /*i*/il_from, ADD PRIMARY KEY (il_from,il_to);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/iwlinks DROP KEY /*i*/iwl_from, ADD PRIMARY KEY (iwl_from,iwl_prefix,iwl_title);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/langlinks DROP KEY /*i*/ll_from, ADD PRIMARY KEY (ll_from,ll_lang);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/log_search DROP KEY /*i*/ls_field_val, ADD PRIMARY KEY (ls_field,ls_value,ls_log_id);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/module_deps DROP KEY /*i*/md_module_skin, ADD PRIMARY KEY (md_module,md_skin);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/objectcache DROP KEY /*i*/keyname, ADD PRIMARY KEY (keyname);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/pagelinks DROP INDEX /*i*/pl_from, ADD PRIMARY KEY (pl_from,pl_namespace,pl_title);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/querycache_info DROP KEY /*i*/qci_type, ADD PRIMARY KEY (qci_type);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/site_stats DROP KEY /*i*/ss_row_id, ADD PRIMARY KEY (ss_row_id);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/templatelinks DROP INDEX /*i*/tl_from, ADD PRIMARY KEY (tl_from,tl_namespace,tl_title);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/text DROP KEY /*i*/old_id, ADD PRIMARY KEY (old_id);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/transcache DROP KEY /*i*/tc_url_idx, ADD PRIMARY KEY (tc_url);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/user_former_groups DROP KEY /*i*/ufg_user_group, ADD PRIMARY KEY (ufg_user,ufg_group);

View file

@ -0,0 +1 @@
ALTER TABLE /*_*/user_properties DROP KEY /*i*/user_properties_user_property, ADD PRIMARY KEY (up_user,up_property);

View file

@ -0,0 +1,60 @@
CREATE TABLE /*_*/categorylinks_tmp (
-- Key to page_id of the page defined as a category member.
cl_from int unsigned NOT NULL default 0,
-- Name of the category.
-- This is also the page_title of the category's description page;
-- all such pages are in namespace 14 (NS_CATEGORY).
cl_to varchar(255) binary NOT NULL default '',
-- A binary string obtained by applying a sortkey generation algorithm
-- (Collation::getSortKey()) to page_title, or cl_sortkey_prefix . "\n"
-- . page_title if cl_sortkey_prefix is nonempty.
cl_sortkey varbinary(230) NOT NULL default '',
-- A prefix for the raw sortkey manually specified by the user, either via
-- [[Category:Foo|prefix]] or {{defaultsort:prefix}}. If nonempty, it's
-- concatenated with a line break followed by the page title before the sortkey
-- conversion algorithm is run. We store this so that we can update
-- collations without reparsing all pages.
-- Note: If you change the length of this field, you also need to change
-- code in LinksUpdate.php. See T27254.
cl_sortkey_prefix varchar(255) binary NOT NULL default '',
-- This isn't really used at present. Provided for an optional
-- sorting method by approximate addition time.
cl_timestamp timestamp NOT NULL,
-- Stores $wgCategoryCollation at the time cl_sortkey was generated. This
-- can be used to install new collation versions, tracking which rows are not
-- yet updated. '' means no collation, this is a legacy row that needs to be
-- updated by updateCollation.php. In the future, it might be possible to
-- specify different collations per category.
cl_collation varbinary(32) NOT NULL default '',
-- Stores whether cl_from is a category, file, or other page, so we can
-- paginate the three categories separately. This never has to be updated
-- after the page is created, since none of these page types can be moved to
-- any other.
cl_type ENUM('page', 'subcat', 'file') NOT NULL default 'page',
PRIMARY KEY (cl_from,cl_to)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/categorylinks_tmp
SELECT *
FROM /*_*/categorylinks;
DROP TABLE /*_*/categorylinks;
ALTER TABLE /*_*/categorylinks_tmp RENAME TO /*_*/categorylinks;
-- We always sort within a given category, and within a given type. FIXME:
-- Formerly this index didn't cover cl_type (since that didn't exist), so old
-- callers won't be using an index: fix this?
CREATE INDEX /*i*/cl_sortkey ON /*_*/categorylinks (cl_to,cl_type,cl_sortkey,cl_from);
-- Used by the API (and some extensions)
CREATE INDEX /*i*/cl_timestamp ON /*_*/categorylinks (cl_to,cl_timestamp);
-- Used when updating collation (e.g. updateCollation.php)
CREATE INDEX /*i*/cl_collation_ext ON /*_*/categorylinks (cl_collation, cl_to, cl_type, cl_from);

View file

@ -0,0 +1,25 @@
CREATE TABLE /*_*/imagelinks_tmp (
-- Key to page_id of the page containing the image / media link.
il_from int unsigned NOT NULL default 0,
-- Namespace for this page
il_from_namespace int NOT NULL default 0,
-- Filename of target image.
-- This is also the page_title of the file's description page;
-- all such pages are in namespace 6 (NS_FILE).
il_to varchar(255) binary NOT NULL default '',
PRIMARY KEY (il_from,il_to)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/imagelinks_tmp
SELECT * FROM /*_*/imagelinks;
DROP TABLE /*_*/imagelinks;
ALTER TABLE /*_*/imagelinks_tmp RENAME TO /*_*/imagelinks;
-- Reverse index, for Special:Whatlinkshere and file description page local usage
CREATE INDEX /*i*/il_to ON /*_*/imagelinks (il_to,il_from);
-- Index for Special:Whatlinkshere with namespace filter
CREATE INDEX /*i*/il_backlinks_namespace ON /*_*/imagelinks (il_from_namespace,il_to,il_from);

View file

@ -0,0 +1,24 @@
CREATE TABLE /*_*/iwlinks_tmp (
-- page_id of the referring page
iwl_from int unsigned NOT NULL default 0,
-- Interwiki prefix code of the target
iwl_prefix varbinary(20) NOT NULL default '',
-- Title of the target, including namespace
iwl_title varchar(255) binary NOT NULL default '',
PRIMARY KEY (iwl_from,iwl_prefix,iwl_title)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/iwlinks_tmp
SELECT * FROM /*_*/iwlinks;
DROP TABLE /*_*/iwlinks;
ALTER TABLE /*_*/iwlinks_tmp RENAME TO /*_*/iwlinks;
-- Index for ApiQueryIWBacklinks
CREATE INDEX /*i*/iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);
-- Index for ApiQueryIWLinks
CREATE INDEX /*i*/iwl_prefix_from_title ON /*_*/iwlinks (iwl_prefix, iwl_from, iwl_title);

View file

@ -0,0 +1,21 @@
CREATE TABLE /*_*/langlinks_tmp (
-- page_id of the referring page
ll_from int unsigned NOT NULL default 0,
-- Language code of the target
ll_lang varbinary(20) NOT NULL default '',
-- Title of the target, including namespace
ll_title varchar(255) binary NOT NULL default '',
PRIMARY KEY (ll_from,ll_lang)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/langlinks_tmp
SELECT * FROM /*_*/langlinks;
DROP TABLE /*_*/langlinks;
ALTER TABLE /*_*/langlinks_tmp RENAME TO /*_*/langlinks;
-- Index for ApiQueryLangbacklinks
CREATE INDEX /*i*/ll_lang ON /*_*/langlinks (ll_lang, ll_title);

View file

@ -0,0 +1,18 @@
CREATE TABLE /*_*/log_search_tmp (
-- The type of ID (rev ID, log ID, rev timestamp, username)
ls_field varbinary(32) NOT NULL,
-- The value of the ID
ls_value varchar(255) NOT NULL,
-- Key to log_id
ls_log_id int unsigned NOT NULL default 0,
PRIMARY KEY (ls_field,ls_value,ls_log_id)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/log_search_tmp
SELECT * FROM /*_*/log_search;
DROP TABLE /*_*/log_search;
ALTER TABLE /*_*/log_search_tmp RENAME TO /*_*/log_search;
CREATE INDEX /*i*/ls_log_id ON /*_*/log_search (ls_log_id);

View file

@ -0,0 +1,16 @@
CREATE TABLE /*_*/module_deps_tmp (
-- Module name
md_module varbinary(255) NOT NULL,
-- Module context vary (includes skin and language; called "md_skin" for legacy reasons)
md_skin varbinary(32) NOT NULL,
-- JSON blob with file dependencies
md_deps mediumblob NOT NULL,
PRIMARY KEY (md_module,md_skin)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/module_deps_tmp
SELECT * FROM /*_*/module_deps;
DROP TABLE /*_*/module_deps;
ALTER TABLE /*_*/module_deps_tmp RENAME TO /*_*/module_deps;

View file

@ -0,0 +1,14 @@
CREATE TABLE /*_*/objectcache_tmp (
keyname varbinary(255) NOT NULL default '' PRIMARY KEY,
value mediumblob,
exptime datetime
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/objectcache_tmp
SELECT * FROM /*_*/objectcache;
DROP TABLE /*_*/objectcache;
ALTER TABLE /*_*/objectcache_tmp RENAME TO /*_*/objectcache;
CREATE INDEX /*i*/exptime ON /*_*/objectcache (exptime);

View file

@ -0,0 +1,27 @@
CREATE TABLE /*_*/pagelinks_tmp (
-- Key to the page_id of the page containing the link.
pl_from int unsigned NOT NULL default 0,
-- Namespace for this page
pl_from_namespace int NOT NULL default 0,
-- Key to page_namespace/page_title of the target page.
-- The target page may or may not exist, and due to renames
-- and deletions may refer to different page records as time
-- goes by.
pl_namespace int NOT NULL default 0,
pl_title varchar(255) binary NOT NULL default '',
PRIMARY KEY (pl_from,pl_namespace,pl_title)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/pagelinks_tmp
SELECT * FROM /*_*/pagelinks;
DROP TABLE /*_*/pagelinks;
ALTER TABLE /*_*/pagelinks_tmp RENAME TO /*_*/pagelinks;
-- Reverse index, for Special:Whatlinkshere
CREATE INDEX /*i*/pl_namespace ON /*_*/pagelinks (pl_namespace,pl_title,pl_from);
-- Index for Special:Whatlinkshere with namespace filter
CREATE INDEX /*i*/pl_backlinks_namespace ON /*_*/pagelinks (pl_from_namespace,pl_namespace,pl_title,pl_from);

View file

@ -0,0 +1,15 @@
CREATE TABLE /*_*/querycache_info_tmp (
-- Special page name
-- Corresponds to a qc_type value
qci_type varbinary(32) NOT NULL default '' PRIMARY KEY,
-- Timestamp of last update
qci_timestamp binary(14) NOT NULL default '19700101000000'
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/querycache_info_tmp
SELECT * FROM /*_*/querycache_info;
DROP TABLE /*_*/querycache_info;
ALTER TABLE /*_*/querycache_info_tmp RENAME TO /*_*/querycache_info;

View file

@ -0,0 +1,33 @@
CREATE TABLE /*_*/site_stats_tmp (
-- The single row should contain 1 here.
ss_row_id int unsigned NOT NULL PRIMARY KEY,
-- Total number of edits performed.
ss_total_edits bigint unsigned default 0,
-- An approximate count of pages matching the following criteria:
-- * in namespace 0
-- * not a redirect
-- * contains the text '[['
-- See Article::isCountable() in includes/Article.php
ss_good_articles bigint unsigned default 0,
-- Total pages, theoretically equal to SELECT COUNT(*) FROM page; except faster
ss_total_pages bigint default '-1',
-- Number of users, theoretically equal to SELECT COUNT(*) FROM user;
ss_users bigint default '-1',
-- Number of users that still edit
ss_active_users bigint default '-1',
-- Number of images, equivalent to SELECT COUNT(*) FROM image
ss_images int default 0
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/site_stats_tmp
SELECT * FROM /*_*/site_stats;
DROP TABLE /*_*/site_stats;
ALTER TABLE /*_*/site_stats_tmp RENAME TO /*_*/site_stats;

View file

@ -0,0 +1,27 @@
CREATE TABLE /*_*/templatelinks_tmp (
-- Key to the page_id of the page containing the link.
tl_from int unsigned NOT NULL default 0,
-- Namespace for this page
tl_from_namespace int NOT NULL default 0,
-- Key to page_namespace/page_title of the target page.
-- The target page may or may not exist, and due to renames
-- and deletions may refer to different page records as time
-- goes by.
tl_namespace int NOT NULL default 0,
tl_title varchar(255) binary NOT NULL default '',
PRIMARY KEY (tl_from,tl_namespace,tl_title)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/templatelinks_tmp
SELECT * FROM /*_*/templatelinks;
DROP TABLE /*_*/templatelinks;
ALTER TABLE /*_*/templatelinks_tmp RENAME TO /*_*/templatelinks;
-- Reverse index, for Special:Whatlinkshere
CREATE INDEX /*i*/tl_namespace ON /*_*/templatelinks (tl_namespace,tl_title,tl_from);
-- Index for Special:Whatlinkshere with namespace filter
CREATE INDEX /*i*/tl_backlinks_namespace ON /*_*/templatelinks (tl_from_namespace,tl_namespace,tl_title,tl_from);

View file

@ -0,0 +1,37 @@
CREATE TABLE /*_*/text_tmp (
-- Unique text storage key number.
-- Note that the 'oldid' parameter used in URLs does *not*
-- refer to this number anymore, but to rev_id.
--
-- revision.rev_text_id is a key to this column
old_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
-- Depending on the contents of the old_flags field, the text
-- may be convenient plain text, or it may be funkily encoded.
old_text mediumblob NOT NULL,
-- Comma-separated list of flags:
-- gzip: text is compressed with PHP's gzdeflate() function.
-- utf-8: text was stored as UTF-8.
-- If $wgLegacyEncoding option is on, rows *without* this flag
-- will be converted to UTF-8 transparently at load time. Note
-- that due to a bug in a maintenance script, this flag may
-- have been stored as 'utf8' in some cases (T18841).
-- object: text field contained a serialized PHP object.
-- The object either contains multiple versions compressed
-- together to achieve a better compression ratio, or it refers
-- to another row where the text can be found.
-- external: text was stored in an external location specified by old_text.
-- Any additional flags apply to the data stored at that URL, not
-- the URL itself. The 'object' flag is *not* set for URLs of the
-- form 'DB://cluster/id/itemid', because the external storage
-- system itself decompresses these.
old_flags tinyblob NOT NULL
) /*$wgDBTableOptions*/ MAX_ROWS=10000000 AVG_ROW_LENGTH=10240;
INSERT INTO /*_*/text_tmp
SELECT * FROM /*_*/text;
DROP TABLE /*_*/text;
ALTER TABLE /*_*/text_tmp RENAME TO /*_*/text;

View file

@ -0,0 +1,12 @@
CREATE TABLE /*_*/transcache_tmp (
tc_url varbinary(255) NOT NULL PRIMARY KEY,
tc_contents text,
tc_time binary(14) NOT NULL
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/transcache_tmp
SELECT * FROM /*_*/transcache;
DROP TABLE /*_*/transcache;
ALTER TABLE /*_*/transcache_tmp RENAME TO /*_*/transcache;

View file

@ -0,0 +1,13 @@
CREATE TABLE /*_*/user_former_groups_tmp (
-- Key to user_id
ufg_user int unsigned NOT NULL default 0,
ufg_group varbinary(255) NOT NULL default '',
PRIMARY KEY (ufg_user,ufg_group)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/user_former_groups_tmp
SELECT * FROM /*_*/user_former_groups;
DROP TABLE /*_*/user_former_groups;
ALTER TABLE /*_*/user_former_groups_tmp RENAME TO /*_*/user_former_groups;

View file

@ -0,0 +1,20 @@
CREATE TABLE /*_*/user_properties_tmp (
-- Foreign key to user.user_id
up_user int NOT NULL,
-- Name of the option being saved. This is indexed for bulk lookup.
up_property varbinary(255) NOT NULL,
-- Property value as a string.
up_value blob,
PRIMARY KEY (up_user,up_property)
) /*$wgDBTableOptions*/;
INSERT INTO /*_*/user_properties_tmp
SELECT * FROM /*_*/user_properties;
DROP TABLE /*_*/user_properties;
ALTER TABLE /*_*/user_properties_tmp RENAME TO /*_*/user_properties;
CREATE INDEX /*i*/user_properties_property ON /*_*/user_properties (up_property);

View file

@ -178,11 +178,10 @@ CREATE INDEX /*i*/ug_expiry ON /*_*/user_groups (ug_expiry);
CREATE TABLE /*_*/user_former_groups (
-- Key to user_id
ufg_user int unsigned NOT NULL default 0,
ufg_group varbinary(255) NOT NULL default ''
ufg_group varbinary(255) NOT NULL default '',
PRIMARY KEY (ufg_user,ufg_group)
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/ufg_user_group ON /*_*/user_former_groups (ufg_user,ufg_group);
--
-- Stores notifications of user talk page changes, for the display
-- of the "you have new messages" box
@ -220,10 +219,10 @@ CREATE TABLE /*_*/user_properties (
up_property varbinary(255) NOT NULL,
-- Property value as a string.
up_value blob
up_value blob,
PRIMARY KEY (up_user,up_property)
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/user_properties_user_property ON /*_*/user_properties (up_user,up_property);
CREATE INDEX /*i*/user_properties_property ON /*_*/user_properties (up_property);
--
@ -576,12 +575,10 @@ CREATE TABLE /*_*/pagelinks (
-- and deletions may refer to different page records as time
-- goes by.
pl_namespace int NOT NULL default 0,
pl_title varchar(255) binary NOT NULL default ''
pl_title varchar(255) binary NOT NULL default '',
PRIMARY KEY (pl_from,pl_namespace,pl_title)
) /*$wgDBTableOptions*/;
-- Forward index, for page edit, save
CREATE UNIQUE INDEX /*i*/pl_from ON /*_*/pagelinks (pl_from,pl_namespace,pl_title);
-- Reverse index, for Special:Whatlinkshere
CREATE INDEX /*i*/pl_namespace ON /*_*/pagelinks (pl_namespace,pl_title,pl_from);
@ -603,12 +600,10 @@ CREATE TABLE /*_*/templatelinks (
-- and deletions may refer to different page records as time
-- goes by.
tl_namespace int NOT NULL default 0,
tl_title varchar(255) binary NOT NULL default ''
tl_title varchar(255) binary NOT NULL default '',
PRIMARY KEY (tl_from,tl_namespace,tl_title)
) /*$wgDBTableOptions*/;
-- Forward index, for page edit, save
CREATE UNIQUE INDEX /*i*/tl_from ON /*_*/templatelinks (tl_from,tl_namespace,tl_title);
-- Reverse index, for Special:Whatlinkshere
CREATE INDEX /*i*/tl_namespace ON /*_*/templatelinks (tl_namespace,tl_title,tl_from);
@ -630,12 +625,10 @@ CREATE TABLE /*_*/imagelinks (
-- Filename of target image.
-- This is also the page_title of the file's description page;
-- all such pages are in namespace 6 (NS_FILE).
il_to varchar(255) binary NOT NULL default ''
il_to varchar(255) binary NOT NULL default '',
PRIMARY KEY (il_from,il_to)
) /*$wgDBTableOptions*/;
-- Forward index, for cache invalidation on file update, etc.
CREATE UNIQUE INDEX /*i*/il_from ON /*_*/imagelinks (il_from,il_to);
-- Reverse index, for Special:Whatlinkshere and file description page local usage
CREATE INDEX /*i*/il_to ON /*_*/imagelinks (il_to,il_from);
@ -685,10 +678,10 @@ CREATE TABLE /*_*/categorylinks (
-- paginate the three categories separately. This never has to be updated
-- after the page is created, since none of these page types can be moved to
-- any other.
cl_type ENUM('page', 'subcat', 'file') NOT NULL default 'page'
cl_type ENUM('page', 'subcat', 'file') NOT NULL default 'page',
PRIMARY KEY (cl_from,cl_to)
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/cl_from ON /*_*/categorylinks (cl_from,cl_to);
-- We always sort within a given category, and within a given type. FIXME:
-- Formerly this index didn't cover cl_type (since that didn't exist), so old
@ -787,12 +780,10 @@ CREATE TABLE /*_*/langlinks (
ll_lang varbinary(20) NOT NULL default '',
-- Title of the target, including namespace
ll_title varchar(255) binary NOT NULL default ''
ll_title varchar(255) binary NOT NULL default '',
PRIMARY KEY (ll_from,ll_lang)
) /*$wgDBTableOptions*/;
-- Forward index, for page edit, save, ApiQueryLanglinks
CREATE UNIQUE INDEX /*i*/ll_from ON /*_*/langlinks (ll_from, ll_lang);
-- Index for ApiQueryLangbacklinks
CREATE INDEX /*i*/ll_lang ON /*_*/langlinks (ll_lang, ll_title);
@ -808,12 +799,10 @@ CREATE TABLE /*_*/iwlinks (
iwl_prefix varbinary(20) NOT NULL default '',
-- Title of the target, including namespace
iwl_title varchar(255) binary NOT NULL default ''
iwl_title varchar(255) binary NOT NULL default '',
PRIMARY KEY (iwl_from,iwl_prefix,iwl_title)
) /*$wgDBTableOptions*/;
-- Forward index, for page edit, save, ApiQueryIWLinks
CREATE UNIQUE INDEX /*i*/iwl_from ON /*_*/iwlinks (iwl_from, iwl_prefix, iwl_title);
-- Index for ApiQueryIWBacklinks
CREATE INDEX /*i*/iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);
@ -827,7 +816,7 @@ CREATE INDEX /*i*/iwl_prefix_from_title ON /*_*/iwlinks (iwl_prefix, iwl_from, i
--
CREATE TABLE /*_*/site_stats (
-- The single row should contain 1 here.
ss_row_id int unsigned NOT NULL,
ss_row_id int unsigned NOT NULL PRIMARY KEY,
-- Total number of edits performed.
ss_total_edits bigint unsigned default 0,
@ -852,9 +841,6 @@ CREATE TABLE /*_*/site_stats (
ss_images int default 0
) /*$wgDBTableOptions*/;
-- Pointless index to assuage developer superstitions
CREATE UNIQUE INDEX /*i*/ss_row_id ON /*_*/site_stats (ss_row_id);
--
-- The internet is full of jerks, alas. Sometimes it's handy
-- to block a vandal or troll account.
@ -1381,13 +1367,11 @@ CREATE INDEX /*i*/exptime ON /*_*/objectcache (exptime);
-- Cache of interwiki transclusion
--
CREATE TABLE /*_*/transcache (
tc_url varbinary(255) NOT NULL,
tc_url varbinary(255) NOT NULL PRIMARY KEY,
tc_contents text,
tc_time binary(14) NOT NULL
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/tc_url_idx ON /*_*/transcache (tc_url);
CREATE TABLE /*_*/logging (
-- Log ID, for referring to this specific log entry, probably for deletion and such.
@ -1460,9 +1444,9 @@ CREATE TABLE /*_*/log_search (
-- The value of the ID
ls_value varchar(255) NOT NULL,
-- Key to log_id
ls_log_id int unsigned NOT NULL default 0
ls_log_id int unsigned NOT NULL default 0,
PRIMARY KEY (ls_field,ls_value,ls_log_id)
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/ls_field_val ON /*_*/log_search (ls_field,ls_value,ls_log_id);
CREATE INDEX /*i*/ls_log_id ON /*_*/log_search (ls_log_id);
@ -1514,14 +1498,12 @@ CREATE INDEX /*i*/job_timestamp ON /*_*/job (job_timestamp);
CREATE TABLE /*_*/querycache_info (
-- Special page name
-- Corresponds to a qc_type value
qci_type varbinary(32) NOT NULL default '',
qci_type varbinary(32) NOT NULL default '' PRIMARY KEY,
-- Timestamp of last update
qci_timestamp binary(14) NOT NULL default '19700101000000'
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/qci_type ON /*_*/querycache_info (qci_type);
-- For each redirect, this table contains exactly one row defining its target
CREATE TABLE /*_*/redirect (
@ -1686,9 +1668,9 @@ CREATE TABLE /*_*/module_deps (
-- Module context vary (includes skin and language; called "md_skin" for legacy reasons)
md_skin varbinary(32) NOT NULL,
-- JSON blob with file dependencies
md_deps mediumblob NOT NULL
md_deps mediumblob NOT NULL,
PRIMARY KEY (md_module,md_skin)
) /*$wgDBTableOptions*/;
CREATE UNIQUE INDEX /*i*/md_module_skin ON /*_*/module_deps (md_module, md_skin);
-- Holds all the sites known to the wiki.
CREATE TABLE /*_*/sites (