r45894 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45893‎ | r45894 | r45895 >
Date:14:12, 19 January 2009
Author:catrope
Status:ok
Tags:
Comment:
Partial redo of r45819:
* rename non-PRIMARY indices that were implicitly named before r45764 back to their implicit names
* add the renamed un_user_id and un_user_ip to the indexName() rewrite
* use consistent casing for PRIMARY KEY
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tables.sql
@@ -408,7 +408,7 @@
409409 ) /*$wgDBTableOptions*/;
410410
411411 CREATE UNIQUE INDEX /*i*/pl_from ON /*_*/pagelinks (pl_from,pl_namespace,pl_title);
412 -CREATE INDEX /*i*/pl_namespace_title ON /*_*/pagelinks (pl_namespace,pl_title,pl_from);
 412+CREATE INDEX /*i*/pl_namespace ON /*_*/pagelinks (pl_namespace,pl_title,pl_from);
413413
414414
415415 --
@@ -427,7 +427,7 @@
428428 ) /*$wgDBTableOptions*/;
429429
430430 CREATE UNIQUE INDEX /*i*/tl_from ON /*_*/templatelinks (tl_from,tl_namespace,tl_title);
431 -CREATE INDEX /*i*/tl_namespace_title ON /*_*/templatelinks (tl_namespace,tl_title,tl_from);
 431+CREATE INDEX /*i*/tl_namespace ON /*_*/templatelinks (tl_namespace,tl_title,tl_from);
432432
433433
434434 --
@@ -563,7 +563,7 @@
564564 ) /*$wgDBTableOptions*/;
565565
566566 CREATE UNIQUE INDEX /*i*/ll_from ON /*_*/langlinks (ll_from, ll_lang);
567 -CREATE INDEX /*i*/ll_lang_title ON /*_*/langlinks (ll_lang, ll_title);
 567+CREATE INDEX /*i*/ll_lang ON /*_*/langlinks (ll_lang, ll_title);
568568
569569
570570 --
@@ -697,7 +697,7 @@
698698 -- Filename.
699699 -- This is also the title of the associated description page,
700700 -- which will be in namespace 6 (NS_FILE).
701 - img_name varchar(255) binary NOT NULL default '' primary key,
 701+ img_name varchar(255) binary NOT NULL default '' PRIMARY KEY,
702702
703703 -- File size in bytes.
704704 img_size int unsigned NOT NULL default 0,
@@ -838,7 +838,7 @@
839839 -- pick out by image name
840840 CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
841841 -- pick out dupe files
842 -CREATE INDEX /*i*/fa_group_key ON /*_*/filearchive (fa_storage_group, fa_storage_key);
 842+CREATE INDEX /*i*/fa_storage_group ON /*_*/filearchive (fa_storage_group, fa_storage_key);
843843 -- sort by deletion time
844844 CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
845845 -- sort by uploader
@@ -943,7 +943,7 @@
944944
945945 ) /*$wgDBTableOptions*/;
946946
947 -CREATE UNIQUE INDEX /*i*/wl_user_namespace_title ON /*_*/watchlist (wl_user, wl_namespace, wl_title);
 947+CREATE UNIQUE INDEX /*i*/wl_user ON /*_*/watchlist (wl_user, wl_namespace, wl_title);
948948 CREATE INDEX /*i*/namespace_title ON /*_*/watchlist (wl_namespace, wl_title);
949949
950950
@@ -1034,18 +1034,18 @@
10351035 qc_title varchar(255) binary NOT NULL default ''
10361036 ) /*$wgDBTableOptions*/;
10371037
1038 -CREATE INDEX /*i*/qc_type_value ON /*_*/querycache (qc_type,qc_value);
 1038+CREATE INDEX /*i*/qc_type ON /*_*/querycache (qc_type,qc_value);
10391039
10401040
10411041 --
10421042 -- For a few generic cache operations if not using Memcached
10431043 --
10441044 CREATE TABLE /*_*/objectcache (
1045 - keyname varbinary(255) NOT NULL default '' primary key,
 1045+ keyname varbinary(255) NOT NULL default '' PRIMARY KEY,
10461046 value mediumblob,
10471047 exptime datetime
10481048 ) /*$wgDBTableOptions*/;
1049 -CREATE INDEX /*i*/oc_exptime ON /*_*/objectcache (exptime);
 1049+CREATE INDEX /*i*/exptime ON /*_*/objectcache (exptime);
10501050
10511051
10521052 --
@@ -1126,7 +1126,7 @@
11271127 job_params blob NOT NULL
11281128 ) /*$wgDBTableOptions*/;
11291129
1130 -CREATE INDEX /*i*/job_cmd_namespace_title ON /*_*/job (job_cmd, job_namespace, job_title);
 1130+CREATE INDEX /*i*/job_cmd ON /*_*/job (job_cmd, job_namespace, job_title);
11311131
11321132
11331133 -- Details of updates to cached special pages
@@ -1145,7 +1145,7 @@
11461146 -- For each redirect, this table contains exactly one row defining its target
11471147 CREATE TABLE /*_*/redirect (
11481148 -- Key to the page_id of the redirect page
1149 - rd_from int unsigned NOT NULL default 0 primary key,
 1149+ rd_from int unsigned NOT NULL default 0 PRIMARY KEY,
11501150
11511151 -- Key to page_namespace/page_title of the target page.
11521152 -- The target page may or may not exist, and due to renames
@@ -1231,7 +1231,7 @@
12321232
12331233 -- A table to log updates, one text key row per update.
12341234 CREATE TABLE /*_*/updatelog (
1235 - ul_key varchar(255) NOT NULL primary key
 1235+ ul_key varchar(255) NOT NULL PRIMARY KEY
12361236 ) /*$wgDBTableOptions*/;
12371237
12381238 -- vim: sw=2 sts=2 et
Index: trunk/phase3/includes/db/Database.php
@@ -1579,8 +1579,13 @@
15801580 */
15811581 function indexName( $index ) {
15821582 // Backwards-compatibility hack
1583 - if ( $index == 'ar_usertext_timestamp' ) {
1584 - return 'usertext_timestamp';
 1583+ $renamed = array(
 1584+ 'ar_usertext_timestamp' => 'usertext_timestamp',
 1585+ 'un_user_id' => 'user_id',
 1586+ 'un_user_ip' => 'user_ip',
 1587+ );
 1588+ if( isset( $renamed[$index] ) ) {
 1589+ return $renamed[$index];
15851590 } else {
15861591 return $index;
15871592 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45764For backport to 1.14....tstarling06:56, 15 January 2009
r45819Attempt at cleaning up r45764, r45769 (renamed indices for SQLite compat):...catrope23:02, 16 January 2009

Status & tagging log