r45819 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45818‎ | r45819 | r45820 >
Date:23:02, 16 January 2009
Author:catrope
Status:reverted (Comments)
Tags:
Comment:
Attempt at cleaning up r45764, r45769 (renamed indices for SQLite compat):
* removing the indexName() hack and with it the /*i*/ stuff from tables.sql
* undoing renames of formerly implicitly named indices
* three indices have to be called different in SQLite because of naming conflicts, adding a patch to updaters.inc that does that
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-index-renames.sql (added) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/Database.php
@@ -1575,18 +1575,6 @@
15761576 }
15771577
15781578 /**
1579 - * Get the name of an index in a given table
1580 - */
1581 - function indexName( $index ) {
1582 - // Backwards-compatibility hack
1583 - if ( $index == 'ar_usertext_timestamp' ) {
1584 - return 'usertext_timestamp';
1585 - } else {
1586 - return $index;
1587 - }
1588 - }
1589 -
1590 - /**
15911579 * Wrapper for addslashes()
15921580 * @param $s String: to be slashed.
15931581 * @return String: slashed string.
@@ -1634,7 +1622,7 @@
16351623 * PostgreSQL doesn't have them and returns ""
16361624 */
16371625 function useIndexClause( $index ) {
1638 - return "FORCE INDEX (" . $this->indexName( $index ) . ")";
 1626+ return "FORCE INDEX (" . $index . ")";
16391627 }
16401628
16411629 /**
@@ -2274,9 +2262,6 @@
22752263 $ins = preg_replace_callback( '!/\*(?:\$wgDBprefix|_)\*/([a-zA-Z_0-9]*)!',
22762264 array( $this, 'tableNameCallback' ), $ins );
22772265
2278 - // Index names
2279 - $ins = preg_replace_callback( '!/\*i\*/([a-zA-Z_0-9]*)!',
2280 - array( $this, 'indexNameCallback' ), $ins );
22812266 return $ins;
22822267 }
22832268
@@ -2288,13 +2273,6 @@
22892274 return $this->tableName( $matches[1] );
22902275 }
22912276
2292 - /**
2293 - * Index name callback
2294 - */
2295 - protected function indexNameCallback( $matches ) {
2296 - return $this->indexName( $matches[1] );
2297 - }
2298 -
22992277 /*
23002278 * Build a concatenation list to feed into a SQL query
23012279 */
Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -157,13 +157,6 @@
158158 }
159159
160160 /**
161 - * Index names have DB scope
162 - */
163 - function indexName( $index ) {
164 - return $index;
165 - }
166 -
167 - /**
168161 * This must be called after nextSequenceVal
169162 */
170163 function insertId() {
Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -698,7 +698,7 @@
699699 return NULL;
700700 }
701701 while ( $row = $this->fetchObject( $res ) ) {
702 - if ( $row->indexname == $this->indexName( $index ) ) {
 702+ if ( $row->indexname == $index ) {
703703 return $row;
704704 }
705705 }
@@ -708,7 +708,7 @@
709709 function indexUnique ($table, $index, $fname = 'Database::indexUnique' ) {
710710 $sql = "SELECT indexname FROM pg_indexes WHERE tablename='{$table}'".
711711 " AND indexdef LIKE 'CREATE UNIQUE%(" .
712 - $this->strencode( $this->indexName( $index ) ) .
 712+ $this->strencode( $index ) .
713713 ")'";
714714 $res = $this->query( $sql, $fname );
715715 if ( !$res )
Index: trunk/phase3/maintenance/archives/patch-index-renames.sql
@@ -0,0 +1,11 @@
 2+--
 3+-- patch-index-renames.sql
 4+--
 5+-- Rename three indices because of naming conflicts
 6+
 7+DROP INDEX user_id ON /*_*/user_newtalk;
 8+DROP INDEX user_ip ON /*_*/user_newtalk;
 9+DROP INDEX usertext_timestamp ON /*_*/archive;
 10+CREATE INDEX un_user_id ON /*_*/user_newtalk (user_id);
 11+CREATE INDEX un_user_ip ON /*_*/user_newtalk (user_ip);
 12+CREATE INDEX ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
\ No newline at end of file
Index: trunk/phase3/maintenance/updaters.inc
@@ -149,6 +149,7 @@
150150 array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ),
151151 array( 'do_active_users_init' ),
152152 array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ),
 153+ array( 'add_index', 'user_newtalk', 'un_user_id', 'patch-index-renames.sql' ),
153154 ),
154155
155156 'sqlite' => array(
Index: trunk/phase3/maintenance/tables.sql
@@ -129,8 +129,8 @@
130130 user_editcount int
131131 ) /*$wgDBTableOptions*/;
132132
133 -CREATE UNIQUE INDEX /*i*/user_name ON /*_*/user (user_name);
134 -CREATE INDEX /*i*/user_email_token ON /*_*/user (user_email_token);
 133+CREATE UNIQUE INDEX user_name ON /*_*/user (user_name);
 134+CREATE INDEX user_email_token ON /*_*/user (user_email_token);
135135
136136
137137 --
@@ -156,8 +156,8 @@
157157 ug_group varbinary(16) NOT NULL default ''
158158 ) /*$wgDBTableOptions*/;
159159
160 -CREATE UNIQUE INDEX /*i*/ug_user_group ON /*_*/user_groups (ug_user,ug_group);
161 -CREATE INDEX /*i*/ug_group ON /*_*/user_groups (ug_group);
 160+CREATE UNIQUE INDEX ug_user_group ON /*_*/user_groups (ug_user,ug_group);
 161+CREATE INDEX ug_group ON /*_*/user_groups (ug_group);
162162
163163
164164 -- Stores notifications of user talk page changes, for the display
@@ -174,8 +174,8 @@
175175 ) /*$wgDBTableOptions*/;
176176
177177 -- Indexes renamed for SQLite in 1.14
178 -CREATE INDEX /*i*/un_user_id ON /*_*/user_newtalk (user_id);
179 -CREATE INDEX /*i*/un_user_ip ON /*_*/user_newtalk (user_ip);
 178+CREATE INDEX un_user_id ON /*_*/user_newtalk (user_id);
 179+CREATE INDEX un_user_ip ON /*_*/user_newtalk (user_ip);
180180
181181
182182 --
@@ -229,9 +229,9 @@
230230 page_len int unsigned NOT NULL
231231 ) /*$wgDBTableOptions*/;
232232
233 -CREATE UNIQUE INDEX /*i*/name_title ON /*_*/page (page_namespace,page_title);
234 -CREATE INDEX /*i*/page_random ON /*_*/page (page_random);
235 -CREATE INDEX /*i*/page_len ON /*_*/page (page_len);
 233+CREATE UNIQUE INDEX name_title ON /*_*/page (page_namespace,page_title);
 234+CREATE INDEX page_random ON /*_*/page (page_random);
 235+CREATE INDEX page_len ON /*_*/page (page_len);
236236
237237
238238 --
@@ -283,11 +283,11 @@
284284 ) /*$wgDBTableOptions*/ MAX_ROWS=10000000 AVG_ROW_LENGTH=1024;
285285 -- In case tables are created as MyISAM, use row hints for MySQL <5.0 to avoid 4GB limit
286286
287 -CREATE UNIQUE INDEX /*i*/rev_page_id ON /*_*/revision (rev_page, rev_id);
288 -CREATE INDEX /*i*/rev_timestamp ON /*_*/revision (rev_timestamp);
289 -CREATE INDEX /*i*/page_timestamp ON /*_*/revision (rev_page,rev_timestamp);
290 -CREATE INDEX /*i*/user_timestamp ON /*_*/revision (rev_user,rev_timestamp);
291 -CREATE INDEX /*i*/usertext_timestamp ON /*_*/revision (rev_user_text,rev_timestamp);
 287+CREATE UNIQUE INDEX rev_page_id ON /*_*/revision (rev_page, rev_id);
 288+CREATE INDEX rev_timestamp ON /*_*/revision (rev_timestamp);
 289+CREATE INDEX page_timestamp ON /*_*/revision (rev_page,rev_timestamp);
 290+CREATE INDEX user_timestamp ON /*_*/revision (rev_user,rev_timestamp);
 291+CREATE INDEX usertext_timestamp ON /*_*/revision (rev_user_text,rev_timestamp);
292292
293293 --
294294 -- Holds text of individual page revisions.
@@ -388,8 +388,8 @@
389389 ar_parent_id int unsigned default NULL
390390 ) /*$wgDBTableOptions*/;
391391
392 -CREATE INDEX /*i*/name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
393 -CREATE INDEX /*i*/ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
 392+CREATE INDEX name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
 393+CREATE INDEX ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
394394
395395
396396 --
@@ -407,8 +407,8 @@
408408 pl_title varchar(255) binary NOT NULL default ''
409409 ) /*$wgDBTableOptions*/;
410410
411 -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);
 411+CREATE UNIQUE INDEX pl_from ON /*_*/pagelinks (pl_from,pl_namespace,pl_title);
 412+CREATE INDEX pl_namespace ON /*_*/pagelinks (pl_namespace,pl_title,pl_from);
413413
414414
415415 --
@@ -426,8 +426,8 @@
427427 tl_title varchar(255) binary NOT NULL default ''
428428 ) /*$wgDBTableOptions*/;
429429
430 -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);
 430+CREATE UNIQUE INDEX tl_from ON /*_*/templatelinks (tl_from,tl_namespace,tl_title);
 431+CREATE INDEX tl_namespace ON /*_*/templatelinks (tl_namespace,tl_title,tl_from);
432432
433433
434434 --
@@ -445,8 +445,8 @@
446446 il_to varchar(255) binary NOT NULL default ''
447447 ) /*$wgDBTableOptions*/;
448448
449 -CREATE UNIQUE INDEX /*i*/il_from ON /*_*/imagelinks (il_from,il_to);
450 -CREATE INDEX /*i*/il_to ON /*_*/imagelinks (il_to,il_from);
 449+CREATE UNIQUE INDEX il_from ON /*_*/imagelinks (il_from,il_to);
 450+CREATE INDEX il_to ON /*_*/imagelinks (il_to,il_from);
451451
452452
453453 --
@@ -477,13 +477,13 @@
478478 cl_timestamp timestamp NOT NULL
479479 ) /*$wgDBTableOptions*/;
480480
481 -CREATE UNIQUE INDEX /*i*/cl_from ON /*_*/categorylinks (cl_from,cl_to);
 481+CREATE UNIQUE INDEX cl_from ON /*_*/categorylinks (cl_from,cl_to);
482482
483483 -- We always sort within a given category...
484 -CREATE INDEX /*i*/cl_sortkey ON /*_*/categorylinks (cl_to,cl_sortkey,cl_from);
 484+CREATE INDEX cl_sortkey ON /*_*/categorylinks (cl_to,cl_sortkey,cl_from);
485485
486486 -- Not really used?
487 -CREATE INDEX /*i*/cl_timestamp ON /*_*/categorylinks (cl_to,cl_timestamp);
 487+CREATE INDEX cl_timestamp ON /*_*/categorylinks (cl_to,cl_timestamp);
488488
489489
490490 --
@@ -513,10 +513,10 @@
514514 cat_hidden tinyint unsigned NOT NULL default 0
515515 ) /*$wgDBTableOptions*/;
516516
517 -CREATE UNIQUE INDEX /*i*/cat_title ON /*_*/category (cat_title);
 517+CREATE UNIQUE INDEX cat_title ON /*_*/category (cat_title);
518518
519519 -- For Special:Mostlinkedcategories
520 -CREATE INDEX /*i*/cat_pages ON /*_*/category (cat_pages);
 520+CREATE INDEX cat_pages ON /*_*/category (cat_pages);
521521
522522
523523 --
@@ -543,9 +543,9 @@
544544 el_index blob NOT NULL
545545 ) /*$wgDBTableOptions*/;
546546
547 -CREATE INDEX /*i*/el_from ON /*_*/externallinks (el_from, el_to(40));
548 -CREATE INDEX /*i*/el_to ON /*_*/externallinks (el_to(60), el_from);
549 -CREATE INDEX /*i*/el_index ON /*_*/externallinks (el_index(60));
 547+CREATE INDEX el_from ON /*_*/externallinks (el_from, el_to(40));
 548+CREATE INDEX el_to ON /*_*/externallinks (el_to(60), el_from);
 549+CREATE INDEX el_index ON /*_*/externallinks (el_index(60));
550550
551551
552552 --
@@ -562,8 +562,8 @@
563563 ll_title varchar(255) binary NOT NULL default ''
564564 ) /*$wgDBTableOptions*/;
565565
566 -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);
 566+CREATE UNIQUE INDEX ll_from ON /*_*/langlinks (ll_from, ll_lang);
 567+CREATE INDEX ll_lang_title ON /*_*/langlinks (ll_lang, ll_title);
568568
569569
570570 --
@@ -604,7 +604,7 @@
605605 ) /*$wgDBTableOptions*/;
606606
607607 -- Pointless index to assuage developer superstitions
608 -CREATE UNIQUE INDEX /*i*/ss_row_id ON /*_*/site_stats (ss_row_id);
 608+CREATE UNIQUE INDEX ss_row_id ON /*_*/site_stats (ss_row_id);
609609
610610
611611 --
@@ -682,12 +682,12 @@
683683
684684 -- Unique index to support "user already blocked" messages
685685 -- Any new options which prevent collisions should be included
686 -CREATE UNIQUE INDEX /*i*/ipb_address ON /*_*/ipblocks (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only);
 686+CREATE UNIQUE INDEX ipb_address ON /*_*/ipblocks (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only);
687687
688 -CREATE INDEX /*i*/ipb_user ON /*_*/ipblocks (ipb_user);
689 -CREATE INDEX /*i*/ipb_range ON /*_*/ipblocks (ipb_range_start(8), ipb_range_end(8));
690 -CREATE INDEX /*i*/ipb_timestamp ON /*_*/ipblocks (ipb_timestamp);
691 -CREATE INDEX /*i*/ipb_expiry ON /*_*/ipblocks (ipb_expiry);
 688+CREATE INDEX ipb_user ON /*_*/ipblocks (ipb_user);
 689+CREATE INDEX ipb_range ON /*_*/ipblocks (ipb_range_start(8), ipb_range_end(8));
 690+CREATE INDEX ipb_timestamp ON /*_*/ipblocks (ipb_timestamp);
 691+CREATE INDEX ipb_expiry ON /*_*/ipblocks (ipb_expiry);
692692
693693
694694 --
@@ -740,13 +740,13 @@
741741 img_sha1 varbinary(32) NOT NULL default ''
742742 ) /*$wgDBTableOptions*/;
743743
744 -CREATE INDEX /*i*/img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
 744+CREATE INDEX img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
745745 -- Used by Special:Imagelist for sort-by-size
746 -CREATE INDEX /*i*/img_size ON /*_*/image (img_size);
 746+CREATE INDEX img_size ON /*_*/image (img_size);
747747 -- Used by Special:Newimages and Special:Imagelist
748 -CREATE INDEX /*i*/img_timestamp ON /*_*/image (img_timestamp);
 748+CREATE INDEX img_timestamp ON /*_*/image (img_timestamp);
749749 -- Used in API and duplicate search
750 -CREATE INDEX /*i*/img_sha1 ON /*_*/image (img_sha1);
 750+CREATE INDEX img_sha1 ON /*_*/image (img_sha1);
751751
752752
753753 --
@@ -780,11 +780,11 @@
781781 oi_sha1 varbinary(32) NOT NULL default ''
782782 ) /*$wgDBTableOptions*/;
783783
784 -CREATE INDEX /*i*/oi_usertext_timestamp ON /*_*/oldimage (oi_user_text,oi_timestamp);
785 -CREATE INDEX /*i*/oi_name_timestamp ON /*_*/oldimage (oi_name,oi_timestamp);
 784+CREATE INDEX oi_usertext_timestamp ON /*_*/oldimage (oi_user_text,oi_timestamp);
 785+CREATE INDEX oi_name_timestamp ON /*_*/oldimage (oi_name,oi_timestamp);
786786 -- oi_archive_name truncated to 14 to avoid key length overflow
787 -CREATE INDEX /*i*/oi_name_archive_name ON /*_*/oldimage (oi_name,oi_archive_name(14));
788 -CREATE INDEX /*i*/oi_sha1 ON /*_*/oldimage (oi_sha1);
 787+CREATE INDEX oi_name_archive_name ON /*_*/oldimage (oi_name,oi_archive_name(14));
 788+CREATE INDEX oi_sha1 ON /*_*/oldimage (oi_sha1);
789789
790790
791791 --
@@ -836,13 +836,13 @@
837837 ) /*$wgDBTableOptions*/;
838838
839839 -- pick out by image name
840 -CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
 840+CREATE INDEX 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 fa_storage_group ON /*_*/filearchive (fa_storage_group, fa_storage_key);
843843 -- sort by deletion time
844 -CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
 844+CREATE INDEX fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
845845 -- sort by uploader
846 -CREATE INDEX /*i*/fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
 846+CREATE INDEX fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
847847
848848
849849 --
@@ -918,13 +918,13 @@
919919 rc_params blob NULL
920920 ) /*$wgDBTableOptions*/;
921921
922 -CREATE INDEX /*i*/rc_timestamp ON /*_*/recentchanges (rc_timestamp);
923 -CREATE INDEX /*i*/rc_namespace_title ON /*_*/recentchanges (rc_namespace, rc_title);
924 -CREATE INDEX /*i*/rc_cur_id ON /*_*/recentchanges (rc_cur_id);
925 -CREATE INDEX /*i*/new_name_timestamp ON /*_*/recentchanges (rc_new,rc_namespace,rc_timestamp);
926 -CREATE INDEX /*i*/rc_ip ON /*_*/recentchanges (rc_ip);
927 -CREATE INDEX /*i*/rc_ns_usertext ON /*_*/recentchanges (rc_namespace, rc_user_text);
928 -CREATE INDEX /*i*/rc_user_text ON /*_*/recentchanges (rc_user_text, rc_timestamp);
 922+CREATE INDEX rc_timestamp ON /*_*/recentchanges (rc_timestamp);
 923+CREATE INDEX rc_namespace_title ON /*_*/recentchanges (rc_namespace, rc_title);
 924+CREATE INDEX rc_cur_id ON /*_*/recentchanges (rc_cur_id);
 925+CREATE INDEX new_name_timestamp ON /*_*/recentchanges (rc_new,rc_namespace,rc_timestamp);
 926+CREATE INDEX rc_ip ON /*_*/recentchanges (rc_ip);
 927+CREATE INDEX rc_ns_usertext ON /*_*/recentchanges (rc_namespace, rc_user_text);
 928+CREATE INDEX rc_user_text ON /*_*/recentchanges (rc_user_text, rc_timestamp);
929929
930930
931931 CREATE TABLE /*_*/watchlist (
@@ -943,8 +943,8 @@
944944
945945 ) /*$wgDBTableOptions*/;
946946
947 -CREATE UNIQUE INDEX /*i*/wl_user_namespace_title ON /*_*/watchlist (wl_user, wl_namespace, wl_title);
948 -CREATE INDEX /*i*/namespace_title ON /*_*/watchlist (wl_namespace, wl_title);
 947+CREATE UNIQUE INDEX wl_user ON /*_*/watchlist (wl_user, wl_namespace, wl_title);
 948+CREATE INDEX namespace_title ON /*_*/watchlist (wl_namespace, wl_title);
949949
950950
951951 --
@@ -969,7 +969,7 @@
970970 math_mathml text
971971 ) /*$wgDBTableOptions*/;
972972
973 -CREATE UNIQUE INDEX /*i*/math_inputhash ON /*_*/math (math_inputhash);
 973+CREATE UNIQUE INDEX math_inputhash ON /*_*/math (math_inputhash);
974974
975975
976976 --
@@ -991,9 +991,9 @@
992992 si_text mediumtext NOT NULL
993993 ) ENGINE=MyISAM;
994994
995 -CREATE UNIQUE INDEX /*i*/si_page ON /*_*/searchindex (si_page);
996 -CREATE FULLTEXT INDEX /*i*/si_title ON /*_*/searchindex (si_title);
997 -CREATE FULLTEXT INDEX /*i*/si_text ON /*_*/searchindex (si_text);
 995+CREATE UNIQUE INDEX si_page ON /*_*/searchindex (si_page);
 996+CREATE FULLTEXT INDEX si_title ON /*_*/searchindex (si_title);
 997+CREATE FULLTEXT INDEX si_text ON /*_*/searchindex (si_text);
998998
999999
10001000 --
@@ -1016,7 +1016,7 @@
10171017 iw_trans tinyint NOT NULL default 0
10181018 ) /*$wgDBTableOptions*/;
10191019
1020 -CREATE UNIQUE INDEX /*i*/iw_prefix ON /*_*/interwiki (iw_prefix);
 1020+CREATE UNIQUE INDEX iw_prefix ON /*_*/interwiki (iw_prefix);
10211021
10221022
10231023 --
@@ -1034,7 +1034,7 @@
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 qc_type ON /*_*/querycache (qc_type,qc_value);
10391039
10401040
10411041 --
@@ -1045,7 +1045,7 @@
10461046 value mediumblob,
10471047 exptime datetime
10481048 ) /*$wgDBTableOptions*/;
1049 -CREATE INDEX /*i*/oc_exptime ON /*_*/objectcache (exptime);
 1049+CREATE INDEX exptime ON /*_*/objectcache (exptime);
10501050
10511051
10521052 --
@@ -1057,7 +1057,7 @@
10581058 tc_time int NOT NULL
10591059 ) /*$wgDBTableOptions*/;
10601060
1061 -CREATE UNIQUE INDEX /*i*/tc_url_idx ON /*_*/transcache (tc_url);
 1061+CREATE UNIQUE INDEX tc_url_idx ON /*_*/transcache (tc_url);
10621062
10631063
10641064 CREATE TABLE /*_*/logging (
@@ -1091,10 +1091,10 @@
10921092 log_deleted tinyint unsigned NOT NULL default 0
10931093 ) /*$wgDBTableOptions*/;
10941094
1095 -CREATE INDEX /*i*/type_time ON /*_*/logging (log_type, log_timestamp);
1096 -CREATE INDEX /*i*/user_time ON /*_*/logging (log_user, log_timestamp);
1097 -CREATE INDEX /*i*/page_time ON /*_*/logging (log_namespace, log_title, log_timestamp);
1098 -CREATE INDEX /*i*/times ON /*_*/logging (log_timestamp);
 1095+CREATE INDEX type_time ON /*_*/logging (log_type, log_timestamp);
 1096+CREATE INDEX user_time ON /*_*/logging (log_user, log_timestamp);
 1097+CREATE INDEX page_time ON /*_*/logging (log_namespace, log_title, log_timestamp);
 1098+CREATE INDEX times ON /*_*/logging (log_timestamp);
10991099
11001100
11011101 CREATE TABLE /*_*/trackbacks (
@@ -1105,7 +1105,7 @@
11061106 tb_ex text,
11071107 tb_name varchar(255)
11081108 ) /*$wgDBTableOptions*/;
1109 -CREATE INDEX /*i*/tb_page ON /*_*/trackbacks (tb_page);
 1109+CREATE INDEX tb_page ON /*_*/trackbacks (tb_page);
11101110
11111111
11121112 -- Jobs performed by parallel apache threads or a command-line daemon
@@ -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 job_cmd ON /*_*/job (job_cmd, job_namespace, job_title);
11311131
11321132
11331133 -- Details of updates to cached special pages
@@ -1139,7 +1139,7 @@
11401140 qci_timestamp binary(14) NOT NULL default '19700101000000'
11411141 ) /*$wgDBTableOptions*/;
11421142
1143 -CREATE UNIQUE INDEX /*i*/qci_type ON /*_*/querycache_info (qci_type);
 1143+CREATE UNIQUE INDEX qci_type ON /*_*/querycache_info (qci_type);
11441144
11451145
11461146 -- For each redirect, this table contains exactly one row defining its target
@@ -1155,7 +1155,7 @@
11561156 rd_title varchar(255) binary NOT NULL default ''
11571157 ) /*$wgDBTableOptions*/;
11581158
1159 -CREATE INDEX /*i*/rd_ns_title ON /*_*/redirect (rd_namespace,rd_title,rd_from);
 1159+CREATE INDEX rd_ns_title ON /*_*/redirect (rd_namespace,rd_title,rd_from);
11601160
11611161
11621162 -- Used for caching expensive grouped queries that need two links (for example double-redirects)
@@ -1175,9 +1175,9 @@
11761176 qcc_titletwo varchar(255) binary NOT NULL default ''
11771177 ) /*$wgDBTableOptions*/;
11781178
1179 -CREATE INDEX /*i*/qcc_type ON /*_*/querycachetwo (qcc_type,qcc_value);
1180 -CREATE INDEX /*i*/qcc_title ON /*_*/querycachetwo (qcc_type,qcc_namespace,qcc_title);
1181 -CREATE INDEX /*i*/qcc_titletwo ON /*_*/querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
 1179+CREATE INDEX qcc_type ON /*_*/querycachetwo (qcc_type,qcc_value);
 1180+CREATE INDEX qcc_title ON /*_*/querycachetwo (qcc_type,qcc_namespace,qcc_title);
 1181+CREATE INDEX qcc_titletwo ON /*_*/querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
11821182
11831183
11841184 -- Used for storing page restrictions (i.e. protection levels)
@@ -1198,10 +1198,10 @@
11991199 pr_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT
12001200 ) /*$wgDBTableOptions*/;
12011201
1202 -CREATE UNIQUE INDEX /*i*/pr_pagetype ON /*_*/page_restrictions (pr_page,pr_type);
1203 -CREATE UNIQUE INDEX /*i*/pr_typelevel ON /*_*/page_restrictions (pr_type,pr_level);
1204 -CREATE UNIQUE INDEX /*i*/pr_level ON /*_*/page_restrictions (pr_level);
1205 -CREATE UNIQUE INDEX /*i*/pr_cascade ON /*_*/page_restrictions (pr_cascade);
 1202+CREATE UNIQUE INDEX pr_pagetype ON /*_*/page_restrictions (pr_page,pr_type);
 1203+CREATE UNIQUE INDEX pr_typelevel ON /*_*/page_restrictions (pr_type,pr_level);
 1204+CREATE UNIQUE INDEX pr_level ON /*_*/page_restrictions (pr_level);
 1205+CREATE UNIQUE INDEX pr_cascade ON /*_*/page_restrictions (pr_cascade);
12061206
12071207
12081208 -- Protected titles - nonexistent pages that have been protected
@@ -1215,8 +1215,8 @@
12161216 pt_create_perm varbinary(60) NOT NULL
12171217 ) /*$wgDBTableOptions*/;
12181218
1219 -CREATE UNIQUE INDEX /*i*/pt_namespace_title ON /*_*/protected_titles (pt_namespace,pt_title);
1220 -CREATE INDEX /*i*/pt_timestamp ON /*_*/protected_titles (pt_timestamp);
 1219+CREATE UNIQUE INDEX pt_namespace ON /*_*/protected_titles (pt_namespace,pt_title);
 1220+CREATE INDEX pt_timestamp ON /*_*/protected_titles (pt_timestamp);
12211221
12221222
12231223 -- Name/value pairs indexed by page_id
@@ -1226,7 +1226,7 @@
12271227 pp_value blob NOT NULL
12281228 ) /*$wgDBTableOptions*/;
12291229
1230 -CREATE UNIQUE INDEX /*i*/pp_page_propname ON /*_*/page_props (pp_page,pp_propname);
 1230+CREATE UNIQUE INDEX pp_page ON /*_*/page_props (pp_page,pp_propname);
12311231
12321232
12331233 -- A table to log updates, one text key row per update.

Follow-up revisions

RevisionCommit summaryAuthorDate
r45830Fix up r45819 per CR comments: removing calls to removed function Database::i...catrope09:56, 17 January 2009
r45831Another followup to r45819: update references to the renamed archive.usertext...catrope10:11, 17 January 2009
r45891Revert r45821, r45830, r45831 and r45835 all in order to revert r45819, per d...catrope13:56, 19 January 2009
r45894Partial redo of r45819:...catrope14:12, 19 January 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45764For backport to 1.14....tstarling06:56, 15 January 2009
r45769* Preserve usertext_timestamp index name for MySQL, prefix it for SQLite. Iss...tstarling14:20, 15 January 2009

Comments

#Comment by Nikerabbit (talk | contribs)   08:48, 17 January 2009

Reported by trashy on #mediawiki when running update.php:

PHP Fatal error:  Call to undefined method DatabaseMysql::indexName() in /var/www/wiki/includes/db/Database.php on line 1194
#Comment by Trasher~mediawikiwiki (talk | contribs)   09:26, 17 January 2009

Seems that indexName function that has been removed is still used in Database.php at line 1194 :

        $index = $this->indexName( $index );

Similar calls are present in DatabaseSqlite.php :

  • at line 197
        $sql = 'PRAGMA index_info(' . $this->addQuotes( $this->indexName( $index ) ) . ')';
  • at line 216
               'name' => $this->indexName( $index ),
#Comment by Catrope (talk | contribs)   09:57, 17 January 2009

Damn, I thought I'd removed all the calls to indexName(). Removed the rest in r45830.

#Comment by Catrope (talk | contribs)   10:13, 17 January 2009

References to renamed indices updated in r45831.

#Comment by Simetrical (talk | contribs)   00:11, 18 January 2009

You're asking the sysadmins to ALTER two tables for the sake of cross-database naming consistency? Isn't that a little excessive? I'm pretty sure Tim kept the old names for MySQL specifically because he didn't want to have to alter tables unnecessarily.

#Comment by Tim Starling (talk | contribs)   00:40, 18 January 2009

Yes, exactly. It's not a problem to silently change the index names in SQLite and PostgreSQL because they both have a no-op useIndexClause(), and because SQLite never had any indexes to start with. But changing the MySQL index name of archive.usertext_timestamp will require a full set of master switches on Wikimedia before deployment of this revision. I'm not sure if it's even possible since some of the servers are running out of disk space and it'll require a temporary copy of the archive table.

#Comment by Catrope (talk | contribs)   18:09, 18 January 2009

Good point. I forgot for a minute that the other DMBSes don't even use the index names anywhere. I'll revert most of this and the followup revs tomorrow afternoon (I wanna preserve the part that re-renames the implicitly named indexes, though).

#Comment by Catrope (talk | contribs)   13:56, 19 January 2009

Reverted in r45891

Status & tagging log