r45769 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45768‎ | r45769 | r45770 >
Date:14:20, 15 January 2009
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
* Preserve usertext_timestamp index name for MySQL, prefix it for SQLite. Issues remain on the experimental non-installable DBMSes.
* Clean up some E_STRICT issues
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/sqlite/archives/initial-indexes.sql (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/sqlite/archives/initial-indexes.sql
@@ -51,8 +51,8 @@
5252 user_registration binary(14),
5353 user_editcount int
5454 );
55 -CREATE UNIQUE INDEX user_name ON /*_*/user_tmp (user_name);
56 -CREATE INDEX user_email_token ON /*_*/user_tmp (user_email_token);
 55+CREATE UNIQUE INDEX /*i*/user_name ON /*_*/user_tmp (user_name);
 56+CREATE INDEX /*i*/user_email_token ON /*_*/user_tmp (user_email_token);
5757
5858
5959 CREATE TABLE /*_*/user_groups_tmp (
@@ -60,8 +60,8 @@
6161 ug_group varbinary(16) NOT NULL default ''
6262 );
6363
64 -CREATE UNIQUE INDEX ug_user_group ON /*_*/user_groups_tmp (ug_user,ug_group);
65 -CREATE INDEX ug_group ON /*_*/user_groups_tmp (ug_group);
 64+CREATE UNIQUE INDEX /*i*/ug_user_group ON /*_*/user_groups_tmp (ug_user,ug_group);
 65+CREATE INDEX /*i*/ug_group ON /*_*/user_groups_tmp (ug_group);
6666
6767 CREATE TABLE /*_*/page_tmp (
6868 page_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
@@ -77,9 +77,9 @@
7878 page_len int unsigned NOT NULL
7979 );
8080
81 -CREATE UNIQUE INDEX name_title ON /*_*/page_tmp (page_namespace,page_title);
82 -CREATE INDEX page_random ON /*_*/page_tmp (page_random);
83 -CREATE INDEX page_len ON /*_*/page_tmp (page_len);
 81+CREATE UNIQUE INDEX /*i*/name_title ON /*_*/page_tmp (page_namespace,page_title);
 82+CREATE INDEX /*i*/page_random ON /*_*/page_tmp (page_random);
 83+CREATE INDEX /*i*/page_len ON /*_*/page_tmp (page_len);
8484
8585
8686 CREATE TABLE /*_*/revision_tmp (
@@ -95,11 +95,11 @@
9696 rev_len int unsigned,
9797 rev_parent_id int unsigned default NULL
9898 );
99 -CREATE UNIQUE INDEX rev_page_id ON /*_*/revision_tmp (rev_page, rev_id);
100 -CREATE INDEX rev_timestamp ON /*_*/revision_tmp (rev_timestamp);
101 -CREATE INDEX page_timestamp ON /*_*/revision_tmp (rev_page,rev_timestamp);
102 -CREATE INDEX user_timestamp ON /*_*/revision_tmp (rev_user,rev_timestamp);
103 -CREATE INDEX usertext_timestamp ON /*_*/revision_tmp (rev_user_text,rev_timestamp);
 99+CREATE UNIQUE INDEX /*i*/rev_page_id ON /*_*/revision_tmp (rev_page, rev_id);
 100+CREATE INDEX /*i*/rev_timestamp ON /*_*/revision_tmp (rev_timestamp);
 101+CREATE INDEX /*i*/page_timestamp ON /*_*/revision_tmp (rev_page,rev_timestamp);
 102+CREATE INDEX /*i*/user_timestamp ON /*_*/revision_tmp (rev_user,rev_timestamp);
 103+CREATE INDEX /*i*/usertext_timestamp ON /*_*/revision_tmp (rev_user_text,rev_timestamp);
104104
105105 CREATE TABLE /*_*/pagelinks_tmp (
106106 pl_from int unsigned NOT NULL default 0,
@@ -107,8 +107,8 @@
108108 pl_title varchar(255) binary NOT NULL default ''
109109 );
110110
111 -CREATE UNIQUE INDEX pl_from ON /*_*/pagelinks_tmp (pl_from,pl_namespace,pl_title);
112 -CREATE INDEX pl_namespace_title ON /*_*/pagelinks_tmp (pl_namespace,pl_title,pl_from);
 111+CREATE UNIQUE INDEX /*i*/pl_from ON /*_*/pagelinks_tmp (pl_from,pl_namespace,pl_title);
 112+CREATE INDEX /*i*/pl_namespace_title ON /*_*/pagelinks_tmp (pl_namespace,pl_title,pl_from);
113113
114114
115115 CREATE TABLE /*_*/templatelinks_tmp (
@@ -117,16 +117,16 @@
118118 tl_title varchar(255) binary NOT NULL default ''
119119 );
120120
121 -CREATE UNIQUE INDEX tl_from ON /*_*/templatelinks_tmp (tl_from,tl_namespace,tl_title);
122 -CREATE INDEX tl_namespace_title ON /*_*/templatelinks_tmp (tl_namespace,tl_title,tl_from);
 121+CREATE UNIQUE INDEX /*i*/tl_from ON /*_*/templatelinks_tmp (tl_from,tl_namespace,tl_title);
 122+CREATE INDEX /*i*/tl_namespace_title ON /*_*/templatelinks_tmp (tl_namespace,tl_title,tl_from);
123123
124124
125125 CREATE TABLE /*_*/imagelinks_tmp (
126126 il_from int unsigned NOT NULL default 0,
127127 il_to varchar(255) binary NOT NULL default ''
128128 ) /*$wgDBTableOptions*/;
129 -CREATE UNIQUE INDEX il_from ON /*_*/imagelinks_tmp (il_from,il_to);
130 -CREATE INDEX il_to ON /*_*/imagelinks_tmp (il_to,il_from);
 129+CREATE UNIQUE INDEX /*i*/il_from ON /*_*/imagelinks_tmp (il_from,il_to);
 130+CREATE INDEX /*i*/il_to ON /*_*/imagelinks_tmp (il_to,il_from);
131131
132132
133133 CREATE TABLE /*_*/categorylinks_tmp (
@@ -135,9 +135,9 @@
136136 cl_sortkey varchar(70) binary NOT NULL default '',
137137 cl_timestamp timestamp NOT NULL
138138 );
139 -CREATE UNIQUE INDEX cl_from ON /*_*/categorylinks_tmp (cl_from,cl_to);
140 -CREATE INDEX cl_sortkey ON /*_*/categorylinks_tmp (cl_to,cl_sortkey,cl_from);
141 -CREATE INDEX cl_timestamp ON /*_*/categorylinks_tmp (cl_to,cl_timestamp);
 139+CREATE UNIQUE INDEX /*i*/cl_from ON /*_*/categorylinks_tmp (cl_from,cl_to);
 140+CREATE INDEX /*i*/cl_sortkey ON /*_*/categorylinks_tmp (cl_to,cl_sortkey,cl_from);
 141+CREATE INDEX /*i*/cl_timestamp ON /*_*/categorylinks_tmp (cl_to,cl_timestamp);
142142
143143
144144 CREATE TABLE /*_*/category_tmp (
@@ -148,8 +148,8 @@
149149 cat_files int signed NOT NULL default 0,
150150 cat_hidden tinyint unsigned NOT NULL default 0
151151 );
152 -CREATE UNIQUE INDEX cat_title ON /*_*/category_tmp (cat_title);
153 -CREATE INDEX cat_pages ON /*_*/category_tmp (cat_pages);
 152+CREATE UNIQUE INDEX /*i*/cat_title ON /*_*/category_tmp (cat_title);
 153+CREATE INDEX /*i*/cat_pages ON /*_*/category_tmp (cat_pages);
154154
155155 CREATE TABLE /*_*/langlinks_tmp (
156156 ll_from int unsigned NOT NULL default 0,
@@ -157,8 +157,8 @@
158158 ll_title varchar(255) binary NOT NULL default ''
159159 );
160160
161 -CREATE UNIQUE INDEX ll_from ON /*_*/langlinks_tmp (ll_from, ll_lang);
162 -CREATE INDEX ll_lang_title ON /*_*/langlinks_tmp (ll_lang, ll_title);
 161+CREATE UNIQUE INDEX /*i*/ll_from ON /*_*/langlinks_tmp (ll_from, ll_lang);
 162+CREATE INDEX /*i*/ll_lang_title ON /*_*/langlinks_tmp (ll_lang, ll_title);
163163
164164
165165 CREATE TABLE /*_*/site_stats_tmp (
@@ -172,7 +172,7 @@
173173 ss_admins int default '-1',
174174 ss_images int default 0
175175 );
176 -CREATE UNIQUE INDEX ss_row_id ON /*_*/site_stats_tmp (ss_row_id);
 176+CREATE UNIQUE INDEX /*i*/ss_row_id ON /*_*/site_stats_tmp (ss_row_id);
177177
178178
179179 CREATE TABLE /*_*/ipblocks_tmp (
@@ -196,11 +196,11 @@
197197 ipb_block_email bool NOT NULL default 0,
198198 ipb_allow_usertalk bool NOT NULL default 0
199199 );
200 -CREATE UNIQUE INDEX ipb_address ON /*_*/ipblocks_tmp (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only);
201 -CREATE INDEX ipb_user ON /*_*/ipblocks_tmp (ipb_user);
202 -CREATE INDEX ipb_range ON /*_*/ipblocks_tmp (ipb_range_start(8), ipb_range_end(8));
203 -CREATE INDEX ipb_timestamp ON /*_*/ipblocks_tmp (ipb_timestamp);
204 -CREATE INDEX ipb_expiry ON /*_*/ipblocks_tmp (ipb_expiry);
 200+CREATE UNIQUE INDEX /*i*/ipb_address ON /*_*/ipblocks_tmp (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only);
 201+CREATE INDEX /*i*/ipb_user ON /*_*/ipblocks_tmp (ipb_user);
 202+CREATE INDEX /*i*/ipb_range ON /*_*/ipblocks_tmp (ipb_range_start(8), ipb_range_end(8));
 203+CREATE INDEX /*i*/ipb_timestamp ON /*_*/ipblocks_tmp (ipb_timestamp);
 204+CREATE INDEX /*i*/ipb_expiry ON /*_*/ipblocks_tmp (ipb_expiry);
205205
206206
207207 CREATE TABLE /*_*/watchlist_tmp (
@@ -210,8 +210,8 @@
211211 wl_notificationtimestamp varbinary(14)
212212 );
213213
214 -CREATE UNIQUE INDEX wl_user_namespace_title ON /*_*/watchlist_tmp (wl_user, wl_namespace, wl_title);
215 -CREATE INDEX namespace_title ON /*_*/watchlist_tmp (wl_namespace, wl_title);
 214+CREATE UNIQUE INDEX /*i*/wl_user_namespace_title ON /*_*/watchlist_tmp (wl_user, wl_namespace, wl_title);
 215+CREATE INDEX /*i*/namespace_title ON /*_*/watchlist_tmp (wl_namespace, wl_title);
216216
217217
218218 CREATE TABLE /*_*/math_tmp (
@@ -222,7 +222,7 @@
223223 math_mathml text
224224 );
225225
226 -CREATE UNIQUE INDEX math_inputhash ON /*_*/math_tmp (math_inputhash);
 226+CREATE UNIQUE INDEX /*i*/math_inputhash ON /*_*/math_tmp (math_inputhash);
227227
228228
229229 CREATE TABLE /*_*/interwiki_tmp (
@@ -232,7 +232,7 @@
233233 iw_trans tinyint NOT NULL default 0
234234 );
235235
236 -CREATE UNIQUE INDEX iw_prefix ON /*_*/interwiki_tmp (iw_prefix);
 236+CREATE UNIQUE INDEX /*i*/iw_prefix ON /*_*/interwiki_tmp (iw_prefix);
237237
238238
239239 CREATE TABLE /*_*/page_restrictions_tmp (
@@ -245,10 +245,10 @@
246246 pr_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT
247247 );
248248
249 -CREATE UNIQUE INDEX pr_pagetype ON /*_*/page_restrictions_tmp (pr_page,pr_type);
250 -CREATE UNIQUE INDEX pr_typelevel ON /*_*/page_restrictions_tmp (pr_type,pr_level);
251 -CREATE UNIQUE INDEX pr_level ON /*_*/page_restrictions_tmp (pr_level);
252 -CREATE UNIQUE INDEX pr_cascade ON /*_*/page_restrictions_tmp (pr_cascade);
 249+CREATE UNIQUE INDEX /*i*/pr_pagetype ON /*_*/page_restrictions_tmp (pr_page,pr_type);
 250+CREATE UNIQUE INDEX /*i*/pr_typelevel ON /*_*/page_restrictions_tmp (pr_type,pr_level);
 251+CREATE UNIQUE INDEX /*i*/pr_level ON /*_*/page_restrictions_tmp (pr_level);
 252+CREATE UNIQUE INDEX /*i*/pr_cascade ON /*_*/page_restrictions_tmp (pr_cascade);
253253
254254 CREATE TABLE /*_*/protected_titles_tmp (
255255 pt_namespace int NOT NULL,
@@ -259,15 +259,15 @@
260260 pt_expiry varbinary(14) NOT NULL default '',
261261 pt_create_perm varbinary(60) NOT NULL
262262 );
263 -CREATE UNIQUE INDEX pt_namespace_title ON /*_*/protected_titles_tmp (pt_namespace,pt_title);
264 -CREATE INDEX pt_timestamp ON /*_*/protected_titles_tmp (pt_timestamp);
 263+CREATE UNIQUE INDEX /*i*/pt_namespace_title ON /*_*/protected_titles_tmp (pt_namespace,pt_title);
 264+CREATE INDEX /*i*/pt_timestamp ON /*_*/protected_titles_tmp (pt_timestamp);
265265
266266 CREATE TABLE /*_*/page_props_tmp (
267267 pp_page int NOT NULL,
268268 pp_propname varbinary(60) NOT NULL,
269269 pp_value blob NOT NULL
270270 );
271 -CREATE UNIQUE INDEX pp_page_propname ON /*_*/page_props_tmp (pp_page,pp_propname);
 271+CREATE UNIQUE INDEX /*i*/pp_page_propname ON /*_*/page_props_tmp (pp_page,pp_propname);
272272
273273 --------------------------------------------------------------------------------
274274 -- Populate the new tables using INSERT SELECT
@@ -344,9 +344,9 @@
345345 si_title varchar(255) NOT NULL default '',
346346 si_text mediumtext NOT NULL
347347 );
348 -CREATE UNIQUE INDEX si_page ON /*_*/searchindex (si_page);
349 -CREATE INDEX si_title ON /*_*/searchindex (si_title);
350 -CREATE INDEX si_text ON /*_*/searchindex (si_text);
 348+CREATE UNIQUE INDEX /*i*/si_page ON /*_*/searchindex (si_page);
 349+CREATE INDEX /*i*/si_title ON /*_*/searchindex (si_title);
 350+CREATE INDEX /*i*/si_text ON /*_*/searchindex (si_text);
351351
352352 DROP TABLE IF EXISTS /*_*/transcache;
353353 CREATE TABLE /*_*/transcache (
@@ -354,14 +354,14 @@
355355 tc_contents text,
356356 tc_time int NOT NULL
357357 ) /*$wgDBTableOptions*/;
358 -CREATE UNIQUE INDEX tc_url_idx ON /*_*/transcache (tc_url);
 358+CREATE UNIQUE INDEX /*i*/tc_url_idx ON /*_*/transcache (tc_url);
359359
360360 DROP TABLE IF EXISTS /*_*/querycache_info;
361361 CREATE TABLE /*_*/querycache_info (
362362 qci_type varbinary(32) NOT NULL default '',
363363 qci_timestamp binary(14) NOT NULL default '19700101000000'
364364 ) /*$wgDBTableOptions*/;
365 -CREATE UNIQUE INDEX qci_type ON /*_*/querycache_info (qci_type);
 365+CREATE UNIQUE INDEX /*i*/qci_type ON /*_*/querycache_info (qci_type);
366366
367367 --------------------------------------------------------------------------------
368368 -- Empty some cache tables to make the update faster
@@ -375,43 +375,43 @@
376376 -- Add indexes to tables with no unique indexes
377377 --------------------------------------------------------------------------------
378378
379 -CREATE INDEX un_user_id ON /*_*/user_newtalk (user_id);
380 -CREATE INDEX un_user_ip ON /*_*/user_newtalk (user_ip);
381 -CREATE INDEX name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
382 -CREATE INDEX ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
383 -CREATE INDEX el_from ON /*_*/externallinks (el_from, el_to(40));
384 -CREATE INDEX el_to ON /*_*/externallinks (el_to(60), el_from);
385 -CREATE INDEX el_index ON /*_*/externallinks (el_index(60));
386 -CREATE INDEX img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
387 -CREATE INDEX img_size ON /*_*/image (img_size);
388 -CREATE INDEX img_timestamp ON /*_*/image (img_timestamp);
389 -CREATE INDEX img_sha1 ON /*_*/image (img_sha1);
390 -CREATE INDEX oi_usertext_timestamp ON /*_*/oldimage (oi_user_text,oi_timestamp);
391 -CREATE INDEX oi_name_timestamp ON /*_*/oldimage (oi_name,oi_timestamp);
392 -CREATE INDEX oi_name_archive_name ON /*_*/oldimage (oi_name,oi_archive_name(14));
393 -CREATE INDEX oi_sha1 ON /*_*/oldimage (oi_sha1);
394 -CREATE INDEX fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
395 -CREATE INDEX fa_group_key ON /*_*/filearchive (fa_storage_group, fa_storage_key);
396 -CREATE INDEX fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
397 -CREATE INDEX fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
398 -CREATE INDEX rc_timestamp ON /*_*/recentchanges (rc_timestamp);
399 -CREATE INDEX rc_namespace_title ON /*_*/recentchanges (rc_namespace, rc_title);
400 -CREATE INDEX rc_cur_id ON /*_*/recentchanges (rc_cur_id);
401 -CREATE INDEX new_name_timestamp ON /*_*/recentchanges (rc_new,rc_namespace,rc_timestamp);
402 -CREATE INDEX rc_ip ON /*_*/recentchanges (rc_ip);
403 -CREATE INDEX rc_ns_usertext ON /*_*/recentchanges (rc_namespace, rc_user_text);
404 -CREATE INDEX rc_user_text ON /*_*/recentchanges (rc_user_text, rc_timestamp);
405 -CREATE INDEX qc_type_value ON /*_*/querycache (qc_type,qc_value);
406 -CREATE INDEX oc_exptime ON /*_*/objectcache (exptime);
407 -CREATE INDEX type_time ON /*_*/logging (log_type, log_timestamp);
408 -CREATE INDEX user_time ON /*_*/logging (log_user, log_timestamp);
409 -CREATE INDEX page_time ON /*_*/logging (log_namespace, log_title, log_timestamp);
410 -CREATE INDEX times ON /*_*/logging (log_timestamp);
411 -CREATE INDEX tb_page ON /*_*/trackbacks (tb_page);
412 -CREATE INDEX job_cmd_namespace_title ON /*_*/job (job_cmd, job_namespace, job_title);
413 -CREATE INDEX rd_ns_title ON /*_*/redirect (rd_namespace,rd_title,rd_from);
414 -CREATE INDEX qcc_type ON /*_*/querycachetwo (qcc_type,qcc_value);
415 -CREATE INDEX qcc_title ON /*_*/querycachetwo (qcc_type,qcc_namespace,qcc_title);
416 -CREATE INDEX qcc_titletwo ON /*_*/querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
 379+CREATE INDEX /*i*/un_user_id ON /*_*/user_newtalk (user_id);
 380+CREATE INDEX /*i*/un_user_ip ON /*_*/user_newtalk (user_ip);
 381+CREATE INDEX /*i*/name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
 382+CREATE INDEX /*i*/ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
 383+CREATE INDEX /*i*/el_from ON /*_*/externallinks (el_from, el_to(40));
 384+CREATE INDEX /*i*/el_to ON /*_*/externallinks (el_to(60), el_from);
 385+CREATE INDEX /*i*/el_index ON /*_*/externallinks (el_index(60));
 386+CREATE INDEX /*i*/img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
 387+CREATE INDEX /*i*/img_size ON /*_*/image (img_size);
 388+CREATE INDEX /*i*/img_timestamp ON /*_*/image (img_timestamp);
 389+CREATE INDEX /*i*/img_sha1 ON /*_*/image (img_sha1);
 390+CREATE INDEX /*i*/oi_usertext_timestamp ON /*_*/oldimage (oi_user_text,oi_timestamp);
 391+CREATE INDEX /*i*/oi_name_timestamp ON /*_*/oldimage (oi_name,oi_timestamp);
 392+CREATE INDEX /*i*/oi_name_archive_name ON /*_*/oldimage (oi_name,oi_archive_name(14));
 393+CREATE INDEX /*i*/oi_sha1 ON /*_*/oldimage (oi_sha1);
 394+CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
 395+CREATE INDEX /*i*/fa_group_key ON /*_*/filearchive (fa_storage_group, fa_storage_key);
 396+CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
 397+CREATE INDEX /*i*/fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
 398+CREATE INDEX /*i*/rc_timestamp ON /*_*/recentchanges (rc_timestamp);
 399+CREATE INDEX /*i*/rc_namespace_title ON /*_*/recentchanges (rc_namespace, rc_title);
 400+CREATE INDEX /*i*/rc_cur_id ON /*_*/recentchanges (rc_cur_id);
 401+CREATE INDEX /*i*/new_name_timestamp ON /*_*/recentchanges (rc_new,rc_namespace,rc_timestamp);
 402+CREATE INDEX /*i*/rc_ip ON /*_*/recentchanges (rc_ip);
 403+CREATE INDEX /*i*/rc_ns_usertext ON /*_*/recentchanges (rc_namespace, rc_user_text);
 404+CREATE INDEX /*i*/rc_user_text ON /*_*/recentchanges (rc_user_text, rc_timestamp);
 405+CREATE INDEX /*i*/qc_type_value ON /*_*/querycache (qc_type,qc_value);
 406+CREATE INDEX /*i*/oc_exptime ON /*_*/objectcache (exptime);
 407+CREATE INDEX /*i*/type_time ON /*_*/logging (log_type, log_timestamp);
 408+CREATE INDEX /*i*/user_time ON /*_*/logging (log_user, log_timestamp);
 409+CREATE INDEX /*i*/page_time ON /*_*/logging (log_namespace, log_title, log_timestamp);
 410+CREATE INDEX /*i*/times ON /*_*/logging (log_timestamp);
 411+CREATE INDEX /*i*/tb_page ON /*_*/trackbacks (tb_page);
 412+CREATE INDEX /*i*/job_cmd_namespace_title ON /*_*/job (job_cmd, job_namespace, job_title);
 413+CREATE INDEX /*i*/rd_ns_title ON /*_*/redirect (rd_namespace,rd_title,rd_from);
 414+CREATE INDEX /*i*/qcc_type ON /*_*/querycachetwo (qcc_type,qcc_value);
 415+CREATE INDEX /*i*/qcc_title ON /*_*/querycachetwo (qcc_type,qcc_namespace,qcc_title);
 416+CREATE INDEX /*i*/qcc_titletwo ON /*_*/querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
417417
418418 INSERT INTO /*_*/updatelog VALUES ('initial_indexes');
Index: trunk/phase3/maintenance/tables.sql
@@ -129,8 +129,8 @@
130130 user_editcount int
131131 ) /*$wgDBTableOptions*/;
132132
133 -CREATE UNIQUE INDEX user_name ON /*_*/user (user_name);
134 -CREATE INDEX user_email_token ON /*_*/user (user_email_token);
 133+CREATE UNIQUE INDEX /*i*/user_name ON /*_*/user (user_name);
 134+CREATE INDEX /*i*/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 ug_user_group ON /*_*/user_groups (ug_user,ug_group);
161 -CREATE INDEX ug_group ON /*_*/user_groups (ug_group);
 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);
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 un_user_id ON /*_*/user_newtalk (user_id);
179 -CREATE INDEX un_user_ip ON /*_*/user_newtalk (user_ip);
 178+CREATE INDEX /*i*/un_user_id ON /*_*/user_newtalk (user_id);
 179+CREATE INDEX /*i*/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 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);
 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);
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 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);
 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);
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 name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
393 -CREATE INDEX ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
 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);
394394
395395
396396 --
@@ -407,8 +407,8 @@
408408 pl_title varchar(255) binary NOT NULL default ''
409409 ) /*$wgDBTableOptions*/;
410410
411 -CREATE UNIQUE INDEX pl_from ON /*_*/pagelinks (pl_from,pl_namespace,pl_title);
412 -CREATE INDEX pl_namespace_title ON /*_*/pagelinks (pl_namespace,pl_title,pl_from);
 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);
413413
414414
415415 --
@@ -426,8 +426,8 @@
427427 tl_title varchar(255) binary NOT NULL default ''
428428 ) /*$wgDBTableOptions*/;
429429
430 -CREATE UNIQUE INDEX tl_from ON /*_*/templatelinks (tl_from,tl_namespace,tl_title);
431 -CREATE INDEX tl_namespace_title ON /*_*/templatelinks (tl_namespace,tl_title,tl_from);
 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);
432432
433433
434434 --
@@ -445,8 +445,8 @@
446446 il_to varchar(255) binary NOT NULL default ''
447447 ) /*$wgDBTableOptions*/;
448448
449 -CREATE UNIQUE INDEX il_from ON /*_*/imagelinks (il_from,il_to);
450 -CREATE INDEX il_to ON /*_*/imagelinks (il_to,il_from);
 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);
451451
452452
453453 --
@@ -477,13 +477,13 @@
478478 cl_timestamp timestamp NOT NULL
479479 ) /*$wgDBTableOptions*/;
480480
481 -CREATE UNIQUE INDEX cl_from ON /*_*/categorylinks (cl_from,cl_to);
 481+CREATE UNIQUE INDEX /*i*/cl_from ON /*_*/categorylinks (cl_from,cl_to);
482482
483483 -- We always sort within a given category...
484 -CREATE INDEX cl_sortkey ON /*_*/categorylinks (cl_to,cl_sortkey,cl_from);
 484+CREATE INDEX /*i*/cl_sortkey ON /*_*/categorylinks (cl_to,cl_sortkey,cl_from);
485485
486486 -- Not really used?
487 -CREATE INDEX cl_timestamp ON /*_*/categorylinks (cl_to,cl_timestamp);
 487+CREATE INDEX /*i*/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 cat_title ON /*_*/category (cat_title);
 517+CREATE UNIQUE INDEX /*i*/cat_title ON /*_*/category (cat_title);
518518
519519 -- For Special:Mostlinkedcategories
520 -CREATE INDEX cat_pages ON /*_*/category (cat_pages);
 520+CREATE INDEX /*i*/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 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));
 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));
550550
551551
552552 --
@@ -562,8 +562,8 @@
563563 ll_title varchar(255) binary NOT NULL default ''
564564 ) /*$wgDBTableOptions*/;
565565
566 -CREATE UNIQUE INDEX ll_from ON /*_*/langlinks (ll_from, ll_lang);
567 -CREATE INDEX ll_lang_title ON /*_*/langlinks (ll_lang, ll_title);
 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);
568568
569569
570570 --
@@ -604,7 +604,7 @@
605605 ) /*$wgDBTableOptions*/;
606606
607607 -- Pointless index to assuage developer superstitions
608 -CREATE UNIQUE INDEX ss_row_id ON /*_*/site_stats (ss_row_id);
 608+CREATE UNIQUE INDEX /*i*/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 ipb_address ON /*_*/ipblocks (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only);
 686+CREATE UNIQUE INDEX /*i*/ipb_address ON /*_*/ipblocks (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only);
687687
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);
 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);
692692
693693
694694 --
@@ -740,13 +740,13 @@
741741 img_sha1 varbinary(32) NOT NULL default ''
742742 ) /*$wgDBTableOptions*/;
743743
744 -CREATE INDEX img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
 744+CREATE INDEX /*i*/img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
745745 -- Used by Special:Imagelist for sort-by-size
746 -CREATE INDEX img_size ON /*_*/image (img_size);
 746+CREATE INDEX /*i*/img_size ON /*_*/image (img_size);
747747 -- Used by Special:Newimages and Special:Imagelist
748 -CREATE INDEX img_timestamp ON /*_*/image (img_timestamp);
 748+CREATE INDEX /*i*/img_timestamp ON /*_*/image (img_timestamp);
749749 -- Used in API and duplicate search
750 -CREATE INDEX img_sha1 ON /*_*/image (img_sha1);
 750+CREATE INDEX /*i*/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 oi_usertext_timestamp ON /*_*/oldimage (oi_user_text,oi_timestamp);
785 -CREATE INDEX oi_name_timestamp ON /*_*/oldimage (oi_name,oi_timestamp);
 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);
786786 -- oi_archive_name truncated to 14 to avoid key length overflow
787 -CREATE INDEX oi_name_archive_name ON /*_*/oldimage (oi_name,oi_archive_name(14));
788 -CREATE INDEX oi_sha1 ON /*_*/oldimage (oi_sha1);
 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);
789789
790790
791791 --
@@ -836,13 +836,13 @@
837837 ) /*$wgDBTableOptions*/;
838838
839839 -- pick out by image name
840 -CREATE INDEX fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
 840+CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
841841 -- pick out dupe files
842 -CREATE INDEX fa_group_key ON /*_*/filearchive (fa_storage_group, fa_storage_key);
 842+CREATE INDEX /*i*/fa_group_key ON /*_*/filearchive (fa_storage_group, fa_storage_key);
843843 -- sort by deletion time
844 -CREATE INDEX fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
 844+CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
845845 -- sort by uploader
846 -CREATE INDEX fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
 846+CREATE INDEX /*i*/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 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);
 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);
929929
930930
931931 CREATE TABLE /*_*/watchlist (
@@ -943,8 +943,8 @@
944944
945945 ) /*$wgDBTableOptions*/;
946946
947 -CREATE UNIQUE INDEX wl_user_namespace_title ON /*_*/watchlist (wl_user, wl_namespace, wl_title);
948 -CREATE INDEX namespace_title ON /*_*/watchlist (wl_namespace, wl_title);
 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);
949949
950950
951951 --
@@ -969,7 +969,7 @@
970970 math_mathml text
971971 ) /*$wgDBTableOptions*/;
972972
973 -CREATE UNIQUE INDEX math_inputhash ON /*_*/math (math_inputhash);
 973+CREATE UNIQUE INDEX /*i*/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 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);
 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);
998998
999999
10001000 --
@@ -1016,7 +1016,7 @@
10171017 iw_trans tinyint NOT NULL default 0
10181018 ) /*$wgDBTableOptions*/;
10191019
1020 -CREATE UNIQUE INDEX iw_prefix ON /*_*/interwiki (iw_prefix);
 1020+CREATE UNIQUE INDEX /*i*/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 qc_type_value ON /*_*/querycache (qc_type,qc_value);
 1038+CREATE INDEX /*i*/qc_type_value ON /*_*/querycache (qc_type,qc_value);
10391039
10401040
10411041 --
@@ -1045,7 +1045,7 @@
10461046 value mediumblob,
10471047 exptime datetime
10481048 ) /*$wgDBTableOptions*/;
1049 -CREATE INDEX oc_exptime ON /*_*/objectcache (exptime);
 1049+CREATE INDEX /*i*/oc_exptime ON /*_*/objectcache (exptime);
10501050
10511051
10521052 --
@@ -1057,7 +1057,7 @@
10581058 tc_time int NOT NULL
10591059 ) /*$wgDBTableOptions*/;
10601060
1061 -CREATE UNIQUE INDEX tc_url_idx ON /*_*/transcache (tc_url);
 1061+CREATE UNIQUE INDEX /*i*/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 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);
 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);
10991099
11001100
11011101 CREATE TABLE /*_*/trackbacks (
@@ -1105,7 +1105,7 @@
11061106 tb_ex text,
11071107 tb_name varchar(255)
11081108 ) /*$wgDBTableOptions*/;
1109 -CREATE INDEX tb_page ON /*_*/trackbacks (tb_page);
 1109+CREATE INDEX /*i*/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 job_cmd_namespace_title ON /*_*/job (job_cmd, job_namespace, job_title);
 1130+CREATE INDEX /*i*/job_cmd_namespace_title 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 qci_type ON /*_*/querycache_info (qci_type);
 1143+CREATE UNIQUE INDEX /*i*/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 rd_ns_title ON /*_*/redirect (rd_namespace,rd_title,rd_from);
 1159+CREATE INDEX /*i*/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 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);
 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);
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 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);
 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);
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 pt_namespace_title ON /*_*/protected_titles (pt_namespace,pt_title);
1220 -CREATE INDEX pt_timestamp ON /*_*/protected_titles (pt_timestamp);
 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);
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 pp_page_propname ON /*_*/page_props (pp_page,pp_propname);
 1230+CREATE UNIQUE INDEX /*i*/pp_page_propname ON /*_*/page_props (pp_page,pp_propname);
12311231
12321232
12331233 -- A table to log updates, one text key row per update.
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 == $index ) {
 702+ if ( $row->indexname == $this->indexName( $index ) ) {
703703 return $row;
704704 }
705705 }
@@ -707,7 +707,9 @@
708708
709709 function indexUnique ($table, $index, $fname = 'Database::indexUnique' ) {
710710 $sql = "SELECT indexname FROM pg_indexes WHERE tablename='{$table}'".
711 - " AND indexdef LIKE 'CREATE UNIQUE%({$index})'";
 711+ " AND indexdef LIKE 'CREATE UNIQUE%(" .
 712+ $this->strencode( $this->indexName( $index ) ) .
 713+ ")'";
712714 $res = $this->query( $sql, $fname );
713715 if ( !$res )
714716 return NULL;
Index: trunk/phase3/includes/db/Database.php
@@ -1191,6 +1191,7 @@
11921192 # SHOW INDEX should work for 3.x and up:
11931193 # http://dev.mysql.com/doc/mysql/en/SHOW_INDEX.html
11941194 $table = $this->tableName( $table );
 1195+ $index = $this->indexName( $index );
11951196 $sql = 'SHOW INDEX FROM '.$table;
11961197 $res = $this->query( $sql, $fname );
11971198 if ( !$res ) {
@@ -1574,6 +1575,18 @@
15751576 }
15761577
15771578 /**
 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+ /**
15781591 * Wrapper for addslashes()
15791592 * @param $s String: to be slashed.
15801593 * @return String: slashed string.
@@ -1621,7 +1634,7 @@
16221635 * PostgreSQL doesn't have them and returns ""
16231636 */
16241637 function useIndexClause( $index ) {
1625 - return "FORCE INDEX ($index)";
 1638+ return "FORCE INDEX (" . $this->indexName( $index ) . ")";
16261639 }
16271640
16281641 /**
@@ -2258,8 +2271,12 @@
22592272 }
22602273
22612274 // Table prefixes
2262 - $ins = preg_replace_callback( '/\/\*(?:\$wgDBprefix|_)\*\/([a-zA-Z_0-9]*)/',
2263 - array( &$this, 'tableNameCallback' ), $ins );
 2275+ $ins = preg_replace_callback( '!/\*(?:\$wgDBprefix|_)\*/([a-zA-Z_0-9]*)!',
 2276+ array( $this, 'tableNameCallback' ), $ins );
 2277+
 2278+ // Index names
 2279+ $ins = preg_replace_callback( '!/\*i\*/([a-zA-Z_0-9]*)!',
 2280+ array( $this, 'indexNameCallback' ), $ins );
22642281 return $ins;
22652282 }
22662283
@@ -2271,6 +2288,13 @@
22722289 return $this->tableName( $matches[1] );
22732290 }
22742291
 2292+ /**
 2293+ * Index name callback
 2294+ */
 2295+ protected function indexNameCallback( $matches ) {
 2296+ return $this->indexName( $matches[1] );
 2297+ }
 2298+
22752299 /*
22762300 * Build a concatenation list to feed into a SQL query
22772301 */
Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -101,11 +101,11 @@
102102 return $res;
103103 }
104104
105 - function freeResult(&$res) {
 105+ function freeResult($res) {
106106 if ($res instanceof ResultWrapper) $res->result = NULL; else $res = NULL;
107107 }
108108
109 - function fetchObject(&$res) {
 109+ function fetchObject($res) {
110110 if ($res instanceof ResultWrapper) $r =& $res->result; else $r =& $res;
111111 $cur = current($r);
112112 if (is_array($cur)) {
@@ -117,7 +117,7 @@
118118 return false;
119119 }
120120
121 - function fetchRow(&$res) {
 121+ function fetchRow($res) {
122122 if ($res instanceof ResultWrapper) $r =& $res->result; else $r =& $res;
123123 $cur = current($r);
124124 if (is_array($cur)) {
@@ -130,17 +130,17 @@
131131 /**
132132 * The PDO::Statement class implements the array interface so count() will work
133133 */
134 - function numRows(&$res) {
 134+ function numRows($res) {
135135 $r = $res instanceof ResultWrapper ? $res->result : $res;
136136 return count($r);
137137 }
138138
139 - function numFields(&$res) {
 139+ function numFields($res) {
140140 $r = $res instanceof ResultWrapper ? $res->result : $res;
141141 return is_array($r) ? count($r[0]) : 0;
142142 }
143143
144 - function fieldName(&$res,$n) {
 144+ function fieldName($res,$n) {
145145 $r = $res instanceof ResultWrapper ? $res->result : $res;
146146 if (is_array($r)) {
147147 $keys = array_keys($r[0]);
@@ -157,13 +157,20 @@
158158 }
159159
160160 /**
 161+ * Index names have DB scope
 162+ */
 163+ function indexName( $index ) {
 164+ return $index;
 165+ }
 166+
 167+ /**
161168 * This must be called after nextSequenceVal
162169 */
163170 function insertId() {
164171 return $this->mConn->lastInsertId();
165172 }
166173
167 - function dataSeek(&$res,$row) {
 174+ function dataSeek($res,$row) {
168175 if ($res instanceof ResultWrapper) $r =& $res->result; else $r =& $res;
169176 reset($r);
170177 if ($row > 0) for ($i = 0; $i < $row; $i++) next($r);
@@ -194,7 +201,7 @@
195202 * - if errors are explicitly ignored, returns NULL on failure
196203 */
197204 function indexInfo($table, $index, $fname = 'Database::indexExists') {
198 - $sql = 'PRAGMA index_info(' . $this->addQuotes( $index ) . ')';
 205+ $sql = 'PRAGMA index_info(' . $this->addQuotes( $this->indexName( $index ) ) . ')';
199206 $res = $this->query( $sql, $fname );
200207 if ( !$res ) {
201208 return null;
@@ -213,7 +220,7 @@
214221 $row = $this->selectRow( 'sqlite_master', '*',
215222 array(
216223 'type' => 'index',
217 - 'name' => $index,
 224+ 'name' => $this->indexName( $index ),
218225 ), $fname );
219226 if ( !$row || !isset( $row->sql ) ) {
220227 return null;
@@ -314,7 +321,7 @@
315322 /**
316323 * Query whether a given column exists in the mediawiki schema
317324 */
318 - function fieldExists($table, $field) {
 325+ function fieldExists($table, $field, $fname = '') {
319326 $info = $this->fieldInfo( $table, $field );
320327 return (bool)$info;
321328 }
@@ -335,19 +342,19 @@
336343 return false;
337344 }
338345
339 - function begin() {
 346+ function begin( $fname = '' ) {
340347 if ($this->mTrxLevel == 1) $this->commit();
341348 $this->mConn->beginTransaction();
342349 $this->mTrxLevel = 1;
343350 }
344351
345 - function commit() {
 352+ function commit( $fname = '' ) {
346353 if ($this->mTrxLevel == 0) return;
347354 $this->mConn->commit();
348355 $this->mTrxLevel = 0;
349356 }
350357
351 - function rollback() {
 358+ function rollback( $fname = '' ) {
352359 if ($this->mTrxLevel == 0) return;
353360 $this->mConn->rollBack();
354361 $this->mTrxLevel = 0;

Follow-up revisions

RevisionCommit summaryAuthorDate
r45819Attempt at cleaning up r45764, r45769 (renamed indices for SQLite compat):...catrope23:02, 16 January 2009
r50614Fix breakage of SQLite ResultWrapper due to r45769. The "result" member in SQ...tstarling02:49, 15 May 2009

Comments

#Comment by Catrope (talk | contribs)   21:37, 16 January 2009

There are other indices whose name changed in r45764 that this commit doesn't address. For example, the pl_namespace index went from being nameless (and therefore implicitly named after its first field) to being called pl_namespace_title.

#Comment by Catrope (talk | contribs)   21:42, 16 January 2009

Also, there's still no maintenance script for renaming indices, which is definitely needed.

#Comment by Catrope (talk | contribs)   23:03, 16 January 2009

Addressed both of these issues in r45819.

Status & tagging log