Index: trunk/phase3/maintenance/sqlite/tables.sql |
— | — | @@ -1,340 +0,0 @@ |
2 | | -CREATE TABLE /*$wgDBprefix*/user ( |
3 | | - user_id INTEGER PRIMARY KEY AUTOINCREMENT, |
4 | | - user_name varchar(255) default '', |
5 | | - user_real_name varchar(255) default '', |
6 | | - user_password tinyblob , |
7 | | - user_newpassword tinyblob , |
8 | | - user_newpass_time BLOB, |
9 | | - user_email tinytext , |
10 | | - user_options blob , |
11 | | - user_touched BLOB default '', |
12 | | - user_token BLOB default '', |
13 | | - user_email_authenticated BLOB, |
14 | | - user_email_token BLOB, |
15 | | - user_email_token_expires BLOB, |
16 | | - user_registration BLOB, |
17 | | - user_editcount int) /*$wgDBTableOptions*/; |
18 | | - |
19 | | -CREATE TABLE /*$wgDBprefix*/user_groups ( |
20 | | - ug_user INTEGER default '0', |
21 | | - ug_group varBLOB default '') /*$wgDBTableOptions*/; |
22 | | - |
23 | | -CREATE TABLE /*$wgDBprefix*/user_newtalk ( |
24 | | - user_id INTEGER default '0', |
25 | | - user_ip varBLOB default '', |
26 | | - user_last_timestamp BLOB default '') /*$wgDBTableOptions*/; |
27 | | - |
28 | | -CREATE TABLE /*$wgDBprefix*/page ( |
29 | | - page_id INTEGER PRIMARY KEY AUTOINCREMENT, |
30 | | - page_namespace INTEGER , |
31 | | - page_title varchar(255) , |
32 | | - page_restrictions tinyblob , |
33 | | - page_counter bigint default '0', |
34 | | - page_is_redirect tinyint default '0', |
35 | | - page_is_new tinyint default '0', |
36 | | - page_random real , |
37 | | - page_touched BLOB default '', |
38 | | - page_latest INTEGER , |
39 | | - page_len INTEGER ) /*$wgDBTableOptions*/; |
40 | | - |
41 | | -CREATE TABLE /*$wgDBprefix*/revision ( |
42 | | - rev_id INTEGER PRIMARY KEY AUTOINCREMENT, |
43 | | - rev_page INTEGER , |
44 | | - rev_text_id INTEGER , |
45 | | - rev_comment tinyblob , |
46 | | - rev_user INTEGER default '0', |
47 | | - rev_user_text varchar(255) default '', |
48 | | - rev_timestamp BLOB default '', |
49 | | - rev_minor_edit tinyint default '0', |
50 | | - rev_deleted tinyint default '0', |
51 | | - rev_len int, |
52 | | - rev_parent_id INTEGER default NULL) /*$wgDBTableOptions*/ ; |
53 | | - |
54 | | -CREATE TABLE /*$wgDBprefix*/text ( |
55 | | - old_id INTEGER PRIMARY KEY AUTOINCREMENT, |
56 | | - old_text mediumblob , |
57 | | - old_flags tinyblob ) /*$wgDBTableOptions*/ ; |
58 | | - |
59 | | -CREATE TABLE /*$wgDBprefix*/archive ( |
60 | | - ar_namespace INTEGER default '0', |
61 | | - ar_title varchar(255) default '', |
62 | | - ar_text mediumblob , |
63 | | - ar_comment tinyblob , |
64 | | - ar_user INTEGER default '0', |
65 | | - ar_user_text varchar(255) , |
66 | | - ar_timestamp BLOB default '', |
67 | | - ar_minor_edit tinyint default '0', |
68 | | - ar_flags tinyblob , |
69 | | - ar_rev_id int, |
70 | | - ar_text_id int, |
71 | | - ar_deleted tinyint default '0', |
72 | | - ar_len int, |
73 | | - ar_page_id int, |
74 | | - ar_parent_id INTEGER default NULL) /*$wgDBTableOptions*/; |
75 | | - |
76 | | -CREATE TABLE /*$wgDBprefix*/pagelinks ( |
77 | | - pl_from INTEGER default '0', |
78 | | - pl_namespace INTEGER default '0', |
79 | | - pl_title varchar(255) default '') /*$wgDBTableOptions*/; |
80 | | - |
81 | | -CREATE TABLE /*$wgDBprefix*/templatelinks ( |
82 | | - tl_from INTEGER default '0', |
83 | | - tl_namespace INTEGER default '0', |
84 | | - tl_title varchar(255) default '') /*$wgDBTableOptions*/; |
85 | | - |
86 | | -CREATE TABLE /*$wgDBprefix*/imagelinks ( |
87 | | - il_from INTEGER default '0', |
88 | | - il_to varchar(255) default '') /*$wgDBTableOptions*/; |
89 | | - |
90 | | -CREATE TABLE /*$wgDBprefix*/categorylinks ( |
91 | | - cl_from INTEGER default '0', |
92 | | - cl_to varchar(255) default '', |
93 | | - cl_sortkey varchar(70) default '', |
94 | | - cl_timestamp timestamp ) /*$wgDBTableOptions*/; |
95 | | - |
96 | | -CREATE TABLE /*$wgDBprefix*/category ( |
97 | | - cat_id INTEGER PRIMARY KEY AUTOINCREMENT, |
98 | | - cat_title varchar(255) , |
99 | | - cat_pages INTEGER signed default 0, |
100 | | - cat_subcats INTEGER signed default 0, |
101 | | - cat_files INTEGER signed default 0, |
102 | | - cat_hidden tinyint default 0) /*$wgDBTableOptions*/; |
103 | | - |
104 | | -CREATE TABLE /*$wgDBprefix*/externallinks ( |
105 | | - el_from INTEGER default '0', |
106 | | - el_to blob , |
107 | | - el_index blob ) /*$wgDBTableOptions*/; |
108 | | - |
109 | | -CREATE TABLE /*$wgDBprefix*/langlinks ( |
110 | | - ll_from INTEGER default '0', |
111 | | - ll_lang varBLOB default '', |
112 | | - ll_title varchar(255) default '') /*$wgDBTableOptions*/; |
113 | | - |
114 | | -CREATE TABLE /*$wgDBprefix*/site_stats ( |
115 | | - ss_row_id INTEGER , |
116 | | - ss_total_views bigint default '0', |
117 | | - ss_total_edits bigint default '0', |
118 | | - ss_good_articles bigint default '0', |
119 | | - ss_total_pages bigint default '-1', |
120 | | - ss_users bigint default '-1', |
121 | | - ss_admins INTEGER default '-1', |
122 | | - ss_images INTEGER default '0') /*$wgDBTableOptions*/; |
123 | | - |
124 | | -CREATE TABLE /*$wgDBprefix*/hitcounter ( |
125 | | - hc_id INTEGER |
126 | | -) ; |
127 | | - |
128 | | -CREATE TABLE /*$wgDBprefix*/ipblocks ( |
129 | | - ipb_id INTEGER PRIMARY KEY AUTOINCREMENT, |
130 | | - ipb_address tinyblob , |
131 | | - ipb_user INTEGER default '0', |
132 | | - ipb_by INTEGER default '0', |
133 | | - ipb_by_text varchar(255) default '', |
134 | | - ipb_reason tinyblob , |
135 | | - ipb_timestamp BLOB default '', |
136 | | - ipb_auto bool default 0, |
137 | | - ipb_anon_only bool default 0, |
138 | | - ipb_create_account bool default 1, |
139 | | - ipb_enable_autoblock bool default '1', |
140 | | - ipb_expiry varBLOB default '', |
141 | | - ipb_range_start tinyblob , |
142 | | - ipb_range_end tinyblob , |
143 | | - ipb_deleted bool default 0, |
144 | | - ipb_block_email bool default 0) /*$wgDBTableOptions*/; |
145 | | - |
146 | | -CREATE TABLE /*$wgDBprefix*/image ( |
147 | | - img_name varchar(255) default '', |
148 | | - img_size INTEGER default '0', |
149 | | - img_width INTEGER default '0', |
150 | | - img_height INTEGER default '0', |
151 | | - img_metadata mediumblob , |
152 | | - img_bits INTEGER default '0', |
153 | | - img_media_type TEXT default NULL, |
154 | | - img_major_mime TEXT default "unknown", |
155 | | - img_minor_mime varBLOB default "unknown", |
156 | | - img_description tinyblob , |
157 | | - img_user INTEGER default '0', |
158 | | - img_user_text varchar(255) , |
159 | | - img_timestamp varBLOB default '', |
160 | | - img_sha1 varBLOB default '') /*$wgDBTableOptions*/; |
161 | | - |
162 | | -CREATE TABLE /*$wgDBprefix*/oldimage ( |
163 | | - oi_name varchar(255) default '', |
164 | | - oi_archive_name varchar(255) default '', |
165 | | - oi_size INTEGER default 0, |
166 | | - oi_width INTEGER default 0, |
167 | | - oi_height INTEGER default 0, |
168 | | - oi_bits INTEGER default 0, |
169 | | - oi_description tinyblob , |
170 | | - oi_user INTEGER default '0', |
171 | | - oi_user_text varchar(255) , |
172 | | - oi_timestamp BLOB default '', |
173 | | - oi_metadata mediumblob , |
174 | | - oi_media_type TEXT default NULL, |
175 | | - oi_major_mime TEXT default "unknown", |
176 | | - oi_minor_mime varBLOB default "unknown", |
177 | | - oi_deleted tinyint default '0', |
178 | | - oi_sha1 varBLOB default '') /*$wgDBTableOptions*/; |
179 | | - |
180 | | -CREATE TABLE /*$wgDBprefix*/filearchive ( |
181 | | - fa_id INTEGER PRIMARY KEY AUTOINCREMENT, |
182 | | - fa_name varchar(255) default '', |
183 | | - fa_archive_name varchar(255) default '', |
184 | | - fa_storage_group varBLOB, |
185 | | - fa_storage_key varBLOB default '', |
186 | | - fa_deleted_user int, |
187 | | - fa_deleted_timestamp BLOB default '', |
188 | | - fa_deleted_reason text, |
189 | | - fa_size INTEGER default '0', |
190 | | - fa_width INTEGER default '0', |
191 | | - fa_height INTEGER default '0', |
192 | | - fa_metadata mediumblob, |
193 | | - fa_bits INTEGER default '0', |
194 | | - fa_media_type TEXT default NULL, |
195 | | - fa_major_mime TEXT default "unknown", |
196 | | - fa_minor_mime varBLOB default "unknown", |
197 | | - fa_description tinyblob, |
198 | | - fa_user INTEGER default '0', |
199 | | - fa_user_text varchar(255) , |
200 | | - fa_timestamp BLOB default '', |
201 | | - fa_deleted tinyint default '0') /*$wgDBTableOptions*/; |
202 | | - |
203 | | -CREATE TABLE /*$wgDBprefix*/recentchanges ( |
204 | | - rc_id INTEGER PRIMARY KEY AUTOINCREMENT, |
205 | | - rc_timestamp varBLOB default '', |
206 | | - rc_cur_time varBLOB default '', |
207 | | - rc_user INTEGER default '0', |
208 | | - rc_user_text varchar(255) , |
209 | | - rc_namespace INTEGER default '0', |
210 | | - rc_title varchar(255) default '', |
211 | | - rc_comment varchar(255) default '', |
212 | | - rc_minor tinyint default '0', |
213 | | - rc_bot tinyint default '0', |
214 | | - rc_new tinyint default '0', |
215 | | - rc_cur_id INTEGER default '0', |
216 | | - rc_this_oldid INTEGER default '0', |
217 | | - rc_last_oldid INTEGER default '0', |
218 | | - rc_type tinyint default '0', |
219 | | - rc_moved_to_ns tinyint default '0', |
220 | | - rc_moved_to_title varchar(255) default '', |
221 | | - rc_patrolled tinyint default '0', |
222 | | - rc_ip varBLOB default '', |
223 | | - rc_old_len int, |
224 | | - rc_new_len int, |
225 | | - rc_deleted tinyint default '0', |
226 | | - rc_logid INTEGER default '0', |
227 | | - rc_log_type varBLOB NULL default NULL, |
228 | | - rc_log_action varBLOB NULL default NULL, |
229 | | - rc_params blob NULL) /*$wgDBTableOptions*/; |
230 | | - |
231 | | -CREATE TABLE /*$wgDBprefix*/watchlist ( |
232 | | - wl_user INTEGER , |
233 | | - wl_namespace INTEGER default '0', |
234 | | - wl_title varchar(255) default '', |
235 | | - wl_notificationtimestamp varBLOB) /*$wgDBTableOptions*/; |
236 | | - |
237 | | -CREATE TABLE /*$wgDBprefix*/math ( |
238 | | - math_inputhash varBLOB , |
239 | | - math_outputhash varBLOB , |
240 | | - math_html_conservativeness tinyint , |
241 | | - math_html text, |
242 | | - math_mathml text) /*$wgDBTableOptions*/; |
243 | | - |
244 | | -CREATE TABLE /*$wgDBprefix*/searchindex ( |
245 | | - si_page INTEGER , |
246 | | - si_title varchar(255) default '', |
247 | | - si_text mediumtext ) ; |
248 | | - |
249 | | -CREATE TABLE /*$wgDBprefix*/interwiki ( |
250 | | - iw_prefix varchar(32) , |
251 | | - iw_url blob , |
252 | | - iw_local bool , |
253 | | - iw_trans tinyint default 0) /*$wgDBTableOptions*/; |
254 | | - |
255 | | -CREATE TABLE /*$wgDBprefix*/querycache ( |
256 | | - qc_type varBLOB , |
257 | | - qc_value INTEGER default '0', |
258 | | - qc_namespace INTEGER default '0', |
259 | | - qc_title varchar(255) default '') /*$wgDBTableOptions*/; |
260 | | - |
261 | | -CREATE TABLE /*$wgDBprefix*/objectcache ( |
262 | | - keyname varBLOB default '', |
263 | | - value mediumblob, |
264 | | - exptime datetime) /*$wgDBTableOptions*/; |
265 | | - |
266 | | -CREATE TABLE /*$wgDBprefix*/transcache ( |
267 | | - tc_url varBLOB , |
268 | | - tc_contents text, |
269 | | - tc_time INTEGER ) /*$wgDBTableOptions*/; |
270 | | - |
271 | | -CREATE TABLE /*$wgDBprefix*/logging ( |
272 | | - log_id INTEGER PRIMARY KEY AUTOINCREMENT, |
273 | | - log_type varBLOB default '', |
274 | | - log_action varBLOB default '', |
275 | | - log_timestamp BLOB default '19700101000000', |
276 | | - log_user INTEGER default 0, |
277 | | - log_namespace INTEGER default 0, |
278 | | - log_title varchar(255) default '', |
279 | | - log_comment varchar(255) default '', |
280 | | - log_params blob , |
281 | | - log_deleted tinyint default '0') /*$wgDBTableOptions*/; |
282 | | - |
283 | | -CREATE TABLE /*$wgDBprefix*/trackbacks ( |
284 | | - tb_id INTEGER PRIMARY KEY AUTOINCREMENT, |
285 | | - tb_page INTEGER REFERENCES /*$wgDBprefix*/page(page_id) ON DELETE CASCADE, |
286 | | - tb_title varchar(255) , |
287 | | - tb_url blob , |
288 | | - tb_ex text, |
289 | | - tb_name varchar(255)) /*$wgDBTableOptions*/; |
290 | | - |
291 | | -CREATE TABLE /*$wgDBprefix*/job ( |
292 | | - job_id INTEGER PRIMARY KEY AUTOINCREMENT, |
293 | | - job_cmd varBLOB default '', |
294 | | - job_namespace INTEGER , |
295 | | - job_title varchar(255) , |
296 | | - job_params blob ) /*$wgDBTableOptions*/; |
297 | | - |
298 | | -CREATE TABLE /*$wgDBprefix*/querycache_info ( |
299 | | - qci_type varBLOB default '', |
300 | | - qci_timestamp BLOB default '19700101000000') /*$wgDBTableOptions*/; |
301 | | - |
302 | | -CREATE TABLE /*$wgDBprefix*/redirect ( |
303 | | - rd_from INTEGER default '0', |
304 | | - rd_namespace INTEGER default '0', |
305 | | - rd_title varchar(255) default '') /*$wgDBTableOptions*/; |
306 | | - |
307 | | -CREATE TABLE /*$wgDBprefix*/querycachetwo ( |
308 | | - qcc_type varBLOB , |
309 | | - qcc_value INTEGER default '0', |
310 | | - qcc_namespace INTEGER default '0', |
311 | | - qcc_title varchar(255) default '', |
312 | | - qcc_namespacetwo INTEGER default '0', |
313 | | - qcc_titletwo varchar(255) default '') /*$wgDBTableOptions*/; |
314 | | - |
315 | | -CREATE TABLE /*$wgDBprefix*/page_restrictions ( |
316 | | - pr_page INTEGER , |
317 | | - pr_type varBLOB , |
318 | | - pr_level varBLOB , |
319 | | - pr_cascade tinyint , |
320 | | - pr_user INTEGER NULL, |
321 | | - pr_expiry varBLOB NULL, |
322 | | - pr_id INTEGER PRIMARY KEY AUTOINCREMENT) /*$wgDBTableOptions*/; |
323 | | - |
324 | | -CREATE TABLE /*$wgDBprefix*/protected_titles ( |
325 | | - pt_namespace INTEGER , |
326 | | - pt_title varchar(255) , |
327 | | - pt_user INTEGER , |
328 | | - pt_reason tinyblob, |
329 | | - pt_timestamp BLOB , |
330 | | - pt_expiry varBLOB default '', |
331 | | - pt_create_perm varBLOB ) /*$wgDBTableOptions*/; |
332 | | - |
333 | | -CREATE TABLE /*$wgDBprefix*/page_props ( |
334 | | - pp_page INTEGER , |
335 | | - pp_propname varBLOB , |
336 | | - pp_value blob ) /*$wgDBTableOptions*/; |
337 | | - |
338 | | -CREATE TABLE /*$wgDBprefix*/updatelog ( |
339 | | - ul_key varchar(255) ) /*$wgDBTableOptions*/; |
340 | | - |
341 | | - |
Index: trunk/phase3/maintenance/sqlite/archives/initial-indexes.sql |
— | — | @@ -0,0 +1,417 @@ |
| 2 | +-- Correct for the total lack of indexes in the MW 1.13 SQLite schema |
| 3 | +-- |
| 4 | +-- Unique indexes need to be handled with INSERT SELECT since just running |
| 5 | +-- the CREATE INDEX statement will fail if there are duplicate values. |
| 6 | +-- |
| 7 | +-- Ignore duplicates, several tables will have them (e.g. bug 16966) but in |
| 8 | +-- most cases it's harmless to discard them. We'll keep the old tables with |
| 9 | +-- duplicates in so that the user can recover them in case of disaster. |
| 10 | + |
| 11 | +-------------------------------------------------------------------------------- |
| 12 | +-- Drop temporary tables from aborted runs |
| 13 | +-------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +DROP TABLE IF EXISTS /*_*/user_tmp; |
| 16 | +DROP TABLE IF EXISTS /*_*/user_groups_tmp; |
| 17 | +DROP TABLE IF EXISTS /*_*/page_tmp; |
| 18 | +DROP TABLE IF EXISTS /*_*/revision_tmp; |
| 19 | +DROP TABLE IF EXISTS /*_*/pagelinks_tmp; |
| 20 | +DROP TABLE IF EXISTS /*_*/templatelinks_tmp; |
| 21 | +DROP TABLE IF EXISTS /*_*/imagelinks_tmp; |
| 22 | +DROP TABLE IF EXISTS /*_*/categorylinks_tmp; |
| 23 | +DROP TABLE IF EXISTS /*_*/category_tmp; |
| 24 | +DROP TABLE IF EXISTS /*_*/langlinks_tmp; |
| 25 | +DROP TABLE IF EXISTS /*_*/site_stats_tmp; |
| 26 | +DROP TABLE IF EXISTS /*_*/ipblocks_tmp; |
| 27 | +DROP TABLE IF EXISTS /*_*/watchlist_tmp; |
| 28 | +DROP TABLE IF EXISTS /*_*/math_tmp; |
| 29 | +DROP TABLE IF EXISTS /*_*/interwiki_tmp; |
| 30 | +DROP TABLE IF EXISTS /*_*/page_restrictions_tmp; |
| 31 | +DROP TABLE IF EXISTS /*_*/protected_titles_tmp; |
| 32 | +DROP TABLE IF EXISTS /*_*/page_props_tmp; |
| 33 | + |
| 34 | +-------------------------------------------------------------------------------- |
| 35 | +-- Create new tables |
| 36 | +-------------------------------------------------------------------------------- |
| 37 | + |
| 38 | +CREATE TABLE /*_*/user_tmp ( |
| 39 | + user_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 40 | + user_name varchar(255) binary NOT NULL default '', |
| 41 | + user_real_name varchar(255) binary NOT NULL default '', |
| 42 | + user_password tinyblob NOT NULL, |
| 43 | + user_newpassword tinyblob NOT NULL, |
| 44 | + user_newpass_time binary(14), |
| 45 | + user_email tinytext NOT NULL, |
| 46 | + user_options blob NOT NULL, |
| 47 | + user_touched binary(14) NOT NULL default '', |
| 48 | + user_token binary(32) NOT NULL default '', |
| 49 | + user_email_authenticated binary(14), |
| 50 | + user_email_token binary(32), |
| 51 | + user_email_token_expires binary(14), |
| 52 | + user_registration binary(14), |
| 53 | + user_editcount int |
| 54 | +); |
| 55 | +CREATE UNIQUE INDEX user_name ON /*_*/user_tmp (user_name); |
| 56 | +CREATE INDEX user_email_token ON /*_*/user_tmp (user_email_token); |
| 57 | + |
| 58 | + |
| 59 | +CREATE TABLE /*_*/user_groups_tmp ( |
| 60 | + ug_user int unsigned NOT NULL default 0, |
| 61 | + ug_group varbinary(16) NOT NULL default '' |
| 62 | +); |
| 63 | + |
| 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); |
| 66 | + |
| 67 | +CREATE TABLE /*_*/page_tmp ( |
| 68 | + page_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 69 | + page_namespace int NOT NULL, |
| 70 | + page_title varchar(255) binary NOT NULL, |
| 71 | + page_restrictions tinyblob NOT NULL, |
| 72 | + page_counter bigint unsigned NOT NULL default 0, |
| 73 | + page_is_redirect tinyint unsigned NOT NULL default 0, |
| 74 | + page_is_new tinyint unsigned NOT NULL default 0, |
| 75 | + page_random real unsigned NOT NULL, |
| 76 | + page_touched binary(14) NOT NULL default '', |
| 77 | + page_latest int unsigned NOT NULL, |
| 78 | + page_len int unsigned NOT NULL |
| 79 | +); |
| 80 | + |
| 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); |
| 84 | + |
| 85 | + |
| 86 | +CREATE TABLE /*_*/revision_tmp ( |
| 87 | + rev_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 88 | + rev_page int unsigned NOT NULL, |
| 89 | + rev_text_id int unsigned NOT NULL, |
| 90 | + rev_comment tinyblob NOT NULL, |
| 91 | + rev_user int unsigned NOT NULL default 0, |
| 92 | + rev_user_text varchar(255) binary NOT NULL default '', |
| 93 | + rev_timestamp binary(14) NOT NULL default '', |
| 94 | + rev_minor_edit tinyint unsigned NOT NULL default 0, |
| 95 | + rev_deleted tinyint unsigned NOT NULL default 0, |
| 96 | + rev_len int unsigned, |
| 97 | + rev_parent_id int unsigned default NULL |
| 98 | +); |
| 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); |
| 104 | + |
| 105 | +CREATE TABLE /*_*/pagelinks_tmp ( |
| 106 | + pl_from int unsigned NOT NULL default 0, |
| 107 | + pl_namespace int NOT NULL default 0, |
| 108 | + pl_title varchar(255) binary NOT NULL default '' |
| 109 | +); |
| 110 | + |
| 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); |
| 113 | + |
| 114 | + |
| 115 | +CREATE TABLE /*_*/templatelinks_tmp ( |
| 116 | + tl_from int unsigned NOT NULL default 0, |
| 117 | + tl_namespace int NOT NULL default 0, |
| 118 | + tl_title varchar(255) binary NOT NULL default '' |
| 119 | +); |
| 120 | + |
| 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); |
| 123 | + |
| 124 | + |
| 125 | +CREATE TABLE /*_*/imagelinks_tmp ( |
| 126 | + il_from int unsigned NOT NULL default 0, |
| 127 | + il_to varchar(255) binary NOT NULL default '' |
| 128 | +) /*$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); |
| 131 | + |
| 132 | + |
| 133 | +CREATE TABLE /*_*/categorylinks_tmp ( |
| 134 | + cl_from int unsigned NOT NULL default 0, |
| 135 | + cl_to varchar(255) binary NOT NULL default '', |
| 136 | + cl_sortkey varchar(70) binary NOT NULL default '', |
| 137 | + cl_timestamp timestamp NOT NULL |
| 138 | +); |
| 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); |
| 142 | + |
| 143 | + |
| 144 | +CREATE TABLE /*_*/category_tmp ( |
| 145 | + cat_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 146 | + cat_title varchar(255) binary NOT NULL, |
| 147 | + cat_pages int signed NOT NULL default 0, |
| 148 | + cat_subcats int signed NOT NULL default 0, |
| 149 | + cat_files int signed NOT NULL default 0, |
| 150 | + cat_hidden tinyint unsigned NOT NULL default 0 |
| 151 | +); |
| 152 | +CREATE UNIQUE INDEX cat_title ON /*_*/category_tmp (cat_title); |
| 153 | +CREATE INDEX cat_pages ON /*_*/category_tmp (cat_pages); |
| 154 | + |
| 155 | +CREATE TABLE /*_*/langlinks_tmp ( |
| 156 | + ll_from int unsigned NOT NULL default 0, |
| 157 | + ll_lang varbinary(20) NOT NULL default '', |
| 158 | + ll_title varchar(255) binary NOT NULL default '' |
| 159 | +); |
| 160 | + |
| 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); |
| 163 | + |
| 164 | + |
| 165 | +CREATE TABLE /*_*/site_stats_tmp ( |
| 166 | + ss_row_id int unsigned NOT NULL, |
| 167 | + ss_total_views bigint unsigned default 0, |
| 168 | + ss_total_edits bigint unsigned default 0, |
| 169 | + ss_good_articles bigint unsigned default 0, |
| 170 | + ss_total_pages bigint default '-1', |
| 171 | + ss_users bigint default '-1', |
| 172 | + ss_active_users bigint default '-1', |
| 173 | + ss_admins int default '-1', |
| 174 | + ss_images int default 0 |
| 175 | +); |
| 176 | +CREATE UNIQUE INDEX ss_row_id ON /*_*/site_stats_tmp (ss_row_id); |
| 177 | + |
| 178 | + |
| 179 | +CREATE TABLE /*_*/ipblocks_tmp ( |
| 180 | + ipb_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, |
| 181 | + ipb_address tinyblob NOT NULL, |
| 182 | + ipb_user int unsigned NOT NULL default 0, |
| 183 | + ipb_by int unsigned NOT NULL default 0, |
| 184 | + ipb_by_text varchar(255) binary NOT NULL default '', |
| 185 | + ipb_reason tinyblob NOT NULL, |
| 186 | + ipb_timestamp binary(14) NOT NULL default '', |
| 187 | + ipb_auto bool NOT NULL default 0, |
| 188 | + |
| 189 | + -- If set to 1, block applies only to logged-out users |
| 190 | + ipb_anon_only bool NOT NULL default 0, |
| 191 | + ipb_create_account bool NOT NULL default 1, |
| 192 | + ipb_enable_autoblock bool NOT NULL default '1', |
| 193 | + ipb_expiry varbinary(14) NOT NULL default '', |
| 194 | + ipb_range_start tinyblob NOT NULL, |
| 195 | + ipb_range_end tinyblob NOT NULL, |
| 196 | + ipb_deleted bool NOT NULL default 0, |
| 197 | + ipb_block_email bool NOT NULL default 0, |
| 198 | + ipb_allow_usertalk bool NOT NULL default 0 |
| 199 | +); |
| 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); |
| 205 | + |
| 206 | + |
| 207 | +CREATE TABLE /*_*/watchlist_tmp ( |
| 208 | + wl_user int unsigned NOT NULL, |
| 209 | + wl_namespace int NOT NULL default 0, |
| 210 | + wl_title varchar(255) binary NOT NULL default '', |
| 211 | + wl_notificationtimestamp varbinary(14) |
| 212 | +); |
| 213 | + |
| 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); |
| 216 | + |
| 217 | + |
| 218 | +CREATE TABLE /*_*/math_tmp ( |
| 219 | + math_inputhash varbinary(16) NOT NULL, |
| 220 | + math_outputhash varbinary(16) NOT NULL, |
| 221 | + math_html_conservativeness tinyint NOT NULL, |
| 222 | + math_html text, |
| 223 | + math_mathml text |
| 224 | +); |
| 225 | + |
| 226 | +CREATE UNIQUE INDEX math_inputhash ON /*_*/math_tmp (math_inputhash); |
| 227 | + |
| 228 | + |
| 229 | +CREATE TABLE /*_*/interwiki_tmp ( |
| 230 | + iw_prefix varchar(32) NOT NULL, |
| 231 | + iw_url blob NOT NULL, |
| 232 | + iw_local bool NOT NULL, |
| 233 | + iw_trans tinyint NOT NULL default 0 |
| 234 | +); |
| 235 | + |
| 236 | +CREATE UNIQUE INDEX iw_prefix ON /*_*/interwiki_tmp (iw_prefix); |
| 237 | + |
| 238 | + |
| 239 | +CREATE TABLE /*_*/page_restrictions_tmp ( |
| 240 | + pr_page int NOT NULL, |
| 241 | + pr_type varbinary(60) NOT NULL, |
| 242 | + pr_level varbinary(60) NOT NULL, |
| 243 | + pr_cascade tinyint NOT NULL, |
| 244 | + pr_user int NULL, |
| 245 | + pr_expiry varbinary(14) NULL, |
| 246 | + pr_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT |
| 247 | +); |
| 248 | + |
| 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); |
| 253 | + |
| 254 | +CREATE TABLE /*_*/protected_titles_tmp ( |
| 255 | + pt_namespace int NOT NULL, |
| 256 | + pt_title varchar(255) binary NOT NULL, |
| 257 | + pt_user int unsigned NOT NULL, |
| 258 | + pt_reason tinyblob, |
| 259 | + pt_timestamp binary(14) NOT NULL, |
| 260 | + pt_expiry varbinary(14) NOT NULL default '', |
| 261 | + pt_create_perm varbinary(60) NOT NULL |
| 262 | +); |
| 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); |
| 265 | + |
| 266 | +CREATE TABLE /*_*/page_props_tmp ( |
| 267 | + pp_page int NOT NULL, |
| 268 | + pp_propname varbinary(60) NOT NULL, |
| 269 | + pp_value blob NOT NULL |
| 270 | +); |
| 271 | +CREATE UNIQUE INDEX pp_page_propname ON /*_*/page_props_tmp (pp_page,pp_propname); |
| 272 | + |
| 273 | +-------------------------------------------------------------------------------- |
| 274 | +-- Populate the new tables using INSERT SELECT |
| 275 | +-------------------------------------------------------------------------------- |
| 276 | + |
| 277 | +INSERT OR IGNORE INTO /*_*/user_tmp SELECT * FROM /*_*/user; |
| 278 | +INSERT OR IGNORE INTO /*_*/user_groups_tmp SELECT * FROM /*_*/user_groups; |
| 279 | +INSERT OR IGNORE INTO /*_*/page_tmp SELECT * FROM /*_*/page; |
| 280 | +INSERT OR IGNORE INTO /*_*/revision_tmp SELECT * FROM /*_*/revision; |
| 281 | +INSERT OR IGNORE INTO /*_*/pagelinks_tmp SELECT * FROM /*_*/pagelinks; |
| 282 | +INSERT OR IGNORE INTO /*_*/templatelinks_tmp SELECT * FROM /*_*/templatelinks; |
| 283 | +INSERT OR IGNORE INTO /*_*/imagelinks_tmp SELECT * FROM /*_*/imagelinks; |
| 284 | +INSERT OR IGNORE INTO /*_*/categorylinks_tmp SELECT * FROM /*_*/categorylinks; |
| 285 | +INSERT OR IGNORE INTO /*_*/category_tmp SELECT * FROM /*_*/category; |
| 286 | +INSERT OR IGNORE INTO /*_*/langlinks_tmp SELECT * FROM /*_*/langlinks; |
| 287 | +INSERT OR IGNORE INTO /*_*/site_stats_tmp SELECT * FROM /*_*/site_stats; |
| 288 | +INSERT OR IGNORE INTO /*_*/ipblocks_tmp SELECT * FROM /*_*/ipblocks; |
| 289 | +INSERT OR IGNORE INTO /*_*/watchlist_tmp SELECT * FROM /*_*/watchlist; |
| 290 | +INSERT OR IGNORE INTO /*_*/math_tmp SELECT * FROM /*_*/math; |
| 291 | +INSERT OR IGNORE INTO /*_*/interwiki_tmp SELECT * FROM /*_*/interwiki; |
| 292 | +INSERT OR IGNORE INTO /*_*/page_restrictions_tmp SELECT * FROM /*_*/page_restrictions; |
| 293 | +INSERT OR IGNORE INTO /*_*/protected_titles_tmp SELECT * FROM /*_*/protected_titles; |
| 294 | +INSERT OR IGNORE INTO /*_*/page_props_tmp SELECT * FROM /*_*/page_props; |
| 295 | + |
| 296 | +-------------------------------------------------------------------------------- |
| 297 | +-- Do the table renames |
| 298 | +-------------------------------------------------------------------------------- |
| 299 | + |
| 300 | +ALTER TABLE /*_*/user RENAME TO /*_*/user_old_13; |
| 301 | +ALTER TABLE /*_*/user_tmp RENAME TO /*_*/user; |
| 302 | +ALTER TABLE /*_*/user_groups RENAME TO /*_*/user_groups_old_13; |
| 303 | +ALTER TABLE /*_*/user_groups_tmp RENAME TO /*_*/user_groups; |
| 304 | +ALTER TABLE /*_*/page RENAME TO /*_*/page_old_13; |
| 305 | +ALTER TABLE /*_*/page_tmp RENAME TO /*_*/page; |
| 306 | +ALTER TABLE /*_*/revision RENAME TO /*_*/revision_old_13; |
| 307 | +ALTER TABLE /*_*/revision_tmp RENAME TO /*_*/revision; |
| 308 | +ALTER TABLE /*_*/pagelinks RENAME TO /*_*/pagelinks_old_13; |
| 309 | +ALTER TABLE /*_*/pagelinks_tmp RENAME TO /*_*/pagelinks; |
| 310 | +ALTER TABLE /*_*/templatelinks RENAME TO /*_*/templatelinks_old_13; |
| 311 | +ALTER TABLE /*_*/templatelinks_tmp RENAME TO /*_*/templatelinks; |
| 312 | +ALTER TABLE /*_*/imagelinks RENAME TO /*_*/imagelinks_old_13; |
| 313 | +ALTER TABLE /*_*/imagelinks_tmp RENAME TO /*_*/imagelinks; |
| 314 | +ALTER TABLE /*_*/categorylinks RENAME TO /*_*/categorylinks_old_13; |
| 315 | +ALTER TABLE /*_*/categorylinks_tmp RENAME TO /*_*/categorylinks; |
| 316 | +ALTER TABLE /*_*/category RENAME TO /*_*/category_old_13; |
| 317 | +ALTER TABLE /*_*/category_tmp RENAME TO /*_*/category; |
| 318 | +ALTER TABLE /*_*/langlinks RENAME TO /*_*/langlinks_old_13; |
| 319 | +ALTER TABLE /*_*/langlinks_tmp RENAME TO /*_*/langlinks; |
| 320 | +ALTER TABLE /*_*/site_stats RENAME TO /*_*/site_stats_old_13; |
| 321 | +ALTER TABLE /*_*/site_stats_tmp RENAME TO /*_*/site_stats; |
| 322 | +ALTER TABLE /*_*/ipblocks RENAME TO /*_*/ipblocks_old_13; |
| 323 | +ALTER TABLE /*_*/ipblocks_tmp RENAME TO /*_*/ipblocks; |
| 324 | +ALTER TABLE /*_*/watchlist RENAME TO /*_*/watchlist_old_13; |
| 325 | +ALTER TABLE /*_*/watchlist_tmp RENAME TO /*_*/watchlist; |
| 326 | +ALTER TABLE /*_*/math RENAME TO /*_*/math_old_13; |
| 327 | +ALTER TABLE /*_*/math_tmp RENAME TO /*_*/math; |
| 328 | +ALTER TABLE /*_*/interwiki RENAME TO /*_*/interwiki_old_13; |
| 329 | +ALTER TABLE /*_*/interwiki_tmp RENAME TO /*_*/interwiki; |
| 330 | +ALTER TABLE /*_*/page_restrictions RENAME TO /*_*/page_restrictions_old_13; |
| 331 | +ALTER TABLE /*_*/page_restrictions_tmp RENAME TO /*_*/page_restrictions; |
| 332 | +ALTER TABLE /*_*/protected_titles RENAME TO /*_*/protected_titles_old_13; |
| 333 | +ALTER TABLE /*_*/protected_titles_tmp RENAME TO /*_*/protected_titles; |
| 334 | +ALTER TABLE /*_*/page_props RENAME TO /*_*/page_props_old_13; |
| 335 | +ALTER TABLE /*_*/page_props_tmp RENAME TO /*_*/page_props; |
| 336 | + |
| 337 | +-------------------------------------------------------------------------------- |
| 338 | +-- Drop and create tables with unique indexes but no valuable data |
| 339 | +-------------------------------------------------------------------------------- |
| 340 | + |
| 341 | + |
| 342 | +DROP TABLE IF EXISTS /*_*/searchindex; |
| 343 | +CREATE TABLE /*_*/searchindex ( |
| 344 | + si_page int unsigned NOT NULL, |
| 345 | + si_title varchar(255) NOT NULL default '', |
| 346 | + si_text mediumtext NOT NULL |
| 347 | +); |
| 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); |
| 351 | + |
| 352 | +DROP TABLE IF EXISTS /*_*/transcache; |
| 353 | +CREATE TABLE /*_*/transcache ( |
| 354 | + tc_url varbinary(255) NOT NULL, |
| 355 | + tc_contents text, |
| 356 | + tc_time int NOT NULL |
| 357 | +) /*$wgDBTableOptions*/; |
| 358 | +CREATE UNIQUE INDEX tc_url_idx ON /*_*/transcache (tc_url); |
| 359 | + |
| 360 | +DROP TABLE IF EXISTS /*_*/querycache_info; |
| 361 | +CREATE TABLE /*_*/querycache_info ( |
| 362 | + qci_type varbinary(32) NOT NULL default '', |
| 363 | + qci_timestamp binary(14) NOT NULL default '19700101000000' |
| 364 | +) /*$wgDBTableOptions*/; |
| 365 | +CREATE UNIQUE INDEX qci_type ON /*_*/querycache_info (qci_type); |
| 366 | + |
| 367 | +-------------------------------------------------------------------------------- |
| 368 | +-- Empty some cache tables to make the update faster |
| 369 | +-------------------------------------------------------------------------------- |
| 370 | + |
| 371 | +DELETE FROM /*_*/querycache; |
| 372 | +DELETE FROM /*_*/objectcache; |
| 373 | +DELETE FROM /*_*/querycachetwo; |
| 374 | + |
| 375 | +-------------------------------------------------------------------------------- |
| 376 | +-- Add indexes to tables with no unique indexes |
| 377 | +-------------------------------------------------------------------------------- |
| 378 | + |
| 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); |
| 417 | + |
| 418 | +INSERT INTO /*_*/updatelog VALUES ('initial_indexes'); |
Property changes on: trunk/phase3/maintenance/sqlite/archives/initial-indexes.sql |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 419 | + native |
Index: trunk/phase3/maintenance/sqlite/README |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +SQLite shares the MySQL schema file at maintenance/tables.sql, with a set of |
| 3 | +compatibility regexes to convert MySQL syntax to SQLite syntax: |
| 4 | + |
| 5 | +* BINARY() and VARBINARY() fields are converted to BLOB |
| 6 | +* the UNSIGNED modifier is removed |
| 7 | +* "INT" fields are converted to "INTEGER" |
| 8 | +* ENUM is converted to BLOB |
| 9 | +* the BINARY collation modifier is removed |
| 10 | +* AUTO_INCREMENT is converted to AUTOINCREMENT |
| 11 | +* Any table options are removed |
| 12 | +* Truncated indexes are upgraded to full-width indexes |
| 13 | +* FULLTEXT indexes are converted to ordinary indexes |
Property changes on: trunk/phase3/maintenance/sqlite/README |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 14 | + native |
Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -16,138 +16,148 @@ |
17 | 17 | require_once( "$IP/includes/Hooks.php" ); |
18 | 18 | |
19 | 19 | /** |
20 | | - * List of update functions to call on a MySQL-based MediaWiki installation, |
21 | | - * in sequence. First item is function name, rest are parameters to pass. |
| 20 | + * List of update functions to call for each DB type, in sequence. First item |
| 21 | + * is function name, rest are parameters to pass. |
22 | 22 | */ |
23 | | -$wgMysqlUpdates = array( |
24 | | - // 1.2 |
25 | | - // update_passwords obsolete |
26 | | - array( 'add_field', 'ipblocks', 'ipb_id', 'patch-ipblocks.sql' ), |
27 | | - array( 'add_field', 'ipblocks', 'ipb_expiry', 'patch-ipb_expiry.sql' ), |
28 | | - array( 'do_interwiki_update' ), |
29 | | - array( 'do_index_update' ), |
30 | | - // do_linkscc_update obsolete |
31 | | - array( 'add_table', 'hitcounter', 'patch-hitcounter.sql' ), |
32 | | - array( 'add_field', 'recentchanges', 'rc_type', 'patch-rc_type.sql' ), |
33 | | - |
34 | | - // 1.3 |
35 | | - array( 'add_field', 'user', 'user_real_name', 'patch-user-realname.sql' ), |
36 | | - array( 'add_table', 'querycache', 'patch-querycache.sql' ), |
37 | | - array( 'add_table', 'objectcache', 'patch-objectcache.sql' ), |
38 | | - array( 'add_table', 'categorylinks', 'patch-categorylinks.sql' ), |
39 | | - // do_linkscc_1_3_update obsolete |
40 | | - array( 'do_old_links_update' ), |
41 | | - array( 'add_field', 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ), |
42 | | - |
43 | | - // 1.4 |
44 | | - array( 'do_image_name_unique_update' ), |
45 | | - array( 'add_field', 'recentchanges', 'rc_id', 'patch-rc_id.sql' ), |
46 | | - array( 'add_field', 'recentchanges', 'rc_patrolled', 'patch-rc-patrol.sql' ), |
47 | | - array( 'add_table', 'logging', 'patch-logging.sql' ), |
48 | | - // do_user_rights_update obsolete |
49 | | - array( 'add_field', 'user', 'user_token', 'patch-user_token.sql' ), |
50 | | - // old, old_articleid, patch-remove-old-title-namespace.sql obsolete |
51 | | - // user_groups, patch-userlevels.sql obsolete |
52 | | - // do_group_update() obsolete |
53 | | - array( 'do_watchlist_update' ), |
54 | | - array( 'do_user_update' ), |
55 | | - // do_copy_newtalk_to_watchlist obsolete |
56 | | - |
57 | | - // 1.5 |
58 | | - array( 'do_schema_restructuring' ), |
59 | | - array( 'add_field', 'logging', 'log_params', 'patch-log_params.sql' ), |
60 | | - array( 'check_bin', 'logging', 'log_title', 'patch-logging-title.sql', ), |
61 | | - array( 'add_field', 'archive', 'ar_rev_id', 'patch-archive-rev_id.sql' ), |
62 | | - array( 'add_field', 'page', 'page_len', 'patch-page_len.sql' ), |
63 | | - array( 'do_inverse_timestamp' ), |
64 | | - array( 'do_text_id' ), |
65 | | - array( 'add_field', 'revision', 'rev_deleted', 'patch-rev_deleted.sql' ), |
66 | | - array( 'add_field', 'image', 'img_width', 'patch-img_width.sql' ), |
67 | | - array( 'add_field', 'image', 'img_metadata', 'patch-img_metadata.sql' ), |
68 | | - array( 'add_field', 'user', 'user_email_token', 'patch-user_email_token.sql' ), |
69 | | - array( 'add_field', 'archive', 'ar_text_id', 'patch-archive-text_id.sql' ), |
70 | | - array( 'do_namespace_size' ), |
71 | | - array( 'add_field', 'image', 'img_media_type', 'patch-img_media_type.sql' ), |
72 | | - array( 'do_pagelinks_update' ), |
73 | | - array( 'do_drop_img_type' ), |
74 | | - array( 'do_user_unique_update' ), |
75 | | - array( 'do_user_groups_update' ), |
76 | | - array( 'add_field', 'site_stats', 'ss_total_pages', 'patch-ss_total_articles.sql' ), |
77 | | - array( 'add_table', 'user_newtalk', 'patch-usernewtalk2.sql' ), |
78 | | - array( 'add_table', 'transcache', 'patch-transcache.sql' ), |
79 | | - array( 'add_field', 'interwiki', 'iw_trans', 'patch-interwiki-trans.sql' ), |
80 | | - array( 'add_table', 'trackbacks', 'patch-trackbacks.sql' ), |
81 | | - |
82 | | - // 1.6 |
83 | | - array( 'do_watchlist_null' ), |
84 | | - // do_image_index_update obsolete |
85 | | - array( 'do_logging_timestamp_index' ), |
86 | | - array( 'add_field', 'ipblocks', 'ipb_range_start', 'patch-ipb_range_start.sql' ), |
87 | | - array( 'do_page_random_update' ), |
88 | | - array( 'add_field', 'user', 'user_registration','patch-user_registration.sql' ), |
89 | | - array( 'do_templatelinks_update' ), |
90 | | - array( 'add_table', 'externallinks', 'patch-externallinks.sql' ), |
91 | | - array( 'add_table', 'job', 'patch-job.sql' ), |
92 | | - array( 'add_field', 'site_stats', 'ss_images', 'patch-ss_images.sql' ), |
93 | | - array( 'add_table', 'langlinks', 'patch-langlinks.sql' ), |
94 | | - array( 'add_table', 'querycache_info', 'patch-querycacheinfo.sql' ), |
95 | | - array( 'add_table', 'filearchive', 'patch-filearchive.sql' ), |
96 | | - array( 'add_field', 'ipblocks', 'ipb_anon_only', 'patch-ipb_anon_only.sql' ), |
97 | | - array( 'do_rc_indices_update' ), |
98 | | - |
99 | | - // 1.9 |
100 | | - array( 'add_field', 'user', 'user_newpass_time', 'patch-user_newpass_time.sql' ), |
101 | | - array( 'add_table', 'redirect', 'patch-redirect.sql' ), |
102 | | - array( 'add_table', 'querycachetwo', 'patch-querycachetwo.sql' ), |
103 | | - array( 'add_field', 'ipblocks', 'ipb_enable_autoblock', 'patch-ipb_optional_autoblock.sql' ), |
104 | | - array( 'do_backlinking_indices_update' ), |
105 | | - array( 'add_field', 'recentchanges', 'rc_old_len', 'patch-rc_len.sql' ), |
106 | | - array( 'add_field', 'user', 'user_editcount', 'patch-user_editcount.sql' ), |
107 | | - |
108 | | - // 1.10 |
109 | | - array( 'do_restrictions_update' ), |
110 | | - array( 'add_field', 'logging', 'log_id', 'patch-log_id.sql' ), |
111 | | - array( 'add_field', 'revision', 'rev_parent_id', 'patch-rev_parent_id.sql' ), |
112 | | - array( 'add_field', 'page_restrictions', 'pr_id', 'patch-page_restrictions_sortkey.sql' ), |
113 | | - array( 'add_field', 'revision', 'rev_len', 'patch-rev_len.sql' ), |
114 | | - array( 'add_field', 'recentchanges', 'rc_deleted', 'patch-rc_deleted.sql' ), |
115 | | - array( 'add_field', 'logging', 'log_deleted', 'patch-log_deleted.sql' ), |
116 | | - array( 'add_field', 'archive', 'ar_deleted', 'patch-ar_deleted.sql' ), |
117 | | - array( 'add_field', 'ipblocks', 'ipb_deleted', 'patch-ipb_deleted.sql' ), |
118 | | - array( 'add_field', 'filearchive', 'fa_deleted', 'patch-fa_deleted.sql' ), |
119 | | - array( 'add_field', 'archive', 'ar_len', 'patch-ar_len.sql' ), |
120 | | - |
121 | | - // 1.11 |
122 | | - array( 'add_field', 'ipblocks', 'ipb_block_email', 'patch-ipb_emailban.sql' ), |
123 | | - array( 'do_categorylinks_indices_update' ), |
124 | | - array( 'add_field', 'oldimage', 'oi_metadata', 'patch-oi_metadata.sql'), |
125 | | - array( 'do_archive_user_index' ), |
126 | | - array( 'do_image_user_index' ), |
127 | | - array( 'do_oldimage_user_index' ), |
128 | | - array( 'add_field', 'archive', 'ar_page_id', 'patch-archive-page_id.sql'), |
129 | | - array( 'add_field', 'image', 'img_sha1', 'patch-img_sha1.sql' ), |
| 23 | +$wgUpdates = array( |
| 24 | + 'mysql' => array( |
| 25 | + // 1.2 |
| 26 | + // update_passwords obsolete |
| 27 | + array( 'add_field', 'ipblocks', 'ipb_id', 'patch-ipblocks.sql' ), |
| 28 | + array( 'add_field', 'ipblocks', 'ipb_expiry', 'patch-ipb_expiry.sql' ), |
| 29 | + array( 'do_interwiki_update' ), |
| 30 | + array( 'do_index_update' ), |
| 31 | + // do_linkscc_update obsolete |
| 32 | + array( 'add_table', 'hitcounter', 'patch-hitcounter.sql' ), |
| 33 | + array( 'add_field', 'recentchanges', 'rc_type', 'patch-rc_type.sql' ), |
| 34 | + |
| 35 | + // 1.3 |
| 36 | + array( 'add_field', 'user', 'user_real_name', 'patch-user-realname.sql' ), |
| 37 | + array( 'add_table', 'querycache', 'patch-querycache.sql' ), |
| 38 | + array( 'add_table', 'objectcache', 'patch-objectcache.sql' ), |
| 39 | + array( 'add_table', 'categorylinks', 'patch-categorylinks.sql' ), |
| 40 | + // do_linkscc_1_3_update obsolete |
| 41 | + array( 'do_old_links_update' ), |
| 42 | + array( 'add_field', 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ), |
| 43 | + |
| 44 | + // 1.4 |
| 45 | + array( 'do_image_name_unique_update' ), |
| 46 | + array( 'add_field', 'recentchanges', 'rc_id', 'patch-rc_id.sql' ), |
| 47 | + array( 'add_field', 'recentchanges', 'rc_patrolled', 'patch-rc-patrol.sql' ), |
| 48 | + array( 'add_table', 'logging', 'patch-logging.sql' ), |
| 49 | + // do_user_rights_update obsolete |
| 50 | + array( 'add_field', 'user', 'user_token', 'patch-user_token.sql' ), |
| 51 | + // old, old_articleid, patch-remove-old-title-namespace.sql obsolete |
| 52 | + // user_groups, patch-userlevels.sql obsolete |
| 53 | + // do_group_update() obsolete |
| 54 | + array( 'do_watchlist_update' ), |
| 55 | + array( 'do_user_update' ), |
| 56 | + // do_copy_newtalk_to_watchlist obsolete |
| 57 | + |
| 58 | + // 1.5 |
| 59 | + array( 'do_schema_restructuring' ), |
| 60 | + array( 'add_field', 'logging', 'log_params', 'patch-log_params.sql' ), |
| 61 | + array( 'check_bin', 'logging', 'log_title', 'patch-logging-title.sql', ), |
| 62 | + array( 'add_field', 'archive', 'ar_rev_id', 'patch-archive-rev_id.sql' ), |
| 63 | + array( 'add_field', 'page', 'page_len', 'patch-page_len.sql' ), |
| 64 | + array( 'do_inverse_timestamp' ), |
| 65 | + array( 'do_text_id' ), |
| 66 | + array( 'add_field', 'revision', 'rev_deleted', 'patch-rev_deleted.sql' ), |
| 67 | + array( 'add_field', 'image', 'img_width', 'patch-img_width.sql' ), |
| 68 | + array( 'add_field', 'image', 'img_metadata', 'patch-img_metadata.sql' ), |
| 69 | + array( 'add_field', 'user', 'user_email_token', 'patch-user_email_token.sql' ), |
| 70 | + array( 'add_field', 'archive', 'ar_text_id', 'patch-archive-text_id.sql' ), |
| 71 | + array( 'do_namespace_size' ), |
| 72 | + array( 'add_field', 'image', 'img_media_type', 'patch-img_media_type.sql' ), |
| 73 | + array( 'do_pagelinks_update' ), |
| 74 | + array( 'do_drop_img_type' ), |
| 75 | + array( 'do_user_unique_update' ), |
| 76 | + array( 'do_user_groups_update' ), |
| 77 | + array( 'add_field', 'site_stats', 'ss_total_pages', 'patch-ss_total_articles.sql' ), |
| 78 | + array( 'add_table', 'user_newtalk', 'patch-usernewtalk2.sql' ), |
| 79 | + array( 'add_table', 'transcache', 'patch-transcache.sql' ), |
| 80 | + array( 'add_field', 'interwiki', 'iw_trans', 'patch-interwiki-trans.sql' ), |
| 81 | + array( 'add_table', 'trackbacks', 'patch-trackbacks.sql' ), |
| 82 | + |
| 83 | + // 1.6 |
| 84 | + array( 'do_watchlist_null' ), |
| 85 | + // do_image_index_update obsolete |
| 86 | + array( 'do_logging_timestamp_index' ), |
| 87 | + array( 'add_field', 'ipblocks', 'ipb_range_start', 'patch-ipb_range_start.sql' ), |
| 88 | + array( 'do_page_random_update' ), |
| 89 | + array( 'add_field', 'user', 'user_registration','patch-user_registration.sql' ), |
| 90 | + array( 'do_templatelinks_update' ), |
| 91 | + array( 'add_table', 'externallinks', 'patch-externallinks.sql' ), |
| 92 | + array( 'add_table', 'job', 'patch-job.sql' ), |
| 93 | + array( 'add_field', 'site_stats', 'ss_images', 'patch-ss_images.sql' ), |
| 94 | + array( 'add_table', 'langlinks', 'patch-langlinks.sql' ), |
| 95 | + array( 'add_table', 'querycache_info', 'patch-querycacheinfo.sql' ), |
| 96 | + array( 'add_table', 'filearchive', 'patch-filearchive.sql' ), |
| 97 | + array( 'add_field', 'ipblocks', 'ipb_anon_only', 'patch-ipb_anon_only.sql' ), |
| 98 | + array( 'do_rc_indices_update' ), |
| 99 | + |
| 100 | + // 1.9 |
| 101 | + array( 'add_field', 'user', 'user_newpass_time', 'patch-user_newpass_time.sql' ), |
| 102 | + array( 'add_table', 'redirect', 'patch-redirect.sql' ), |
| 103 | + array( 'add_table', 'querycachetwo', 'patch-querycachetwo.sql' ), |
| 104 | + array( 'add_field', 'ipblocks', 'ipb_enable_autoblock', 'patch-ipb_optional_autoblock.sql' ), |
| 105 | + array( 'do_backlinking_indices_update' ), |
| 106 | + array( 'add_field', 'recentchanges', 'rc_old_len', 'patch-rc_len.sql' ), |
| 107 | + array( 'add_field', 'user', 'user_editcount', 'patch-user_editcount.sql' ), |
| 108 | + |
| 109 | + // 1.10 |
| 110 | + array( 'do_restrictions_update' ), |
| 111 | + array( 'add_field', 'logging', 'log_id', 'patch-log_id.sql' ), |
| 112 | + array( 'add_field', 'revision', 'rev_parent_id', 'patch-rev_parent_id.sql' ), |
| 113 | + array( 'add_field', 'page_restrictions', 'pr_id', 'patch-page_restrictions_sortkey.sql' ), |
| 114 | + array( 'add_field', 'revision', 'rev_len', 'patch-rev_len.sql' ), |
| 115 | + array( 'add_field', 'recentchanges', 'rc_deleted', 'patch-rc_deleted.sql' ), |
| 116 | + array( 'add_field', 'logging', 'log_deleted', 'patch-log_deleted.sql' ), |
| 117 | + array( 'add_field', 'archive', 'ar_deleted', 'patch-ar_deleted.sql' ), |
| 118 | + array( 'add_field', 'ipblocks', 'ipb_deleted', 'patch-ipb_deleted.sql' ), |
| 119 | + array( 'add_field', 'filearchive', 'fa_deleted', 'patch-fa_deleted.sql' ), |
| 120 | + array( 'add_field', 'archive', 'ar_len', 'patch-ar_len.sql' ), |
| 121 | + |
| 122 | + // 1.11 |
| 123 | + array( 'add_field', 'ipblocks', 'ipb_block_email', 'patch-ipb_emailban.sql' ), |
| 124 | + array( 'do_categorylinks_indices_update' ), |
| 125 | + array( 'add_field', 'oldimage', 'oi_metadata', 'patch-oi_metadata.sql'), |
| 126 | + array( 'do_archive_user_index' ), |
| 127 | + array( 'do_image_user_index' ), |
| 128 | + array( 'do_oldimage_user_index' ), |
| 129 | + array( 'add_field', 'archive', 'ar_page_id', 'patch-archive-page_id.sql'), |
| 130 | + array( 'add_field', 'image', 'img_sha1', 'patch-img_sha1.sql' ), |
130 | 131 | |
131 | | - // 1.12 |
132 | | - array( 'add_table', 'protected_titles', 'patch-protected_titles.sql' ), |
133 | | - |
134 | | - // 1.13 |
135 | | - array( 'add_field', 'ipblocks', 'ipb_by_text', 'patch-ipb_by_text.sql' ), |
136 | | - array( 'add_table', 'page_props', 'patch-page_props.sql' ), |
137 | | - array( 'add_table', 'updatelog', 'patch-updatelog.sql' ), |
138 | | - array( 'add_table', 'category', 'patch-category.sql' ), |
139 | | - array( 'do_category_population' ), |
140 | | - array( 'add_field', 'archive', 'ar_parent_id', 'patch-ar_parent_id.sql'), |
141 | | - array( 'add_field', 'user_newtalk', 'user_last_timestamp', 'patch-user_last_timestamp.sql'), |
142 | | - array( 'do_populate_parent_id' ), |
143 | | - array( 'check_bin', 'protected_titles', 'pt_title', 'patch-pt_title-encoding.sql', ), |
144 | | - array( 'maybe_do_profiling_memory_update' ), |
145 | | - array( 'do_filearchive_indices_update' ), |
146 | | - array( 'update_password_format' ), |
147 | | - |
148 | | - // 1.14 |
149 | | - array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ), |
150 | | - array( 'do_active_users_init' ), |
151 | | - array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ) |
| 132 | + // 1.12 |
| 133 | + array( 'add_table', 'protected_titles', 'patch-protected_titles.sql' ), |
| 134 | + |
| 135 | + // 1.13 |
| 136 | + array( 'add_field', 'ipblocks', 'ipb_by_text', 'patch-ipb_by_text.sql' ), |
| 137 | + array( 'add_table', 'page_props', 'patch-page_props.sql' ), |
| 138 | + array( 'add_table', 'updatelog', 'patch-updatelog.sql' ), |
| 139 | + array( 'add_table', 'category', 'patch-category.sql' ), |
| 140 | + array( 'do_category_population' ), |
| 141 | + array( 'add_field', 'archive', 'ar_parent_id', 'patch-ar_parent_id.sql'), |
| 142 | + array( 'add_field', 'user_newtalk', 'user_last_timestamp', 'patch-user_last_timestamp.sql'), |
| 143 | + array( 'do_populate_parent_id' ), |
| 144 | + array( 'check_bin', 'protected_titles', 'pt_title', 'patch-pt_title-encoding.sql', ), |
| 145 | + array( 'maybe_do_profiling_memory_update' ), |
| 146 | + array( 'do_filearchive_indices_update' ), |
| 147 | + array( 'update_password_format' ), |
| 148 | + |
| 149 | + // 1.14 |
| 150 | + array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ), |
| 151 | + array( 'do_active_users_init' ), |
| 152 | + array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ), |
| 153 | + ), |
| 154 | + |
| 155 | + 'sqlite' => array( |
| 156 | + // 1.14 |
| 157 | + array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ), |
| 158 | + array( 'do_active_users_init' ), |
| 159 | + array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ), |
| 160 | + array( 'sqlite_initial_indexes' ), |
| 161 | + ), |
152 | 162 | ); |
153 | 163 | |
154 | 164 | |
— | — | @@ -1070,11 +1080,13 @@ |
1071 | 1081 | } |
1072 | 1082 | |
1073 | 1083 | # Run core updates in sequence... |
1074 | | - global $wgMysqlUpdates; |
1075 | | - foreach( $wgMysqlUpdates as $params ) { |
1076 | | - $func = array_shift( $params ); |
1077 | | - call_user_func_array( $func, $params ); |
1078 | | - flush(); |
| 1084 | + global $wgUpdates; |
| 1085 | + if ( isset( $wgUpdates[$wgDBtype] ) ) { |
| 1086 | + foreach( $wgUpdates[$wgDBtype] as $params ) { |
| 1087 | + $func = array_shift( $params ); |
| 1088 | + call_user_func_array( $func, $params ); |
| 1089 | + flush(); |
| 1090 | + } |
1079 | 1091 | } |
1080 | 1092 | |
1081 | 1093 | /// @fixme clean up this mess too! |
— | — | @@ -1112,10 +1124,9 @@ |
1113 | 1125 | |
1114 | 1126 | function archive($name) { |
1115 | 1127 | global $wgDBtype, $IP; |
1116 | | - switch ($wgDBtype) { |
1117 | | - case "postgres": |
1118 | | - return "$IP/maintenance/postgres/archives/$name"; |
1119 | | - default: |
| 1128 | + if ( file_exists( "$IP/maintenance/$wgDBtype/archives/$name" ) ) { |
| 1129 | + return "$IP/maintenance/$wgDBtype/archives/$name"; |
| 1130 | + } else { |
1120 | 1131 | return "$IP/maintenance/archives/$name"; |
1121 | 1132 | } |
1122 | 1133 | } |
— | — | @@ -1243,6 +1254,23 @@ |
1244 | 1255 | echo "done\n"; |
1245 | 1256 | } |
1246 | 1257 | |
| 1258 | +function sqlite_initial_indexes() { |
| 1259 | + global $wgDatabase; |
| 1260 | + if ( update_row_exists( 'initial_indexes' ) ) { |
| 1261 | + echo "...have initial indexes\n"; |
| 1262 | + return; |
| 1263 | + } |
| 1264 | + echo "Adding initial indexes..."; |
| 1265 | + $wgDatabase->sourceFile( archive( 'initial-indexes.sql' ) ); |
| 1266 | + echo "done\n"; |
| 1267 | +} |
| 1268 | + |
| 1269 | + |
| 1270 | +/*********************************************************************** |
| 1271 | + * Start PG crap |
| 1272 | + * TODO: merge with above |
| 1273 | + ***********************************************************************/ |
| 1274 | + |
1247 | 1275 | function |
1248 | 1276 | pg_describe_table($table) |
1249 | 1277 | { |
Index: trunk/phase3/maintenance/tables.sql |
— | — | @@ -2,6 +2,8 @@ |
3 | 3 | -- This is read and executed by the install script; you should |
4 | 4 | -- not have to run it by itself unless doing a manual install. |
5 | 5 | |
| 6 | +-- This is a shared schema file used for both MySQL and SQLite installs. |
| 7 | + |
6 | 8 | -- |
7 | 9 | -- General notes: |
8 | 10 | -- |
— | — | @@ -28,7 +30,7 @@ |
29 | 31 | -- well. |
30 | 32 | -- |
31 | 33 | -- |
| 34 | +-- The /*_*/ comments in this and other files are |
32 | 35 | -- replaced with the defined table prefix by the installer |
33 | 36 | -- and updater scripts. If you are installing or running |
34 | 37 | -- updates manually, you will need to manually insert the |
— | — | @@ -48,8 +50,8 @@ |
49 | 51 | -- preferences and to key tracking information in the other |
50 | 52 | -- tables. |
51 | 53 | -- |
52 | | -CREATE TABLE /*$wgDBprefix*/user ( |
53 | | - user_id int unsigned NOT NULL auto_increment, |
| 54 | +CREATE TABLE /*_*/user ( |
| 55 | + user_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
54 | 56 | |
55 | 57 | -- Usernames must be unique, must not be in the form of |
56 | 58 | -- an IP address. _Shouldn't_ allow slashes or case |
— | — | @@ -124,13 +126,12 @@ |
125 | 127 | -- Meant primarily for heuristic checks to give an impression of whether |
126 | 128 | -- the account has been used much. |
127 | 129 | -- |
128 | | - user_editcount int, |
| 130 | + user_editcount int |
| 131 | +) /*$wgDBTableOptions*/; |
129 | 132 | |
130 | | - PRIMARY KEY user_id (user_id), |
131 | | - UNIQUE INDEX user_name (user_name), |
132 | | - INDEX (user_email_token) |
| 133 | +CREATE UNIQUE INDEX user_name ON /*_*/user (user_name); |
| 134 | +CREATE INDEX user_email_token ON /*_*/user (user_email_token); |
133 | 135 | |
134 | | -) /*$wgDBTableOptions*/; |
135 | 136 | |
136 | 137 | -- |
137 | 138 | -- User permissions have been broken out to a separate table; |
— | — | @@ -140,9 +141,9 @@ |
141 | 142 | -- This table replaces the old user_rights field which used a |
142 | 143 | -- comma-separated blob. |
143 | 144 | -- |
144 | | -CREATE TABLE /*$wgDBprefix*/user_groups ( |
| 145 | +CREATE TABLE /*_*/user_groups ( |
145 | 146 | -- Key to user_id |
146 | | - ug_user int unsigned NOT NULL default '0', |
| 147 | + ug_user int unsigned NOT NULL default 0, |
147 | 148 | |
148 | 149 | -- Group names are short symbolic string keys. |
149 | 150 | -- The set of group names is open-ended, though in practice |
— | — | @@ -152,37 +153,39 @@ |
153 | 154 | -- with particular permissions. A user will have the combined |
154 | 155 | -- permissions of any group they're explicitly in, plus |
155 | 156 | -- the implicit '*' and 'user' groups. |
156 | | - ug_group varbinary(16) NOT NULL default '', |
157 | | - |
158 | | - PRIMARY KEY (ug_user,ug_group), |
159 | | - KEY (ug_group) |
| 157 | + ug_group varbinary(16) NOT NULL default '' |
160 | 158 | ) /*$wgDBTableOptions*/; |
161 | 159 | |
| 160 | +CREATE UNIQUE INDEX ug_user_group ON /*_*/user_groups (ug_user,ug_group); |
| 161 | +CREATE INDEX ug_group ON /*_*/user_groups (ug_group); |
| 162 | + |
| 163 | + |
162 | 164 | -- Stores notifications of user talk page changes, for the display |
163 | 165 | -- of the "you have new messages" box |
164 | | -CREATE TABLE /*$wgDBprefix*/user_newtalk ( |
| 166 | +CREATE TABLE /*_*/user_newtalk ( |
165 | 167 | -- Key to user.user_id |
166 | | - user_id int NOT NULL default '0', |
| 168 | + user_id int NOT NULL default 0, |
167 | 169 | -- If the user is an anonymous user their IP address is stored here |
168 | 170 | -- since the user_id of 0 is ambiguous |
169 | 171 | user_ip varbinary(40) NOT NULL default '', |
170 | 172 | -- The highest timestamp of revisions of the talk page viewed |
171 | 173 | -- by this user |
172 | | - user_last_timestamp binary(14) NOT NULL default '', |
173 | | - INDEX user_id (user_id), |
174 | | - INDEX user_ip (user_ip) |
175 | | - |
| 174 | + user_last_timestamp binary(14) NOT NULL default '' |
176 | 175 | ) /*$wgDBTableOptions*/; |
177 | 176 | |
| 177 | +-- 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 | 180 | |
| 181 | + |
179 | 182 | -- |
180 | 183 | -- Core of the wiki: each page has an entry here which identifies |
181 | 184 | -- it by title and contains some essential metadata. |
182 | 185 | -- |
183 | | -CREATE TABLE /*$wgDBprefix*/page ( |
| 186 | +CREATE TABLE /*_*/page ( |
184 | 187 | -- Unique identifier number. The page_id will be preserved across |
185 | 188 | -- edits and rename operations, but not deletions and recreations. |
186 | | - page_id int unsigned NOT NULL auto_increment, |
| 189 | + page_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
187 | 190 | |
188 | 191 | -- A page name is broken into a namespace and a title. |
189 | 192 | -- The namespace keys are UI-language-independent constants, |
— | — | @@ -198,14 +201,14 @@ |
199 | 202 | page_restrictions tinyblob NOT NULL, |
200 | 203 | |
201 | 204 | -- Number of times this page has been viewed. |
202 | | - page_counter bigint unsigned NOT NULL default '0', |
| 205 | + page_counter bigint unsigned NOT NULL default 0, |
203 | 206 | |
204 | 207 | -- 1 indicates the article is a redirect. |
205 | | - page_is_redirect tinyint unsigned NOT NULL default '0', |
| 208 | + page_is_redirect tinyint unsigned NOT NULL default 0, |
206 | 209 | |
207 | 210 | -- 1 indicates this is a new entry, with only one edit. |
208 | 211 | -- Not all pages with one edit are new pages. |
209 | | - page_is_new tinyint unsigned NOT NULL default '0', |
| 212 | + page_is_new tinyint unsigned NOT NULL default 0, |
210 | 213 | |
211 | 214 | -- Random value between 0 and 1, used for Special:Randompage |
212 | 215 | page_random real unsigned NOT NULL, |
— | — | @@ -223,24 +226,21 @@ |
224 | 227 | page_latest int unsigned NOT NULL, |
225 | 228 | |
226 | 229 | -- Uncompressed length in bytes of the page's current source text. |
227 | | - page_len int unsigned NOT NULL, |
| 230 | + page_len int unsigned NOT NULL |
| 231 | +) /*$wgDBTableOptions*/; |
228 | 232 | |
229 | | - PRIMARY KEY page_id (page_id), |
230 | | - UNIQUE INDEX name_title (page_namespace,page_title), |
231 | | - |
232 | | - -- Special-purpose indexes |
233 | | - INDEX (page_random), |
234 | | - INDEX (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); |
235 | 236 | |
236 | | -) /*$wgDBTableOptions*/; |
237 | 237 | |
238 | 238 | -- |
239 | 239 | -- Every edit of a page creates also a revision row. |
240 | 240 | -- This stores metadata about the revision, and a reference |
241 | 241 | -- to the text storage backend. |
242 | 242 | -- |
243 | | -CREATE TABLE /*$wgDBprefix*/revision ( |
244 | | - rev_id int unsigned NOT NULL auto_increment, |
| 243 | +CREATE TABLE /*_*/revision ( |
| 244 | + rev_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
245 | 245 | |
246 | 246 | -- Key to page_id. This should _never_ be invalid. |
247 | 247 | rev_page int unsigned NOT NULL, |
— | — | @@ -258,7 +258,7 @@ |
259 | 259 | |
260 | 260 | -- Key to user.user_id of the user who made this edit. |
261 | 261 | -- Stores 0 for anonymous edits and for some mass imports. |
262 | | - rev_user int unsigned NOT NULL default '0', |
| 262 | + rev_user int unsigned NOT NULL default 0, |
263 | 263 | |
264 | 264 | -- Text username or IP address of the editor. |
265 | 265 | rev_user_text varchar(255) binary NOT NULL default '', |
— | — | @@ -268,28 +268,27 @@ |
269 | 269 | |
270 | 270 | -- Records whether the user marked the 'minor edit' checkbox. |
271 | 271 | -- Many automated edits are marked as minor. |
272 | | - rev_minor_edit tinyint unsigned NOT NULL default '0', |
| 272 | + rev_minor_edit tinyint unsigned NOT NULL default 0, |
273 | 273 | |
274 | 274 | -- Not yet used; reserved for future changes to the deletion system. |
275 | | - rev_deleted tinyint unsigned NOT NULL default '0', |
| 275 | + rev_deleted tinyint unsigned NOT NULL default 0, |
276 | 276 | |
277 | 277 | -- Length of this revision in bytes |
278 | 278 | rev_len int unsigned, |
279 | 279 | |
280 | 280 | -- Key to revision.rev_id |
281 | 281 | -- This field is used to add support for a tree structure (The Adjacency List Model) |
282 | | - rev_parent_id int unsigned default NULL, |
| 282 | + rev_parent_id int unsigned default NULL |
283 | 283 | |
284 | | - PRIMARY KEY rev_page_id (rev_page, rev_id), |
285 | | - UNIQUE INDEX rev_id (rev_id), |
286 | | - INDEX rev_timestamp (rev_timestamp), |
287 | | - INDEX page_timestamp (rev_page,rev_timestamp), |
288 | | - INDEX user_timestamp (rev_user,rev_timestamp), |
289 | | - INDEX usertext_timestamp (rev_user_text,rev_timestamp) |
290 | | - |
291 | 284 | ) /*$wgDBTableOptions*/ MAX_ROWS=10000000 AVG_ROW_LENGTH=1024; |
292 | 285 | -- In case tables are created as MyISAM, use row hints for MySQL <5.0 to avoid 4GB limit |
293 | 286 | |
| 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); |
| 292 | + |
294 | 293 | -- |
295 | 294 | -- Holds text of individual page revisions. |
296 | 295 | -- |
— | — | @@ -298,13 +297,13 @@ |
299 | 298 | -- table into the 'text' table to minimize unnecessary churning |
300 | 299 | -- and downtime. If upgrading, the other fields will be left unused. |
301 | 300 | -- |
302 | | -CREATE TABLE /*$wgDBprefix*/text ( |
| 301 | +CREATE TABLE /*_*/text ( |
303 | 302 | -- Unique text storage key number. |
304 | 303 | -- Note that the 'oldid' parameter used in URLs does *not* |
305 | 304 | -- refer to this number anymore, but to rev_id. |
306 | 305 | -- |
307 | 306 | -- revision.rev_text_id is a key to this column |
308 | | - old_id int unsigned NOT NULL auto_increment, |
| 307 | + old_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
309 | 308 | |
310 | 309 | -- Depending on the contents of the old_flags field, the text |
311 | 310 | -- may be convenient plain text, or it may be funkily encoded. |
— | — | @@ -319,21 +318,19 @@ |
320 | 319 | -- The object either contains multiple versions compressed |
321 | 320 | -- together to achieve a better compression ratio, or it refers |
322 | 321 | -- to another row where the text can be found. |
323 | | - old_flags tinyblob NOT NULL, |
324 | | - |
325 | | - PRIMARY KEY old_id (old_id) |
326 | | - |
| 322 | + old_flags tinyblob NOT NULL |
327 | 323 | ) /*$wgDBTableOptions*/ MAX_ROWS=10000000 AVG_ROW_LENGTH=10240; |
328 | 324 | -- In case tables are created as MyISAM, use row hints for MySQL <5.0 to avoid 4GB limit |
329 | 325 | |
| 326 | + |
330 | 327 | -- |
331 | 328 | -- Holding area for deleted articles, which may be viewed |
332 | 329 | -- or restored by admins through the Special:Undelete interface. |
333 | 330 | -- The fields generally correspond to the page, revision, and text |
334 | 331 | -- fields, with several caveats. |
335 | 332 | -- |
336 | | -CREATE TABLE /*$wgDBprefix*/archive ( |
337 | | - ar_namespace int NOT NULL default '0', |
| 333 | +CREATE TABLE /*_*/archive ( |
| 334 | + ar_namespace int NOT NULL default 0, |
338 | 335 | ar_title varchar(255) binary NOT NULL default '', |
339 | 336 | |
340 | 337 | -- Newly deleted pages will not store text in this table, |
— | — | @@ -346,10 +343,10 @@ |
347 | 344 | |
348 | 345 | -- Basic revision stuff... |
349 | 346 | ar_comment tinyblob NOT NULL, |
350 | | - ar_user int unsigned NOT NULL default '0', |
| 347 | + ar_user int unsigned NOT NULL default 0, |
351 | 348 | ar_user_text varchar(255) binary NOT NULL, |
352 | 349 | ar_timestamp binary(14) NOT NULL default '', |
353 | | - ar_minor_edit tinyint NOT NULL default '0', |
| 350 | + ar_minor_edit tinyint NOT NULL default 0, |
354 | 351 | |
355 | 352 | -- See ar_text note. |
356 | 353 | ar_flags tinyblob NOT NULL, |
— | — | @@ -375,7 +372,7 @@ |
376 | 373 | ar_text_id int unsigned, |
377 | 374 | |
378 | 375 | -- rev_deleted for archives |
379 | | - ar_deleted tinyint unsigned NOT NULL default '0', |
| 376 | + ar_deleted tinyint unsigned NOT NULL default 0, |
380 | 377 | |
381 | 378 | -- Length of this revision in bytes |
382 | 379 | ar_len int unsigned, |
— | — | @@ -388,80 +385,77 @@ |
389 | 386 | ar_page_id int unsigned, |
390 | 387 | |
391 | 388 | -- Original previous revision |
392 | | - ar_parent_id int unsigned default NULL, |
393 | | - |
394 | | - KEY name_title_timestamp (ar_namespace,ar_title,ar_timestamp), |
395 | | - KEY usertext_timestamp (ar_user_text,ar_timestamp) |
396 | | - |
| 389 | + ar_parent_id int unsigned default NULL |
397 | 390 | ) /*$wgDBTableOptions*/; |
398 | 391 | |
| 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); |
399 | 394 | |
| 395 | + |
400 | 396 | -- |
401 | 397 | -- Track page-to-page hyperlinks within the wiki. |
402 | 398 | -- |
403 | | -CREATE TABLE /*$wgDBprefix*/pagelinks ( |
| 399 | +CREATE TABLE /*_*/pagelinks ( |
404 | 400 | -- Key to the page_id of the page containing the link. |
405 | | - pl_from int unsigned NOT NULL default '0', |
| 401 | + pl_from int unsigned NOT NULL default 0, |
406 | 402 | |
407 | 403 | -- Key to page_namespace/page_title of the target page. |
408 | 404 | -- The target page may or may not exist, and due to renames |
409 | 405 | -- and deletions may refer to different page records as time |
410 | 406 | -- goes by. |
411 | | - pl_namespace int NOT NULL default '0', |
412 | | - pl_title varchar(255) binary NOT NULL default '', |
413 | | - |
414 | | - UNIQUE KEY pl_from (pl_from,pl_namespace,pl_title), |
415 | | - KEY (pl_namespace,pl_title,pl_from) |
416 | | - |
| 407 | + pl_namespace int NOT NULL default 0, |
| 408 | + pl_title varchar(255) binary NOT NULL default '' |
417 | 409 | ) /*$wgDBTableOptions*/; |
418 | 410 | |
| 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); |
419 | 413 | |
| 414 | + |
420 | 415 | -- |
421 | 416 | -- Track template inclusions. |
422 | 417 | -- |
423 | | -CREATE TABLE /*$wgDBprefix*/templatelinks ( |
| 418 | +CREATE TABLE /*_*/templatelinks ( |
424 | 419 | -- Key to the page_id of the page containing the link. |
425 | | - tl_from int unsigned NOT NULL default '0', |
| 420 | + tl_from int unsigned NOT NULL default 0, |
426 | 421 | |
427 | 422 | -- Key to page_namespace/page_title of the target page. |
428 | 423 | -- The target page may or may not exist, and due to renames |
429 | 424 | -- and deletions may refer to different page records as time |
430 | 425 | -- goes by. |
431 | | - tl_namespace int NOT NULL default '0', |
432 | | - tl_title varchar(255) binary NOT NULL default '', |
433 | | - |
434 | | - UNIQUE KEY tl_from (tl_from,tl_namespace,tl_title), |
435 | | - KEY (tl_namespace,tl_title,tl_from) |
436 | | - |
| 426 | + tl_namespace int NOT NULL default 0, |
| 427 | + tl_title varchar(255) binary NOT NULL default '' |
437 | 428 | ) /*$wgDBTableOptions*/; |
438 | 429 | |
| 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); |
| 432 | + |
| 433 | + |
439 | 434 | -- |
440 | 435 | -- Track links to images *used inline* |
441 | 436 | -- We don't distinguish live from broken links here, so |
442 | 437 | -- they do not need to be changed on upload/removal. |
443 | 438 | -- |
444 | | -CREATE TABLE /*$wgDBprefix*/imagelinks ( |
| 439 | +CREATE TABLE /*_*/imagelinks ( |
445 | 440 | -- Key to page_id of the page containing the image / media link. |
446 | | - il_from int unsigned NOT NULL default '0', |
| 441 | + il_from int unsigned NOT NULL default 0, |
447 | 442 | |
448 | 443 | -- Filename of target image. |
449 | 444 | -- This is also the page_title of the file's description page; |
450 | 445 | -- all such pages are in namespace 6 (NS_FILE). |
451 | | - il_to varchar(255) binary NOT NULL default '', |
452 | | - |
453 | | - UNIQUE KEY il_from (il_from,il_to), |
454 | | - KEY (il_to,il_from) |
455 | | - |
| 446 | + il_to varchar(255) binary NOT NULL default '' |
456 | 447 | ) /*$wgDBTableOptions*/; |
457 | 448 | |
| 449 | +CREATE UNIQUE INDEX il_from ON /*_*/imagelinks (il_from,il_to); |
| 450 | +CREATE INDEX il_to ON /*_*/imagelinks (il_to,il_from); |
| 451 | + |
| 452 | + |
458 | 453 | -- |
459 | 454 | -- Track category inclusions *used inline* |
460 | 455 | -- This tracks a single level of category membership |
461 | 456 | -- |
462 | | -CREATE TABLE /*$wgDBprefix*/categorylinks ( |
| 457 | +CREATE TABLE /*_*/categorylinks ( |
463 | 458 | -- Key to page_id of the page defined as a category member. |
464 | | - cl_from int unsigned NOT NULL default '0', |
| 459 | + cl_from int unsigned NOT NULL default 0, |
465 | 460 | |
466 | 461 | -- Name of the category. |
467 | 462 | -- This is also the page_title of the category's description page; |
— | — | @@ -480,26 +474,26 @@ |
481 | 475 | |
482 | 476 | -- This isn't really used at present. Provided for an optional |
483 | 477 | -- sorting method by approximate addition time. |
484 | | - cl_timestamp timestamp NOT NULL, |
485 | | - |
486 | | - UNIQUE KEY cl_from (cl_from,cl_to), |
487 | | - |
488 | | - -- We always sort within a given category... |
489 | | - KEY cl_sortkey (cl_to,cl_sortkey,cl_from), |
490 | | - |
491 | | - -- Not really used? |
492 | | - KEY cl_timestamp (cl_to,cl_timestamp) |
493 | | - |
| 478 | + cl_timestamp timestamp NOT NULL |
494 | 479 | ) /*$wgDBTableOptions*/; |
495 | 480 | |
| 481 | +CREATE UNIQUE INDEX cl_from ON /*_*/categorylinks (cl_from,cl_to); |
| 482 | + |
| 483 | +-- We always sort within a given category... |
| 484 | +CREATE INDEX cl_sortkey ON /*_*/categorylinks (cl_to,cl_sortkey,cl_from); |
| 485 | + |
| 486 | +-- Not really used? |
| 487 | +CREATE INDEX cl_timestamp ON /*_*/categorylinks (cl_to,cl_timestamp); |
| 488 | + |
| 489 | + |
496 | 490 | -- |
497 | 491 | -- Track all existing categories. Something is a category if 1) it has an en- |
498 | 492 | -- try somewhere in categorylinks, or 2) it once did. Categories might not |
499 | 493 | -- have corresponding pages, so they need to be tracked separately. |
500 | 494 | -- |
501 | | -CREATE TABLE /*$wgDBprefix*/category ( |
| 495 | +CREATE TABLE /*_*/category ( |
502 | 496 | -- Primary key |
503 | | - cat_id int unsigned NOT NULL auto_increment, |
| 497 | + cat_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
504 | 498 | |
505 | 499 | -- Name of the category, in the same form as page_title (with underscores). |
506 | 500 | -- If there is a category page corresponding to this category, by definition, |
— | — | @@ -516,21 +510,21 @@ |
517 | 511 | cat_files int signed NOT NULL default 0, |
518 | 512 | |
519 | 513 | -- Reserved for future use |
520 | | - cat_hidden tinyint unsigned NOT NULL default 0, |
521 | | - |
522 | | - PRIMARY KEY (cat_id), |
523 | | - UNIQUE KEY (cat_title), |
524 | | - |
525 | | - -- For Special:Mostlinkedcategories |
526 | | - KEY (cat_pages) |
| 514 | + cat_hidden tinyint unsigned NOT NULL default 0 |
527 | 515 | ) /*$wgDBTableOptions*/; |
528 | 516 | |
| 517 | +CREATE UNIQUE INDEX cat_title ON /*_*/category (cat_title); |
| 518 | + |
| 519 | +-- For Special:Mostlinkedcategories |
| 520 | +CREATE INDEX cat_pages ON /*_*/category (cat_pages); |
| 521 | + |
| 522 | + |
529 | 523 | -- |
530 | 524 | -- Track links to external URLs |
531 | 525 | -- |
532 | | -CREATE TABLE /*$wgDBprefix*/externallinks ( |
| 526 | +CREATE TABLE /*_*/externallinks ( |
533 | 527 | -- page_id of the referring page |
534 | | - el_from int unsigned NOT NULL default '0', |
| 528 | + el_from int unsigned NOT NULL default 0, |
535 | 529 | |
536 | 530 | -- The URL |
537 | 531 | el_to blob NOT NULL, |
— | — | @@ -546,50 +540,52 @@ |
547 | 541 | -- which allows for fast searching for all pages under example.com with the |
548 | 542 | -- clause: |
549 | 543 | -- WHERE el_index LIKE 'http://com.example.%' |
550 | | - el_index blob NOT NULL, |
551 | | - |
552 | | - KEY (el_from, el_to(40)), |
553 | | - KEY (el_to(60), el_from), |
554 | | - KEY (el_index(60)) |
| 544 | + el_index blob NOT NULL |
555 | 545 | ) /*$wgDBTableOptions*/; |
556 | 546 | |
| 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)); |
| 550 | + |
| 551 | + |
557 | 552 | -- |
558 | 553 | -- Track interlanguage links |
559 | 554 | -- |
560 | | -CREATE TABLE /*$wgDBprefix*/langlinks ( |
| 555 | +CREATE TABLE /*_*/langlinks ( |
561 | 556 | -- page_id of the referring page |
562 | | - ll_from int unsigned NOT NULL default '0', |
| 557 | + ll_from int unsigned NOT NULL default 0, |
563 | 558 | |
564 | 559 | -- Language code of the target |
565 | 560 | ll_lang varbinary(20) NOT NULL default '', |
566 | 561 | |
567 | 562 | -- Title of the target, including namespace |
568 | | - ll_title varchar(255) binary NOT NULL default '', |
569 | | - |
570 | | - UNIQUE KEY (ll_from, ll_lang), |
571 | | - KEY (ll_lang, ll_title) |
| 563 | + ll_title varchar(255) binary NOT NULL default '' |
572 | 564 | ) /*$wgDBTableOptions*/; |
573 | 565 | |
| 566 | +CREATE UNIQUE INDEX ll_from ON /*_*/langlinks (ll_from, ll_lang); |
| 567 | +CREATE INDEX ll_lang_title ON /*_*/langlinks (ll_lang, ll_title); |
| 568 | + |
| 569 | + |
574 | 570 | -- |
575 | 571 | -- Contains a single row with some aggregate info |
576 | 572 | -- on the state of the site. |
577 | 573 | -- |
578 | | -CREATE TABLE /*$wgDBprefix*/site_stats ( |
| 574 | +CREATE TABLE /*_*/site_stats ( |
579 | 575 | -- The single row should contain 1 here. |
580 | 576 | ss_row_id int unsigned NOT NULL, |
581 | 577 | |
582 | 578 | -- Total number of page views, if hit counters are enabled. |
583 | | - ss_total_views bigint unsigned default '0', |
| 579 | + ss_total_views bigint unsigned default 0, |
584 | 580 | |
585 | 581 | -- Total number of edits performed. |
586 | | - ss_total_edits bigint unsigned default '0', |
| 582 | + ss_total_edits bigint unsigned default 0, |
587 | 583 | |
588 | 584 | -- An approximate count of pages matching the following criteria: |
589 | 585 | -- * in namespace 0 |
590 | 586 | -- * not a redirect |
591 | 587 | -- * contains the text '[[' |
592 | 588 | -- See Article::isCountable() in includes/Article.php |
593 | | - ss_good_articles bigint unsigned default '0', |
| 589 | + ss_good_articles bigint unsigned default 0, |
594 | 590 | |
595 | 591 | -- Total pages, theoretically equal to SELECT COUNT(*) FROM page; except faster |
596 | 592 | ss_total_pages bigint default '-1', |
— | — | @@ -604,11 +600,12 @@ |
605 | 601 | ss_admins int default '-1', |
606 | 602 | |
607 | 603 | -- Number of images, equivalent to SELECT COUNT(*) FROM image |
608 | | - ss_images int default '0', |
| 604 | + ss_images int default 0 |
| 605 | +) /*$wgDBTableOptions*/; |
609 | 606 | |
610 | | - UNIQUE KEY ss_row_id (ss_row_id) |
| 607 | +-- Pointless index to assuage developer superstitions |
| 608 | +CREATE UNIQUE INDEX ss_row_id ON /*_*/site_stats (ss_row_id); |
611 | 609 | |
612 | | -) /*$wgDBTableOptions*/; |
613 | 610 | |
614 | 611 | -- |
615 | 612 | -- Stores an ID for every time any article is visited; |
— | — | @@ -617,7 +614,7 @@ |
618 | 615 | -- in the page table updated for the all articles |
619 | 616 | -- that have been visited.) |
620 | 617 | -- |
621 | | -CREATE TABLE /*$wgDBprefix*/hitcounter ( |
| 618 | +CREATE TABLE /*_*/hitcounter ( |
622 | 619 | hc_id int unsigned NOT NULL |
623 | 620 | ) ENGINE=HEAP MAX_ROWS=25000; |
624 | 621 | |
— | — | @@ -626,18 +623,18 @@ |
627 | 624 | -- The internet is full of jerks, alas. Sometimes it's handy |
628 | 625 | -- to block a vandal or troll account. |
629 | 626 | -- |
630 | | -CREATE TABLE /*$wgDBprefix*/ipblocks ( |
| 627 | +CREATE TABLE /*_*/ipblocks ( |
631 | 628 | -- Primary key, introduced for privacy. |
632 | | - ipb_id int NOT NULL auto_increment, |
| 629 | + ipb_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, |
633 | 630 | |
634 | 631 | -- Blocked IP address in dotted-quad form or user name. |
635 | 632 | ipb_address tinyblob NOT NULL, |
636 | 633 | |
637 | 634 | -- Blocked user ID or 0 for IP blocks. |
638 | | - ipb_user int unsigned NOT NULL default '0', |
| 635 | + ipb_user int unsigned NOT NULL default 0, |
639 | 636 | |
640 | 637 | -- User ID who made the block. |
641 | | - ipb_by int unsigned NOT NULL default '0', |
| 638 | + ipb_by int unsigned NOT NULL default 0, |
642 | 639 | |
643 | 640 | -- User name of blocker |
644 | 641 | ipb_by_text varchar(255) binary NOT NULL default '', |
— | — | @@ -679,43 +676,41 @@ |
680 | 677 | ipb_block_email bool NOT NULL default 0, |
681 | 678 | |
682 | 679 | -- Block allows user to edit their own talk page |
683 | | - ipb_allow_usertalk bool NOT NULL default 0, |
684 | | - |
685 | | - PRIMARY KEY ipb_id (ipb_id), |
| 680 | + ipb_allow_usertalk bool NOT NULL default 0 |
686 | 681 | |
687 | | - -- Unique index to support "user already blocked" messages |
688 | | - -- Any new options which prevent collisions should be included |
689 | | - UNIQUE INDEX ipb_address (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only), |
690 | | - |
691 | | - INDEX ipb_user (ipb_user), |
692 | | - INDEX ipb_range (ipb_range_start(8), ipb_range_end(8)), |
693 | | - INDEX ipb_timestamp (ipb_timestamp), |
694 | | - INDEX ipb_expiry (ipb_expiry) |
695 | | - |
696 | 682 | ) /*$wgDBTableOptions*/; |
| 683 | + |
| 684 | +-- Unique index to support "user already blocked" messages |
| 685 | +-- 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); |
697 | 687 | |
| 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); |
698 | 692 | |
| 693 | + |
699 | 694 | -- |
700 | 695 | -- Uploaded images and other files. |
701 | 696 | -- |
702 | | -CREATE TABLE /*$wgDBprefix*/image ( |
| 697 | +CREATE TABLE /*_*/image ( |
703 | 698 | -- Filename. |
704 | 699 | -- This is also the title of the associated description page, |
705 | 700 | -- which will be in namespace 6 (NS_FILE). |
706 | | - img_name varchar(255) binary NOT NULL default '', |
| 701 | + img_name varchar(255) binary NOT NULL default '' primary key, |
707 | 702 | |
708 | 703 | -- File size in bytes. |
709 | | - img_size int unsigned NOT NULL default '0', |
| 704 | + img_size int unsigned NOT NULL default 0, |
710 | 705 | |
711 | 706 | -- For images, size in pixels. |
712 | | - img_width int NOT NULL default '0', |
713 | | - img_height int NOT NULL default '0', |
| 707 | + img_width int NOT NULL default 0, |
| 708 | + img_height int NOT NULL default 0, |
714 | 709 | |
715 | 710 | -- Extracted EXIF metadata stored as a serialized PHP array. |
716 | 711 | img_metadata mediumblob NOT NULL, |
717 | 712 | |
718 | 713 | -- For images, bits per pixel if known. |
719 | | - img_bits int NOT NULL default '0', |
| 714 | + img_bits int NOT NULL default 0, |
720 | 715 | |
721 | 716 | -- Media type as defined by the MEDIATYPE_xxx constants |
722 | 717 | img_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL, |
— | — | @@ -735,34 +730,31 @@ |
736 | 731 | img_description tinyblob NOT NULL, |
737 | 732 | |
738 | 733 | -- user_id and user_name of uploader. |
739 | | - img_user int unsigned NOT NULL default '0', |
| 734 | + img_user int unsigned NOT NULL default 0, |
740 | 735 | img_user_text varchar(255) binary NOT NULL, |
741 | 736 | |
742 | 737 | -- Time of the upload. |
743 | 738 | img_timestamp varbinary(14) NOT NULL default '', |
744 | 739 | |
745 | 740 | -- SHA-1 content hash in base-36 |
746 | | - img_sha1 varbinary(32) NOT NULL default '', |
| 741 | + img_sha1 varbinary(32) NOT NULL default '' |
| 742 | +) /*$wgDBTableOptions*/; |
747 | 743 | |
748 | | - PRIMARY KEY img_name (img_name), |
749 | | - |
750 | | - INDEX img_usertext_timestamp (img_user_text,img_timestamp), |
751 | | - -- Used by Special:Imagelist for sort-by-size |
752 | | - INDEX img_size (img_size), |
753 | | - -- Used by Special:Newimages and Special:Imagelist |
754 | | - INDEX img_timestamp (img_timestamp), |
755 | | - -- Used in API and duplicate search |
756 | | - INDEX img_sha1 (img_sha1) |
| 744 | +CREATE INDEX img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp); |
| 745 | +-- Used by Special:Imagelist for sort-by-size |
| 746 | +CREATE INDEX img_size ON /*_*/image (img_size); |
| 747 | +-- Used by Special:Newimages and Special:Imagelist |
| 748 | +CREATE INDEX img_timestamp ON /*_*/image (img_timestamp); |
| 749 | +-- Used in API and duplicate search |
| 750 | +CREATE INDEX img_sha1 ON /*_*/image (img_sha1); |
757 | 751 | |
758 | 752 | |
759 | | -) /*$wgDBTableOptions*/; |
760 | | - |
761 | 753 | -- |
762 | 754 | -- Previous revisions of uploaded files. |
763 | 755 | -- Awkwardly, image rows have to be moved into |
764 | 756 | -- this table at re-upload time. |
765 | 757 | -- |
766 | | -CREATE TABLE /*$wgDBprefix*/oldimage ( |
| 758 | +CREATE TABLE /*_*/oldimage ( |
767 | 759 | -- Base filename: key to image.img_name |
768 | 760 | oi_name varchar(255) binary NOT NULL default '', |
769 | 761 | |
— | — | @@ -776,7 +768,7 @@ |
777 | 769 | oi_height int NOT NULL default 0, |
778 | 770 | oi_bits int NOT NULL default 0, |
779 | 771 | oi_description tinyblob NOT NULL, |
780 | | - oi_user int unsigned NOT NULL default '0', |
| 772 | + oi_user int unsigned NOT NULL default 0, |
781 | 773 | oi_user_text varchar(255) binary NOT NULL, |
782 | 774 | oi_timestamp binary(14) NOT NULL default '', |
783 | 775 | |
— | — | @@ -784,23 +776,23 @@ |
785 | 777 | oi_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL, |
786 | 778 | oi_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") NOT NULL default "unknown", |
787 | 779 | oi_minor_mime varbinary(32) NOT NULL default "unknown", |
788 | | - oi_deleted tinyint unsigned NOT NULL default '0', |
789 | | - oi_sha1 varbinary(32) NOT NULL default '', |
790 | | - |
791 | | - INDEX oi_usertext_timestamp (oi_user_text,oi_timestamp), |
792 | | - INDEX oi_name_timestamp (oi_name,oi_timestamp), |
793 | | - -- oi_archive_name truncated to 14 to avoid key length overflow |
794 | | - INDEX oi_name_archive_name (oi_name,oi_archive_name(14)), |
795 | | - INDEX oi_sha1 (oi_sha1) |
796 | | - |
| 780 | + oi_deleted tinyint unsigned NOT NULL default 0, |
| 781 | + oi_sha1 varbinary(32) NOT NULL default '' |
797 | 782 | ) /*$wgDBTableOptions*/; |
798 | 783 | |
| 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); |
| 786 | +-- 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); |
| 789 | + |
| 790 | + |
799 | 791 | -- |
800 | 792 | -- Record of deleted file data |
801 | 793 | -- |
802 | | -CREATE TABLE /*$wgDBprefix*/filearchive ( |
| 794 | +CREATE TABLE /*_*/filearchive ( |
803 | 795 | -- Unique row id |
804 | | - fa_id int NOT NULL auto_increment, |
| 796 | + fa_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, |
805 | 797 | |
806 | 798 | -- Original base filename; key to image.img_name, page.page_title, etc |
807 | 799 | fa_name varchar(255) binary NOT NULL default '', |
— | — | @@ -826,80 +818,83 @@ |
827 | 819 | fa_deleted_reason text, |
828 | 820 | |
829 | 821 | -- Duped fields from image |
830 | | - fa_size int unsigned default '0', |
831 | | - fa_width int default '0', |
832 | | - fa_height int default '0', |
| 822 | + fa_size int unsigned default 0, |
| 823 | + fa_width int default 0, |
| 824 | + fa_height int default 0, |
833 | 825 | fa_metadata mediumblob, |
834 | | - fa_bits int default '0', |
| 826 | + fa_bits int default 0, |
835 | 827 | fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL, |
836 | 828 | fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") default "unknown", |
837 | 829 | fa_minor_mime varbinary(32) default "unknown", |
838 | 830 | fa_description tinyblob, |
839 | | - fa_user int unsigned default '0', |
| 831 | + fa_user int unsigned default 0, |
840 | 832 | fa_user_text varchar(255) binary, |
841 | 833 | fa_timestamp binary(14) default '', |
842 | 834 | |
843 | 835 | -- Visibility of deleted revisions, bitfield |
844 | | - fa_deleted tinyint unsigned NOT NULL default '0', |
845 | | - |
846 | | - PRIMARY KEY (fa_id), |
847 | | - INDEX (fa_name, fa_timestamp), -- pick out by image name |
848 | | - INDEX (fa_storage_group, fa_storage_key), -- pick out dupe files |
849 | | - INDEX (fa_deleted_timestamp), -- sort by deletion time |
850 | | - INDEX fa_user_timestamp (fa_user_text,fa_timestamp) -- sort by uploader |
851 | | - |
| 836 | + fa_deleted tinyint unsigned NOT NULL default 0 |
852 | 837 | ) /*$wgDBTableOptions*/; |
853 | 838 | |
| 839 | +-- pick out by image name |
| 840 | +CREATE INDEX fa_name ON /*_*/filearchive (fa_name, fa_timestamp); |
| 841 | +-- pick out dupe files |
| 842 | +CREATE INDEX fa_group_key ON /*_*/filearchive (fa_storage_group, fa_storage_key); |
| 843 | +-- sort by deletion time |
| 844 | +CREATE INDEX fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp); |
| 845 | +-- sort by uploader |
| 846 | +CREATE INDEX fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp); |
| 847 | + |
| 848 | + |
854 | 849 | -- |
855 | 850 | -- Primarily a summary table for Special:Recentchanges, |
856 | 851 | -- this table contains some additional info on edits from |
857 | 852 | -- the last few days, see Article::editUpdates() |
858 | 853 | -- |
859 | | -CREATE TABLE /*$wgDBprefix*/recentchanges ( |
860 | | - rc_id int NOT NULL auto_increment, |
| 854 | +CREATE TABLE /*_*/recentchanges ( |
| 855 | + rc_id int NOT NULL PRIMARY KEY AUTO_INCREMENT, |
861 | 856 | rc_timestamp varbinary(14) NOT NULL default '', |
862 | 857 | rc_cur_time varbinary(14) NOT NULL default '', |
863 | 858 | |
864 | 859 | -- As in revision |
865 | | - rc_user int unsigned NOT NULL default '0', |
| 860 | + rc_user int unsigned NOT NULL default 0, |
866 | 861 | rc_user_text varchar(255) binary NOT NULL, |
867 | 862 | |
868 | 863 | -- When pages are renamed, their RC entries do _not_ change. |
869 | | - rc_namespace int NOT NULL default '0', |
| 864 | + rc_namespace int NOT NULL default 0, |
870 | 865 | rc_title varchar(255) binary NOT NULL default '', |
871 | 866 | |
872 | 867 | -- as in revision... |
873 | 868 | rc_comment varchar(255) binary NOT NULL default '', |
874 | | - rc_minor tinyint unsigned NOT NULL default '0', |
| 869 | + rc_minor tinyint unsigned NOT NULL default 0, |
875 | 870 | |
876 | 871 | -- Edits by user accounts with the 'bot' rights key are |
877 | 872 | -- marked with a 1 here, and will be hidden from the |
878 | 873 | -- default view. |
879 | | - rc_bot tinyint unsigned NOT NULL default '0', |
| 874 | + rc_bot tinyint unsigned NOT NULL default 0, |
880 | 875 | |
881 | | - rc_new tinyint unsigned NOT NULL default '0', |
| 876 | + rc_new tinyint unsigned NOT NULL default 0, |
882 | 877 | |
883 | 878 | -- Key to page_id (was cur_id prior to 1.5). |
884 | 879 | -- This will keep links working after moves while |
885 | 880 | -- retaining the at-the-time name in the changes list. |
886 | | - rc_cur_id int unsigned NOT NULL default '0', |
| 881 | + rc_cur_id int unsigned NOT NULL default 0, |
887 | 882 | |
888 | 883 | -- rev_id of the given revision |
889 | | - rc_this_oldid int unsigned NOT NULL default '0', |
| 884 | + rc_this_oldid int unsigned NOT NULL default 0, |
890 | 885 | |
891 | 886 | -- rev_id of the prior revision, for generating diff links. |
892 | | - rc_last_oldid int unsigned NOT NULL default '0', |
| 887 | + rc_last_oldid int unsigned NOT NULL default 0, |
893 | 888 | |
894 | 889 | -- These may no longer be used, with the new move log. |
895 | | - rc_type tinyint unsigned NOT NULL default '0', |
896 | | - rc_moved_to_ns tinyint unsigned NOT NULL default '0', |
| 890 | + rc_type tinyint unsigned NOT NULL default 0, |
| 891 | + rc_moved_to_ns tinyint unsigned NOT NULL default 0, |
897 | 892 | rc_moved_to_title varchar(255) binary NOT NULL default '', |
898 | 893 | |
899 | 894 | -- If the Recent Changes Patrol option is enabled, |
900 | 895 | -- users may mark edits as having been reviewed to |
901 | 896 | -- remove a warning flag on the RC list. |
902 | 897 | -- A value of 1 indicates the page has been reviewed. |
903 | | - rc_patrolled tinyint unsigned NOT NULL default '0', |
| 898 | + rc_patrolled tinyint unsigned NOT NULL default 0, |
904 | 899 | |
905 | 900 | -- Recorded IP address the edit was made from, if the |
906 | 901 | -- $wgPutIPinRC option is enabled. |
— | — | @@ -911,53 +906,52 @@ |
912 | 907 | rc_new_len int, |
913 | 908 | |
914 | 909 | -- Visibility of recent changes items, bitfield |
915 | | - rc_deleted tinyint unsigned NOT NULL default '0', |
| 910 | + rc_deleted tinyint unsigned NOT NULL default 0, |
916 | 911 | |
917 | 912 | -- Value corresonding to log_id, specific log entries |
918 | | - rc_logid int unsigned NOT NULL default '0', |
| 913 | + rc_logid int unsigned NOT NULL default 0, |
919 | 914 | -- Store log type info here, or null |
920 | 915 | rc_log_type varbinary(255) NULL default NULL, |
921 | 916 | -- Store log action or null |
922 | 917 | rc_log_action varbinary(255) NULL default NULL, |
923 | 918 | -- Log params |
924 | | - rc_params blob NULL, |
925 | | - |
926 | | - PRIMARY KEY rc_id (rc_id), |
927 | | - INDEX rc_timestamp (rc_timestamp), |
928 | | - INDEX rc_namespace_title (rc_namespace, rc_title), |
929 | | - INDEX rc_cur_id (rc_cur_id), |
930 | | - INDEX new_name_timestamp (rc_new,rc_namespace,rc_timestamp), |
931 | | - INDEX rc_ip (rc_ip), |
932 | | - INDEX rc_ns_usertext (rc_namespace, rc_user_text), |
933 | | - INDEX rc_user_text (rc_user_text, rc_timestamp) |
934 | | - |
| 919 | + rc_params blob NULL |
935 | 920 | ) /*$wgDBTableOptions*/; |
936 | 921 | |
937 | | -CREATE TABLE /*$wgDBprefix*/watchlist ( |
| 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); |
| 929 | + |
| 930 | + |
| 931 | +CREATE TABLE /*_*/watchlist ( |
938 | 932 | -- Key to user.user_id |
939 | 933 | wl_user int unsigned NOT NULL, |
940 | 934 | |
941 | 935 | -- Key to page_namespace/page_title |
942 | 936 | -- Note that users may watch pages which do not exist yet, |
943 | 937 | -- or existed in the past but have been deleted. |
944 | | - wl_namespace int NOT NULL default '0', |
| 938 | + wl_namespace int NOT NULL default 0, |
945 | 939 | wl_title varchar(255) binary NOT NULL default '', |
946 | 940 | |
947 | 941 | -- Timestamp when user was last sent a notification e-mail; |
948 | 942 | -- cleared when the user visits the page. |
949 | | - wl_notificationtimestamp varbinary(14), |
| 943 | + wl_notificationtimestamp varbinary(14) |
950 | 944 | |
951 | | - UNIQUE KEY (wl_user, wl_namespace, wl_title), |
952 | | - KEY namespace_title (wl_namespace, wl_title) |
953 | | - |
954 | 945 | ) /*$wgDBTableOptions*/; |
955 | 946 | |
| 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); |
956 | 949 | |
| 950 | + |
957 | 951 | -- |
958 | 952 | -- Used by the math module to keep track |
959 | 953 | -- of previously-rendered items. |
960 | 954 | -- |
961 | | -CREATE TABLE /*$wgDBprefix*/math ( |
| 955 | +CREATE TABLE /*_*/math ( |
962 | 956 | -- Binary MD5 hash of the latex fragment, used as an identifier key. |
963 | 957 | math_inputhash varbinary(16) NOT NULL, |
964 | 958 | |
— | — | @@ -972,12 +966,12 @@ |
973 | 967 | math_html text, |
974 | 968 | |
975 | 969 | -- MathML output from texvc, if any |
976 | | - math_mathml text, |
977 | | - |
978 | | - UNIQUE KEY math_inputhash (math_inputhash) |
979 | | - |
| 970 | + math_mathml text |
980 | 971 | ) /*$wgDBTableOptions*/; |
981 | 972 | |
| 973 | +CREATE UNIQUE INDEX math_inputhash ON /*_*/math (math_inputhash); |
| 974 | + |
| 975 | + |
982 | 976 | -- |
983 | 977 | -- When using the default MySQL search backend, page titles |
984 | 978 | -- and text are munged to strip markup, do Unicode case folding, |
— | — | @@ -986,7 +980,7 @@ |
987 | 981 | -- This table must be MyISAM; InnoDB does not support the needed |
988 | 982 | -- fulltext index. |
989 | 983 | -- |
990 | | -CREATE TABLE /*$wgDBprefix*/searchindex ( |
| 984 | +CREATE TABLE /*_*/searchindex ( |
991 | 985 | -- Key to page_id |
992 | 986 | si_page int unsigned NOT NULL, |
993 | 987 | |
— | — | @@ -994,18 +988,18 @@ |
995 | 989 | si_title varchar(255) NOT NULL default '', |
996 | 990 | |
997 | 991 | -- Munged version of body text |
998 | | - si_text mediumtext NOT NULL, |
999 | | - |
1000 | | - UNIQUE KEY (si_page), |
1001 | | - FULLTEXT si_title (si_title), |
1002 | | - FULLTEXT si_text (si_text) |
1003 | | - |
| 992 | + si_text mediumtext NOT NULL |
1004 | 993 | ) ENGINE=MyISAM; |
1005 | 994 | |
| 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); |
| 998 | + |
| 999 | + |
1006 | 1000 | -- |
1007 | 1001 | -- Recognized interwiki link prefixes |
1008 | 1002 | -- |
1009 | | -CREATE TABLE /*$wgDBprefix*/interwiki ( |
| 1003 | +CREATE TABLE /*_*/interwiki ( |
1010 | 1004 | -- The interwiki prefix, (e.g. "Meatball", or the language prefix "de") |
1011 | 1005 | iw_prefix varchar(32) NOT NULL, |
1012 | 1006 | |
— | — | @@ -1019,55 +1013,56 @@ |
1020 | 1014 | iw_local bool NOT NULL, |
1021 | 1015 | |
1022 | 1016 | -- Boolean value indicating whether interwiki transclusions are allowed. |
1023 | | - iw_trans tinyint NOT NULL default 0, |
1024 | | - |
1025 | | - UNIQUE KEY iw_prefix (iw_prefix) |
1026 | | - |
| 1017 | + iw_trans tinyint NOT NULL default 0 |
1027 | 1018 | ) /*$wgDBTableOptions*/; |
1028 | 1019 | |
| 1020 | +CREATE UNIQUE INDEX iw_prefix ON /*_*/interwiki (iw_prefix); |
| 1021 | + |
| 1022 | + |
1029 | 1023 | -- |
1030 | 1024 | -- Used for caching expensive grouped queries |
1031 | 1025 | -- |
1032 | | -CREATE TABLE /*$wgDBprefix*/querycache ( |
| 1026 | +CREATE TABLE /*_*/querycache ( |
1033 | 1027 | -- A key name, generally the base name of of the special page. |
1034 | 1028 | qc_type varbinary(32) NOT NULL, |
1035 | 1029 | |
1036 | 1030 | -- Some sort of stored value. Sizes, counts... |
1037 | | - qc_value int unsigned NOT NULL default '0', |
| 1031 | + qc_value int unsigned NOT NULL default 0, |
1038 | 1032 | |
1039 | 1033 | -- Target namespace+title |
1040 | | - qc_namespace int NOT NULL default '0', |
1041 | | - qc_title varchar(255) binary NOT NULL default '', |
1042 | | - |
1043 | | - KEY (qc_type,qc_value) |
1044 | | - |
| 1034 | + qc_namespace int NOT NULL default 0, |
| 1035 | + qc_title varchar(255) binary NOT NULL default '' |
1045 | 1036 | ) /*$wgDBTableOptions*/; |
1046 | 1037 | |
| 1038 | +CREATE INDEX qc_type_value ON /*_*/querycache (qc_type,qc_value); |
| 1039 | + |
| 1040 | + |
1047 | 1041 | -- |
1048 | 1042 | -- For a few generic cache operations if not using Memcached |
1049 | 1043 | -- |
1050 | | -CREATE TABLE /*$wgDBprefix*/objectcache ( |
1051 | | - keyname varbinary(255) NOT NULL default '', |
| 1044 | +CREATE TABLE /*_*/objectcache ( |
| 1045 | + keyname varbinary(255) NOT NULL default '' primary key, |
1052 | 1046 | value mediumblob, |
1053 | | - exptime datetime, |
1054 | | - PRIMARY KEY (keyname), |
1055 | | - KEY (exptime) |
1056 | | - |
| 1047 | + exptime datetime |
1057 | 1048 | ) /*$wgDBTableOptions*/; |
| 1049 | +CREATE INDEX oc_exptime ON /*_*/objectcache (exptime); |
1058 | 1050 | |
| 1051 | + |
1059 | 1052 | -- |
1060 | 1053 | -- Cache of interwiki transclusion |
1061 | 1054 | -- |
1062 | | -CREATE TABLE /*$wgDBprefix*/transcache ( |
| 1055 | +CREATE TABLE /*_*/transcache ( |
1063 | 1056 | tc_url varbinary(255) NOT NULL, |
1064 | 1057 | tc_contents text, |
1065 | | - tc_time int NOT NULL, |
1066 | | - UNIQUE INDEX tc_url_idx (tc_url) |
| 1058 | + tc_time int NOT NULL |
1067 | 1059 | ) /*$wgDBTableOptions*/; |
1068 | 1060 | |
1069 | | -CREATE TABLE /*$wgDBprefix*/logging ( |
| 1061 | +CREATE UNIQUE INDEX tc_url_idx ON /*_*/transcache (tc_url); |
| 1062 | + |
| 1063 | + |
| 1064 | +CREATE TABLE /*_*/logging ( |
1070 | 1065 | -- Log ID, for referring to this specific log entry, probably for deletion and such. |
1071 | | - log_id int unsigned NOT NULL auto_increment, |
| 1066 | + log_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
1072 | 1067 | |
1073 | 1068 | -- Symbolic keys for the general log type and the action type |
1074 | 1069 | -- within the log. The output format will be controlled by the |
— | — | @@ -1093,32 +1088,29 @@ |
1094 | 1089 | log_params blob NOT NULL, |
1095 | 1090 | |
1096 | 1091 | -- rev_deleted for logs |
1097 | | - log_deleted tinyint unsigned NOT NULL default '0', |
| 1092 | + log_deleted tinyint unsigned NOT NULL default 0 |
| 1093 | +) /*$wgDBTableOptions*/; |
1098 | 1094 | |
1099 | | - PRIMARY KEY log_id (log_id), |
1100 | | - KEY type_time (log_type, log_timestamp), |
1101 | | - KEY user_time (log_user, log_timestamp), |
1102 | | - KEY page_time (log_namespace, log_title, log_timestamp), |
1103 | | - KEY times (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); |
1104 | 1099 | |
1105 | | -) /*$wgDBTableOptions*/; |
1106 | 1100 | |
1107 | | -CREATE TABLE /*$wgDBprefix*/trackbacks ( |
1108 | | - tb_id int auto_increment, |
1109 | | - tb_page int REFERENCES /*$wgDBprefix*/page(page_id) ON DELETE CASCADE, |
| 1101 | +CREATE TABLE /*_*/trackbacks ( |
| 1102 | + tb_id int PRIMARY KEY AUTO_INCREMENT, |
| 1103 | + tb_page int REFERENCES /*_*/page(page_id) ON DELETE CASCADE, |
1110 | 1104 | tb_title varchar(255) NOT NULL, |
1111 | 1105 | tb_url blob NOT NULL, |
1112 | 1106 | tb_ex text, |
1113 | | - tb_name varchar(255), |
1114 | | - |
1115 | | - PRIMARY KEY (tb_id), |
1116 | | - INDEX (tb_page) |
| 1107 | + tb_name varchar(255) |
1117 | 1108 | ) /*$wgDBTableOptions*/; |
| 1109 | +CREATE INDEX tb_page ON /*_*/trackbacks (tb_page); |
1118 | 1110 | |
1119 | 1111 | |
1120 | 1112 | -- Jobs performed by parallel apache threads or a command-line daemon |
1121 | | -CREATE TABLE /*$wgDBprefix*/job ( |
1122 | | - job_id int unsigned NOT NULL auto_increment, |
| 1113 | +CREATE TABLE /*_*/job ( |
| 1114 | + job_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, |
1123 | 1115 | |
1124 | 1116 | -- Command name |
1125 | 1117 | -- Limited to 60 to prevent key length overflow |
— | — | @@ -1130,68 +1122,66 @@ |
1131 | 1123 | job_title varchar(255) binary NOT NULL, |
1132 | 1124 | |
1133 | 1125 | -- Any other parameters to the command |
1134 | | - -- Presently unused, format undefined |
1135 | | - job_params blob NOT NULL, |
1136 | | - |
1137 | | - PRIMARY KEY job_id (job_id), |
1138 | | - KEY (job_cmd, job_namespace, job_title) |
| 1126 | + -- Stored as a PHP serialized array, or an empty string if there are no parameters |
| 1127 | + job_params blob NOT NULL |
1139 | 1128 | ) /*$wgDBTableOptions*/; |
1140 | 1129 | |
| 1130 | +CREATE INDEX job_cmd_namespace_title ON /*_*/job (job_cmd, job_namespace, job_title); |
1141 | 1131 | |
1142 | | -CREATE TABLE /*$wgDBprefix*/querycache_info ( |
1143 | 1132 | |
| 1133 | +-- Details of updates to cached special pages |
| 1134 | +CREATE TABLE /*_*/querycache_info ( |
1144 | 1135 | -- Special page name |
1145 | 1136 | -- Corresponds to a qc_type value |
1146 | 1137 | qci_type varbinary(32) NOT NULL default '', |
1147 | 1138 | |
1148 | 1139 | -- Timestamp of last update |
1149 | | - qci_timestamp binary(14) NOT NULL default '19700101000000', |
| 1140 | + qci_timestamp binary(14) NOT NULL default '19700101000000' |
| 1141 | +) /*$wgDBTableOptions*/; |
1150 | 1142 | |
1151 | | - UNIQUE KEY ( qci_type ) |
| 1143 | +CREATE UNIQUE INDEX qci_type ON /*_*/querycache_info (qci_type); |
1152 | 1144 | |
1153 | | -) /*$wgDBTableOptions*/; |
1154 | 1145 | |
1155 | 1146 | -- For each redirect, this table contains exactly one row defining its target |
1156 | | -CREATE TABLE /*$wgDBprefix*/redirect ( |
| 1147 | +CREATE TABLE /*_*/redirect ( |
1157 | 1148 | -- Key to the page_id of the redirect page |
1158 | | - rd_from int unsigned NOT NULL default '0', |
| 1149 | + rd_from int unsigned NOT NULL default 0 primary key, |
1159 | 1150 | |
1160 | 1151 | -- Key to page_namespace/page_title of the target page. |
1161 | 1152 | -- The target page may or may not exist, and due to renames |
1162 | 1153 | -- and deletions may refer to different page records as time |
1163 | 1154 | -- goes by. |
1164 | | - rd_namespace int NOT NULL default '0', |
1165 | | - rd_title varchar(255) binary NOT NULL default '', |
1166 | | - |
1167 | | - PRIMARY KEY rd_from (rd_from), |
1168 | | - KEY rd_ns_title (rd_namespace,rd_title,rd_from) |
| 1155 | + rd_namespace int NOT NULL default 0, |
| 1156 | + rd_title varchar(255) binary NOT NULL default '' |
1169 | 1157 | ) /*$wgDBTableOptions*/; |
1170 | 1158 | |
| 1159 | +CREATE INDEX rd_ns_title ON /*_*/redirect (rd_namespace,rd_title,rd_from); |
| 1160 | + |
| 1161 | + |
1171 | 1162 | -- Used for caching expensive grouped queries that need two links (for example double-redirects) |
1172 | | -CREATE TABLE /*$wgDBprefix*/querycachetwo ( |
| 1163 | +CREATE TABLE /*_*/querycachetwo ( |
1173 | 1164 | -- A key name, generally the base name of of the special page. |
1174 | 1165 | qcc_type varbinary(32) NOT NULL, |
1175 | 1166 | |
1176 | 1167 | -- Some sort of stored value. Sizes, counts... |
1177 | | - qcc_value int unsigned NOT NULL default '0', |
| 1168 | + qcc_value int unsigned NOT NULL default 0, |
1178 | 1169 | |
1179 | 1170 | -- Target namespace+title |
1180 | | - qcc_namespace int NOT NULL default '0', |
| 1171 | + qcc_namespace int NOT NULL default 0, |
1181 | 1172 | qcc_title varchar(255) binary NOT NULL default '', |
1182 | 1173 | |
1183 | 1174 | -- Target namespace+title2 |
1184 | | - qcc_namespacetwo int NOT NULL default '0', |
1185 | | - qcc_titletwo varchar(255) binary NOT NULL default '', |
| 1175 | + qcc_namespacetwo int NOT NULL default 0, |
| 1176 | + qcc_titletwo varchar(255) binary NOT NULL default '' |
| 1177 | +) /*$wgDBTableOptions*/; |
1186 | 1178 | |
1187 | | - KEY qcc_type (qcc_type,qcc_value), |
1188 | | - KEY qcc_title (qcc_type,qcc_namespace,qcc_title), |
1189 | | - KEY qcc_titletwo (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); |
1190 | 1182 | |
1191 | | -) /*$wgDBTableOptions*/; |
1192 | 1183 | |
1193 | 1184 | -- Used for storing page restrictions (i.e. protection levels) |
1194 | | -CREATE TABLE /*$wgDBprefix*/page_restrictions ( |
| 1185 | +CREATE TABLE /*_*/page_restrictions ( |
1195 | 1186 | -- Page to apply restrictions to (Foreign Key to page). |
1196 | 1187 | pr_page int NOT NULL, |
1197 | 1188 | -- The protection type (edit, move, etc) |
— | — | @@ -1205,42 +1195,43 @@ |
1206 | 1196 | -- Field for time-limited protection. |
1207 | 1197 | pr_expiry varbinary(14) NULL, |
1208 | 1198 | -- Field for an ID for this restrictions row (sort-key for Special:ProtectedPages) |
1209 | | - pr_id int unsigned NOT NULL auto_increment, |
| 1199 | + pr_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT |
| 1200 | +) /*$wgDBTableOptions*/; |
1210 | 1201 | |
1211 | | - PRIMARY KEY pr_pagetype (pr_page,pr_type), |
| 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); |
1212 | 1206 | |
1213 | | - UNIQUE KEY pr_id (pr_id), |
1214 | | - KEY pr_typelevel (pr_type,pr_level), |
1215 | | - KEY pr_level (pr_level), |
1216 | | - KEY pr_cascade (pr_cascade) |
1217 | | -) /*$wgDBTableOptions*/; |
1218 | 1207 | |
1219 | 1208 | -- Protected titles - nonexistent pages that have been protected |
1220 | | -CREATE TABLE /*$wgDBprefix*/protected_titles ( |
| 1209 | +CREATE TABLE /*_*/protected_titles ( |
1221 | 1210 | pt_namespace int NOT NULL, |
1222 | 1211 | pt_title varchar(255) binary NOT NULL, |
1223 | 1212 | pt_user int unsigned NOT NULL, |
1224 | 1213 | pt_reason tinyblob, |
1225 | 1214 | pt_timestamp binary(14) NOT NULL, |
1226 | 1215 | pt_expiry varbinary(14) NOT NULL default '', |
1227 | | - pt_create_perm varbinary(60) NOT NULL, |
1228 | | - PRIMARY KEY (pt_namespace,pt_title), |
1229 | | - KEY pt_timestamp (pt_timestamp) |
| 1216 | + pt_create_perm varbinary(60) NOT NULL |
1230 | 1217 | ) /*$wgDBTableOptions*/; |
1231 | 1218 | |
| 1219 | +CREATE UNIQUE INDEX pt_namespace_title ON /*_*/protected_titles (pt_namespace,pt_title); |
| 1220 | +CREATE INDEX pt_timestamp ON /*_*/protected_titles (pt_timestamp); |
| 1221 | + |
| 1222 | + |
1232 | 1223 | -- Name/value pairs indexed by page_id |
1233 | | -CREATE TABLE /*$wgDBprefix*/page_props ( |
| 1224 | +CREATE TABLE /*_*/page_props ( |
1234 | 1225 | pp_page int NOT NULL, |
1235 | 1226 | pp_propname varbinary(60) NOT NULL, |
1236 | | - pp_value blob NOT NULL, |
1237 | | - |
1238 | | - PRIMARY KEY (pp_page,pp_propname) |
| 1227 | + pp_value blob NOT NULL |
1239 | 1228 | ) /*$wgDBTableOptions*/; |
1240 | 1229 | |
| 1230 | +CREATE UNIQUE INDEX pp_page_propname ON /*_*/page_props (pp_page,pp_propname); |
| 1231 | + |
| 1232 | + |
1241 | 1233 | -- A table to log updates, one text key row per update. |
1242 | | -CREATE TABLE /*$wgDBprefix*/updatelog ( |
1243 | | - ul_key varchar(255) NOT NULL, |
1244 | | - PRIMARY KEY (ul_key) |
| 1234 | +CREATE TABLE /*_*/updatelog ( |
| 1235 | + ul_key varchar(255) NOT NULL primary key |
1245 | 1236 | ) /*$wgDBTableOptions*/; |
1246 | 1237 | |
1247 | 1238 | -- vim: sw=2 sts=2 et |
Index: trunk/phase3/includes/SiteStats.php |
— | — | @@ -222,7 +222,7 @@ |
223 | 223 | |
224 | 224 | if ( $updates ) { |
225 | 225 | $site_stats = $dbw->tableName( 'site_stats' ); |
226 | | - $sql = $dbw->limitResultForUpdate("UPDATE $site_stats SET $updates", 1); |
| 226 | + $sql = "UPDATE $site_stats SET $updates"; |
227 | 227 | |
228 | 228 | # Need a separate transaction because this a global lock |
229 | 229 | $dbw->begin(); |
— | — | @@ -240,7 +240,7 @@ |
241 | 241 | __METHOD__ ); |
242 | 242 | $dbw->update( 'site_stats', |
243 | 243 | array( 'ss_active_users' => intval($activeUsers) ), |
244 | | - array( 'ss_row_id' => 1 ), __METHOD__, array( 'LIMIT' => 1 ) |
| 244 | + array( 'ss_row_id' => 1 ), __METHOD__ |
245 | 245 | ); |
246 | 246 | } |
247 | 247 | } |
Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -570,7 +570,7 @@ |
571 | 571 | $ret = $this->doQuery( $commentedSql ); |
572 | 572 | |
573 | 573 | # Try reconnecting if the connection was lost |
574 | | - if ( false === $ret && ( $this->lastErrno() == 2013 || $this->lastErrno() == 2006 ) ) { |
| 574 | + if ( false === $ret && $this->wasErrorReissuable() ) { |
575 | 575 | # Transaction is gone, like it or not |
576 | 576 | $this->mTrxLevel = 0; |
577 | 577 | wfDebug( "Connection lost, reconnecting...\n" ); |
— | — | @@ -1817,6 +1817,14 @@ |
1818 | 1818 | } |
1819 | 1819 | |
1820 | 1820 | /** |
| 1821 | + * Determines if the last query error was something that should be dealt |
| 1822 | + * with by pinging the connection and reissuing the query |
| 1823 | + */ |
| 1824 | + function wasErrorReissuable() { |
| 1825 | + return $this->lastErrno() == 2013 || $this->lastErrno() == 2006; |
| 1826 | + } |
| 1827 | + |
| 1828 | + /** |
1821 | 1829 | * Perform a deadlock-prone transaction. |
1822 | 1830 | * |
1823 | 1831 | * This function invokes a callback function to perform a set of write |
Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -15,6 +15,7 @@ |
16 | 16 | var $mAffectedRows; |
17 | 17 | var $mLastResult; |
18 | 18 | var $mDatabaseFile; |
| 19 | + var $mName; |
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Constructor |
— | — | @@ -26,6 +27,7 @@ |
27 | 28 | $this->mFailFunction = $failFunction; |
28 | 29 | $this->mFlags = $flags; |
29 | 30 | $this->mDatabaseFile = "$wgSQLiteDataDir/$dbName.sqlite"; |
| 31 | + $this->mName = $dbName; |
30 | 32 | $this->open($server, $user, $password, $dbName); |
31 | 33 | } |
32 | 34 | |
— | — | @@ -89,8 +91,9 @@ |
90 | 92 | */ |
91 | 93 | function doQuery($sql) { |
92 | 94 | $res = $this->mConn->query($sql); |
93 | | - if ($res === false) $this->reportQueryError($this->lastError(),$this->lastErrno(),$sql,__FUNCTION__); |
94 | | - else { |
| 95 | + if ($res === false) { |
| 96 | + return false; |
| 97 | + } else { |
95 | 98 | $r = $res instanceof ResultWrapper ? $res->result : $res; |
96 | 99 | $this->mAffectedRows = $r->rowCount(); |
97 | 100 | $res = new ResultWrapper($this,$r->fetchAll()); |
— | — | @@ -173,8 +176,12 @@ |
174 | 177 | } |
175 | 178 | |
176 | 179 | function lastErrno() { |
177 | | - if (!is_object($this->mConn)) return "Cannot return last error, no db connection"; |
178 | | - return $this->mConn->errorCode(); |
| 180 | + if (!is_object($this->mConn)) { |
| 181 | + return "Cannot return last error, no db connection"; |
| 182 | + } else { |
| 183 | + $info = $this->mConn->errorInfo(); |
| 184 | + return $info[1]; |
| 185 | + } |
179 | 186 | } |
180 | 187 | |
181 | 188 | function affectedRows() { |
— | — | @@ -183,14 +190,43 @@ |
184 | 191 | |
185 | 192 | /** |
186 | 193 | * Returns information about an index |
| 194 | + * Returns false if the index does not exist |
187 | 195 | * - if errors are explicitly ignored, returns NULL on failure |
188 | 196 | */ |
189 | 197 | function indexInfo($table, $index, $fname = 'Database::indexExists') { |
190 | | - return false; |
| 198 | + $sql = 'PRAGMA index_info(' . $this->addQuotes( $index ) . ')'; |
| 199 | + $res = $this->query( $sql, $fname ); |
| 200 | + if ( !$res ) { |
| 201 | + return null; |
| 202 | + } |
| 203 | + if ( $res->numRows() == 0 ) { |
| 204 | + return false; |
| 205 | + } |
| 206 | + $info = array(); |
| 207 | + foreach ( $res as $row ) { |
| 208 | + $info[] = $row->name; |
| 209 | + } |
| 210 | + return $info; |
191 | 211 | } |
192 | 212 | |
193 | 213 | function indexUnique($table, $index, $fname = 'Database::indexUnique') { |
194 | | - return false; |
| 214 | + $row = $this->selectRow( 'sqlite_master', '*', |
| 215 | + array( |
| 216 | + 'type' => 'index', |
| 217 | + 'name' => $index, |
| 218 | + ), $fname ); |
| 219 | + if ( !$row || !isset( $row->sql ) ) { |
| 220 | + return null; |
| 221 | + } |
| 222 | + |
| 223 | + // $row->sql will be of the form CREATE [UNIQUE] INDEX ... |
| 224 | + $indexPos = strpos( $row->sql, 'INDEX' ); |
| 225 | + if ( $indexPos === false ) { |
| 226 | + return null; |
| 227 | + } |
| 228 | + $firstPart = substr( $row->sql, 0, $indexPos ); |
| 229 | + $options = explode( ' ', $firstPart ); |
| 230 | + return in_array( 'UNIQUE', $options ); |
195 | 231 | } |
196 | 232 | |
197 | 233 | /** |
— | — | @@ -228,7 +264,10 @@ |
229 | 265 | return ''; |
230 | 266 | } |
231 | 267 | |
232 | | - # Returns the size of a text field, or -1 for "unlimited" |
| 268 | + /** |
| 269 | + * Returns the size of a text field, or -1 for "unlimited" |
| 270 | + * In SQLite this is SQLITE_MAX_LENGTH, by default 1GB. No way to query it though. |
| 271 | + */ |
233 | 272 | function textFieldSize($table, $field) { |
234 | 273 | return -1; |
235 | 274 | } |
— | — | @@ -252,6 +291,10 @@ |
253 | 292 | return $this->lastErrno() == SQLITE_BUSY; |
254 | 293 | } |
255 | 294 | |
| 295 | + function wasErrorReissuable() { |
| 296 | + return $this->lastErrno() == SQLITE_SCHEMA; |
| 297 | + } |
| 298 | + |
256 | 299 | /** |
257 | 300 | * @return string wikitext of a link to the server software's web site |
258 | 301 | */ |
— | — | @@ -265,17 +308,32 @@ |
266 | 309 | function getServerVersion() { |
267 | 310 | global $wgContLang; |
268 | 311 | $ver = $this->mConn->getAttribute(PDO::ATTR_SERVER_VERSION); |
269 | | - $size = $wgContLang->formatSize(filesize($this->mDatabaseFile)); |
270 | | - $file = basename($this->mDatabaseFile); |
271 | | - return $ver." ($file: $size)"; |
| 312 | + return $ver; |
272 | 313 | } |
273 | 314 | |
274 | 315 | /** |
275 | 316 | * Query whether a given column exists in the mediawiki schema |
276 | 317 | */ |
277 | | - function fieldExists($table, $field) { return true; } |
| 318 | + function fieldExists($table, $field) { |
| 319 | + $info = $this->fieldInfo( $table, $field ); |
| 320 | + return (bool)$info; |
| 321 | + } |
278 | 322 | |
279 | | - function fieldInfo($table, $field) { return SQLiteField::fromText($this, $table, $field); } |
| 323 | + /** |
| 324 | + * Get information about a given field |
| 325 | + * Returns false if the field does not exist. |
| 326 | + */ |
| 327 | + function fieldInfo($table, $field) { |
| 328 | + $tableName = $this->tableName( $table ); |
| 329 | + $sql = 'PRAGMA table_info(' . $this->addQuotes( $tableName ) . ')'; |
| 330 | + $res = $this->query( $sql, __METHOD__ ); |
| 331 | + foreach ( $res as $row ) { |
| 332 | + if ( $row->name == $field ) { |
| 333 | + return new SQLiteField( $row, $tableName ); |
| 334 | + } |
| 335 | + } |
| 336 | + return false; |
| 337 | + } |
280 | 338 | |
281 | 339 | function begin() { |
282 | 340 | if ($this->mTrxLevel == 1) $this->commit(); |
— | — | @@ -296,7 +354,7 @@ |
297 | 355 | } |
298 | 356 | |
299 | 357 | function limitResultForUpdate($sql, $num) { |
300 | | - return $sql; |
| 358 | + return $this->limitResult( $sql, $num ); |
301 | 359 | } |
302 | 360 | |
303 | 361 | function strencode($s) { |
— | — | @@ -325,17 +383,25 @@ |
326 | 384 | function quote_ident($s) { return $s; } |
327 | 385 | |
328 | 386 | /** |
329 | | - * For now, does nothing |
| 387 | + * Not possible in SQLite |
| 388 | + * We have ATTACH_DATABASE but that requires database selectors before the |
| 389 | + * table names and in any case is really a different concept to MySQL's USE |
330 | 390 | */ |
331 | | - function selectDB($db) { return true; } |
| 391 | + function selectDB($db) { |
| 392 | + if ( $db != $this->mName ) { |
| 393 | + throw new MWException( 'selectDB is not implemented in SQLite' ); |
| 394 | + } |
| 395 | + } |
332 | 396 | |
333 | 397 | /** |
334 | 398 | * not done |
335 | 399 | */ |
336 | 400 | public function setTimeout($timeout) { return; } |
337 | 401 | |
| 402 | + /** |
| 403 | + * No-op for a non-networked database |
| 404 | + */ |
338 | 405 | function ping() { |
339 | | - wfDebug("Function ping() not written for SQLite yet"); |
340 | 406 | return true; |
341 | 407 | } |
342 | 408 | |
— | — | @@ -353,39 +419,16 @@ |
354 | 420 | public function setup_database() { |
355 | 421 | global $IP,$wgSQLiteDataDir,$wgDBTableOptions; |
356 | 422 | $wgDBTableOptions = ''; |
357 | | - $mysql_tmpl = "$IP/maintenance/tables.sql"; |
358 | | - $mysql_iw = "$IP/maintenance/interwiki.sql"; |
359 | | - $sqlite_tmpl = "$IP/maintenance/sqlite/tables.sql"; |
360 | 423 | |
361 | | - # Make an SQLite template file if it doesn't exist (based on the same one MySQL uses to create a new wiki db) |
362 | | - if (!file_exists($sqlite_tmpl)) { |
363 | | - $sql = file_get_contents($mysql_tmpl); |
364 | | - $sql = preg_replace('/^\s*--.*?$/m','',$sql); # strip comments |
365 | | - $sql = preg_replace('/^\s*(UNIQUE)?\s*(PRIMARY)?\s*KEY.+?$/m','',$sql); |
366 | | - $sql = preg_replace('/^\s*(UNIQUE )?INDEX.+?$/m','',$sql); # These indexes should be created with a CREATE INDEX query |
367 | | - $sql = preg_replace('/^\s*FULLTEXT.+?$/m','',$sql); # Full text indexes |
368 | | - $sql = preg_replace('/ENUM\(.+?\)/','TEXT',$sql); # Make ENUM's into TEXT's |
369 | | - $sql = preg_replace('/binary\(\d+\)/','BLOB',$sql); |
370 | | - $sql = preg_replace('/(TYPE|MAX_ROWS|AVG_ROW_LENGTH)=\w+/','',$sql); |
371 | | - $sql = preg_replace('/,\s*\)/s',')',$sql); # removing previous items may leave a trailing comma |
372 | | - $sql = str_replace('binary','',$sql); |
373 | | - $sql = str_replace('auto_increment','PRIMARY KEY AUTOINCREMENT',$sql); |
374 | | - $sql = str_replace(' unsigned','',$sql); |
375 | | - $sql = str_replace(' int ',' INTEGER ',$sql); |
376 | | - $sql = str_replace('NOT NULL','',$sql); |
377 | | - |
378 | | - # Tidy up and write file |
379 | | - $sql = preg_replace('/^\s*^/m','',$sql); # Remove empty lines |
380 | | - $sql = preg_replace('/;$/m',";\n",$sql); # Separate each statement with an empty line |
381 | | - file_put_contents($sqlite_tmpl,$sql); |
| 424 | + # Process common MySQL/SQLite table definitions |
| 425 | + $err = $this->sourceFile( "$IP/maintenance/tables.sql" ); |
| 426 | + if ($err !== true) { |
| 427 | + $this->reportQueryError($err,0,$sql,__FUNCTION__); |
| 428 | + exit( 1 ); |
382 | 429 | } |
383 | 430 | |
384 | | - # Parse the SQLite template replacing inline variables such as /*$wgDBprefix*/ |
385 | | - $err = $this->sourceFile($sqlite_tmpl); |
386 | | - if ($err !== true) $this->reportQueryError($err,0,$sql,__FUNCTION__); |
387 | | - |
388 | 431 | # Use DatabasePostgres's code to populate interwiki from MySQL template |
389 | | - $f = fopen($mysql_iw,'r'); |
| 432 | + $f = fopen("$IP/maintenance/interwiki.sql",'r'); |
390 | 433 | if ($f == false) dieout("<li>Could not find the interwiki.sql file"); |
391 | 434 | $sql = "INSERT INTO interwiki(iw_prefix,iw_url,iw_local) VALUES "; |
392 | 435 | while (!feof($f)) { |
— | — | @@ -418,22 +461,80 @@ |
419 | 462 | $function = array_shift( $args ); |
420 | 463 | return call_user_func_array( $function, $args ); |
421 | 464 | } |
422 | | -} |
423 | 465 | |
| 466 | + protected function replaceVars( $s ) { |
| 467 | + $s = parent::replaceVars( $s ); |
| 468 | + if ( preg_match( '/^\s*CREATE TABLE/i', $s ) ) { |
| 469 | + // CREATE TABLE hacks to allow schema file sharing with MySQL |
| 470 | + |
| 471 | + // binary/varbinary column type -> blob |
| 472 | + $s = preg_replace( '/\b(var)?binary(\(\d+\))/i', 'blob\1', $s ); |
| 473 | + // no such thing as unsigned |
| 474 | + $s = preg_replace( '/\bunsigned\b/i', '', $s ); |
| 475 | + // INT -> INTEGER for primary keys |
| 476 | + $s = preg_replacE( '/\bint\b/i', 'integer', $s ); |
| 477 | + // No ENUM type |
| 478 | + $s = preg_replace( '/enum\([^)]*\)/i', 'blob', $s ); |
| 479 | + // binary collation type -> nothing |
| 480 | + $s = preg_replace( '/\bbinary\b/i', '', $s ); |
| 481 | + // auto_increment -> autoincrement |
| 482 | + $s = preg_replace( '/\bauto_increment\b/i', 'autoincrement', $s ); |
| 483 | + // No explicit options |
| 484 | + $s = preg_replace( '/\)[^)]*$/', ')', $s ); |
| 485 | + } elseif ( preg_match( '/^\s*CREATE (\s*(?:UNIQUE|FULLTEXT)\s+)?INDEX/i', $s ) ) { |
| 486 | + // No truncated indexes |
| 487 | + $s = preg_replace( '/\(\d+\)/', '', $s ); |
| 488 | + // No FULLTEXT |
| 489 | + $s = preg_replace( '/\bfulltext\b/i', '', $s ); |
| 490 | + } |
| 491 | + return $s; |
| 492 | + } |
| 493 | + |
| 494 | +} // end DatabaseSqlite class |
| 495 | + |
424 | 496 | /** |
425 | 497 | * @ingroup Database |
426 | 498 | */ |
427 | | -class SQLiteField extends MySQLField { |
| 499 | +class SQLiteField { |
| 500 | + private $info, $tableName; |
| 501 | + function __construct( $info, $tableName ) { |
| 502 | + $this->info = $info; |
| 503 | + $this->tableName = $tableName; |
| 504 | + } |
428 | 505 | |
429 | | - function __construct() { |
| 506 | + function name() { |
| 507 | + return $this->info->name; |
430 | 508 | } |
431 | 509 | |
432 | | - static function fromText($db, $table, $field) { |
433 | | - $n = new SQLiteField; |
434 | | - $n->name = $field; |
435 | | - $n->tablename = $table; |
436 | | - return $n; |
| 510 | + function tableName() { |
| 511 | + return $this->tableName; |
437 | 512 | } |
438 | 513 | |
439 | | -} // end DatabaseSqlite class |
| 514 | + function defaultValue() { |
| 515 | + if ( is_string( $this->info->dflt_value ) ) { |
| 516 | + // Typically quoted |
| 517 | + if ( preg_match( '/^\'(.*)\'$', $this->info->dflt_value ) ) { |
| 518 | + return str_replace( "''", "'", $this->info->dflt_value ); |
| 519 | + } |
| 520 | + } |
| 521 | + return $this->info->dflt_value; |
| 522 | + } |
440 | 523 | |
| 524 | + function maxLength() { |
| 525 | + return -1; |
| 526 | + } |
| 527 | + |
| 528 | + function nullable() { |
| 529 | + // SQLite dynamic types are always nullable |
| 530 | + return true; |
| 531 | + } |
| 532 | + |
| 533 | + # isKey(), isMultipleKey() not implemented, MySQL-specific concept. |
| 534 | + # Suggest removal from base class [TS] |
| 535 | + |
| 536 | + function type() { |
| 537 | + return $this->info->type; |
| 538 | + } |
| 539 | + |
| 540 | +} // end SQLiteField |
| 541 | + |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -161,23 +161,26 @@ |
162 | 162 | if( $hookResult = $this->runHooks( get_class( $this ) . "Raw" ) ) { |
163 | 163 | die( $hookResult ); |
164 | 164 | } |
165 | | - echo $this->htmlHeader(); |
166 | | - echo $this->getHTML(); |
167 | | - echo $this->htmlFooter(); |
| 165 | + if ( defined( 'MEDIAWIKI_INSTALL' ) ) { |
| 166 | + echo $this->getHTML(); |
| 167 | + } else { |
| 168 | + echo $this->htmlHeader(); |
| 169 | + echo $this->getHTML(); |
| 170 | + echo $this->htmlFooter(); |
| 171 | + } |
168 | 172 | } |
169 | 173 | } |
170 | 174 | |
171 | 175 | /** |
172 | 176 | * Output a report about the exception and takes care of formatting. |
173 | | - * It will be either HTML or plain text based on $wgCommandLineMode. |
| 177 | + * It will be either HTML or plain text based on isCommandLine(). |
174 | 178 | */ |
175 | 179 | function report() { |
176 | | - global $wgCommandLineMode; |
177 | 180 | $log = $this->getLogMessage(); |
178 | 181 | if ( $log ) { |
179 | 182 | wfDebugLog( 'exception', $log ); |
180 | 183 | } |
181 | | - if ( $wgCommandLineMode ) { |
| 184 | + if ( self::isCommandLine() ) { |
182 | 185 | wfPrintError( $this->getText() ); |
183 | 186 | } else { |
184 | 187 | $this->reportHTML(); |
— | — | @@ -214,6 +217,10 @@ |
215 | 218 | function htmlFooter() { |
216 | 219 | echo "</body></html>"; |
217 | 220 | } |
| 221 | + |
| 222 | + static function isCommandLine() { |
| 223 | + return !empty( $GLOBALS['wgCommandLineMode'] ) && !defined( 'MEDIAWIKI_INSTALL' ); |
| 224 | + } |
218 | 225 | } |
219 | 226 | |
220 | 227 | /** |
— | — | @@ -264,6 +271,7 @@ |
265 | 272 | * Report an exception to the user |
266 | 273 | */ |
267 | 274 | function wfReportException( Exception $e ) { |
| 275 | + $cmdLine = MWException::isCommandLine(); |
268 | 276 | if ( $e instanceof MWException ) { |
269 | 277 | try { |
270 | 278 | $e->report(); |
— | — | @@ -276,7 +284,7 @@ |
277 | 285 | "\n\nException caught inside exception handler: " . |
278 | 286 | $e2->__toString() . "\n"; |
279 | 287 | |
280 | | - if ( !empty( $GLOBALS['wgCommandLineMode'] ) ) { |
| 288 | + if ( $cmdLine ) { |
281 | 289 | wfPrintError( $message ); |
282 | 290 | } else { |
283 | 291 | echo nl2br( htmlspecialchars( $message ) ). "\n"; |
— | — | @@ -288,7 +296,7 @@ |
289 | 297 | if ( $GLOBALS['wgShowExceptionDetails'] ) { |
290 | 298 | $message .= "\n" . $e->getTraceAsString() ."\n"; |
291 | 299 | } |
292 | | - if ( !empty( $GLOBALS['wgCommandLineMode'] ) ) { |
| 300 | + if ( $cmdLine ) { |
293 | 301 | wfPrintError( $message ); |
294 | 302 | } else { |
295 | 303 | echo nl2br( htmlspecialchars( $message ) ). "\n"; |
— | — | @@ -298,7 +306,7 @@ |
299 | 307 | |
300 | 308 | /** |
301 | 309 | * Print a message, if possible to STDERR. |
302 | | - * Use this in command line mode only (see wgCommandLineMode) |
| 310 | + * Use this in command line mode only (see isCommandLine) |
303 | 311 | */ |
304 | 312 | function wfPrintError( $message ) { |
305 | 313 | #NOTE: STDERR may not be available, especially if php-cgi is used from the command line (bug #15602). |
Index: trunk/phase3/config/index.php |
— | — | @@ -47,11 +47,13 @@ |
48 | 48 | require_once( "$IP/includes/ProfilerStub.php" ); |
49 | 49 | require_once( "$IP/includes/GlobalFunctions.php" ); |
50 | 50 | require_once( "$IP/includes/Hooks.php" ); |
| 51 | +require_once( "$IP/includes/Exception.php" ); |
51 | 52 | |
52 | 53 | # If we get an exception, the user needs to know |
53 | 54 | # all the details |
54 | 55 | $wgShowExceptionDetails = true; |
55 | | - |
| 56 | +$wgShowSQLErrors = true; |
| 57 | +wfInstallExceptionHandler(); |
56 | 58 | ## Databases we support: |
57 | 59 | |
58 | 60 | $ourdb = array(); |