r58144 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58143‎ | r58144 | r58145 >
Date:16:32, 26 October 2009
Author:leonsp
Status:ok
Tags:
Comment:
- DB2 bugfix: Blob class now converted to string where appropriate
- DB2 bugfix: Integer types enlarged to match MySQL (primarily, MySQL INT UNSIGNED now mapped to DB2 BIGINT)
Modified paths:
  • /trunk/phase3/includes/db/DatabaseIbm_db2.php (modified) (history)
  • /trunk/phase3/maintenance/ibm_db2/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/ibm_db2/tables.sql
@@ -8,14 +8,14 @@
99
1010
1111 CREATE TABLE user (
12 - user_id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 0),
 12+ user_id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 0),
1313 user_name VARCHAR(255) NOT NULL UNIQUE,
1414 user_real_name VARCHAR(255),
1515 user_password VARCHAR(1024),
1616 user_newpassword VARCHAR(1024),
1717 user_newpass_time TIMESTAMP(3),
1818 user_token VARCHAR(255),
19 - user_email VARCHAR(255),
 19+ user_email VARCHAR(1024),
2020 user_email_token VARCHAR(255),
2121 user_email_token_expires TIMESTAMP(3),
2222 user_email_authenticated TIMESTAMP(3),
@@ -43,7 +43,7 @@
4444
4545
4646 CREATE TABLE user_groups (
47 - ug_user INTEGER NOT NULL DEFAULT 0,
 47+ ug_user BIGINT NOT NULL DEFAULT 0,
4848 -- REFERENCES user(user_id) ON DELETE CASCADE,
4949 ug_group VARCHAR(255) NOT NULL
5050 );
@@ -56,7 +56,7 @@
5757
5858 CREATE TABLE user_newtalk (
5959 -- registered users key
60 - user_id INTEGER NOT NULL DEFAULT 0,
 60+ user_id BIGINT NOT NULL DEFAULT 0,
6161 -- REFERENCES user(user_id) ON DELETE CASCADE,
6262 -- anonymous users key
6363 user_ip VARCHAR(40),
@@ -71,7 +71,7 @@
7272
7373
7474 CREATE TABLE page (
75 - page_id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 0),
 75+ page_id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 0),
7676 page_namespace SMALLINT NOT NULL,
7777 page_title VARCHAR(255) NOT NULL,
7878 page_restrictions VARCHAR(1024),
@@ -80,8 +80,8 @@
8181 page_is_new SMALLINT NOT NULL DEFAULT 0,
8282 page_random NUMERIC(15,14) NOT NULL,
8383 page_touched TIMESTAMP(3),
84 - page_latest INTEGER NOT NULL, -- FK?
85 - page_len INTEGER NOT NULL
 84+ page_latest BIGINT NOT NULL, -- FK?
 85+ page_len BIGINT NOT NULL
8686 );
8787 CREATE UNIQUE INDEX page_unique_name ON page (page_namespace, page_title);
8888 CREATE INDEX page_random_idx ON page (page_random);
@@ -96,19 +96,19 @@
9797
9898
9999 CREATE TABLE revision (
100 - rev_id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 0),
101 - rev_page INTEGER NOT NULL DEFAULT 0,
 100+ rev_id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 0),
 101+ rev_page BIGINT NOT NULL DEFAULT 0,
102102 -- REFERENCES page (page_id) ON DELETE CASCADE,
103 - rev_text_id INTEGER, -- FK
104 - rev_comment VARCHAR(1024),
105 - rev_user INTEGER NOT NULL DEFAULT 0,
 103+ rev_text_id BIGINT, -- FK
 104+ rev_comment VARCHAR(1024),
 105+ rev_user BIGINT NOT NULL DEFAULT 0,
106106 -- REFERENCES user(user_id) ON DELETE RESTRICT,
107 - rev_user_text VARCHAR(255) NOT NULL,
108 - rev_timestamp TIMESTAMP(3) NOT NULL,
109 - rev_minor_edit SMALLINT NOT NULL DEFAULT 0,
110 - rev_deleted SMALLINT NOT NULL DEFAULT 0,
111 - rev_len INTEGER,
112 - rev_parent_id INTEGER
 107+ rev_user_text VARCHAR(255) NOT NULL,
 108+ rev_timestamp TIMESTAMP(3) NOT NULL,
 109+ rev_minor_edit SMALLINT NOT NULL DEFAULT 0,
 110+ rev_deleted SMALLINT NOT NULL DEFAULT 0,
 111+ rev_len BIGINT,
 112+ rev_parent_id BIGINT DEFAULT NULL
113113 );
114114 CREATE UNIQUE INDEX revision_unique ON revision (rev_page, rev_id);
115115 CREATE INDEX rev_text_id_idx ON revision (rev_text_id);
@@ -130,7 +130,7 @@
131131 CREATE TABLE page_restrictions (
132132 --pr_id INTEGER NOT NULL UNIQUE, --DEFAULT nextval('pr_id_val'),
133133 --pr_id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 0),
134 - pr_id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 0),
 134+ pr_id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 0),
135135 pr_page INTEGER NOT NULL DEFAULT 0,
136136 --(used to be nullable)
137137 -- REFERENCES page (page_id) ON DELETE CASCADE,
@@ -164,7 +164,7 @@
165165 ar_title VARCHAR(255) NOT NULL,
166166 ar_text CLOB(16M) INLINE LENGTH 4096,
167167 ar_comment VARCHAR(1024),
168 - ar_user INTEGER NOT NULL,
 168+ ar_user BIGINT NOT NULL,
169169 -- no foreign keys in MySQL
170170 -- REFERENCES user(user_id) ON DELETE SET NULL,
171171 ar_user_text VARCHAR(255) NOT NULL,
@@ -184,7 +184,7 @@
185185
186186
187187 CREATE TABLE redirect (
188 - rd_from INTEGER NOT NULL PRIMARY KEY,
 188+ rd_from BIGINT NOT NULL PRIMARY KEY,
189189 --REFERENCES page(page_id) ON DELETE CASCADE,
190190 rd_namespace SMALLINT NOT NULL DEFAULT 0,
191191 rd_title VARCHAR(255) NOT NULL DEFAULT '',
@@ -195,7 +195,7 @@
196196
197197
198198 CREATE TABLE pagelinks (
199 - pl_from INTEGER NOT NULL DEFAULT 0,
 199+ pl_from BIGINT NOT NULL DEFAULT 0,
200200 -- REFERENCES page(page_id) ON DELETE CASCADE,
201201 pl_namespace SMALLINT NOT NULL,
202202 pl_title VARCHAR(255) NOT NULL
@@ -203,7 +203,7 @@
204204 CREATE UNIQUE INDEX pagelink_unique ON pagelinks (pl_from,pl_namespace,pl_title);
205205
206206 CREATE TABLE templatelinks (
207 - tl_from INTEGER NOT NULL DEFAULT 0,
 207+ tl_from BIGINT NOT NULL DEFAULT 0,
208208 -- REFERENCES page(page_id) ON DELETE CASCADE,
209209 tl_namespace SMALLINT NOT NULL,
210210 tl_title VARCHAR(255) NOT NULL
@@ -212,7 +212,7 @@
213213 CREATE UNIQUE INDEX tl_from_idx ON templatelinks (tl_from,tl_namespace,tl_title);
214214
215215 CREATE TABLE imagelinks (
216 - il_from INTEGER NOT NULL DEFAULT 0,
 216+ il_from BIGINT NOT NULL DEFAULT 0,
217217 -- REFERENCES page(page_id) ON DELETE CASCADE,
218218 il_to VARCHAR(255) NOT NULL
219219 );
@@ -220,10 +220,12 @@
221221 CREATE UNIQUE INDEX il_to_idx ON imagelinks (il_from,il_to);
222222
223223 CREATE TABLE categorylinks (
224 - cl_from INTEGER NOT NULL DEFAULT 0,
 224+ cl_from BIGINT NOT NULL DEFAULT 0,
225225 -- REFERENCES page(page_id) ON DELETE CASCADE,
226226 cl_to VARCHAR(255) NOT NULL,
227 - cl_sortkey VARCHAR(70),
 227+ -- cl_sortkey has to be at least 86 wide
 228+ -- in order to be compatible with the old MySQL schema from MW 1.10
 229+ cl_sortkey VARCHAR(86),
228230 cl_timestamp TIMESTAMP(3) NOT NULL
229231 );
230232 CREATE UNIQUE INDEX cl_from ON categorylinks (cl_from, cl_to);
@@ -232,7 +234,7 @@
233235
234236
235237 CREATE TABLE externallinks (
236 - el_from INTEGER NOT NULL DEFAULT 0,
 238+ el_from BIGINT NOT NULL DEFAULT 0,
237239 -- REFERENCES page(page_id) ON DELETE CASCADE,
238240 el_to VARCHAR(1024) NOT NULL,
239241 el_index VARCHAR(1024) NOT NULL
@@ -246,7 +248,7 @@
247249 --
248250 CREATE TABLE external_user (
249251 -- Foreign key to user_id
250 - eu_wiki_id INTEGER NOT NULL PRIMARY KEY,
 252+ eu_wiki_id BIGINT NOT NULL PRIMARY KEY,
251253
252254 -- Some opaque identifier provided by the external database
253255 eu_external_id VARCHAR(255) NOT NULL
@@ -261,7 +263,7 @@
262264
263265
264266 CREATE TABLE langlinks (
265 - ll_from INTEGER NOT NULL DEFAULT 0,
 267+ ll_from BIGINT NOT NULL DEFAULT 0,
266268 -- REFERENCES page (page_id) ON DELETE CASCADE,
267269 ll_lang VARCHAR(20),
268270 ll_title VARCHAR(255)
@@ -271,10 +273,10 @@
272274
273275
274276 CREATE TABLE site_stats (
275 - ss_row_id INTEGER NOT NULL UNIQUE,
276 - ss_total_views INTEGER DEFAULT 0,
277 - ss_total_edits INTEGER DEFAULT 0,
278 - ss_good_articles INTEGER DEFAULT 0,
 277+ ss_row_id BIGINT NOT NULL UNIQUE,
 278+ ss_total_views BIGINT DEFAULT 0,
 279+ ss_total_edits BIGINT DEFAULT 0,
 280+ ss_good_articles BIGINT DEFAULT 0,
279281 ss_total_pages INTEGER DEFAULT -1,
280282 ss_users INTEGER DEFAULT -1,
281283 ss_active_users INTEGER DEFAULT -1,
@@ -290,9 +292,9 @@
291293 ipb_id INTEGER NOT NULL PRIMARY KEY,
292294 --DEFAULT nextval('ipblocks_ipb_id_val'),
293295 ipb_address VARCHAR(1024),
294 - ipb_user INTEGER NOT NULL DEFAULT 0,
 296+ ipb_user BIGINT NOT NULL DEFAULT 0,
295297 -- REFERENCES user(user_id) ON DELETE SET NULL,
296 - ipb_by INTEGER NOT NULL DEFAULT 0,
 298+ ipb_by BIGINT NOT NULL DEFAULT 0,
297299 -- REFERENCES user(user_id) ON DELETE CASCADE,
298300 ipb_by_text VARCHAR(255) NOT NULL DEFAULT '',
299301 ipb_reason VARCHAR(1024) NOT NULL,
@@ -317,7 +319,7 @@
318320
319321 CREATE TABLE image (
320322 img_name VARCHAR(255) NOT NULL PRIMARY KEY,
321 - img_size INTEGER NOT NULL,
 323+ img_size BIGINT NOT NULL,
322324 img_width INTEGER NOT NULL,
323325 img_height INTEGER NOT NULL,
324326 img_metadata CLOB(16M) INLINE LENGTH 4096 NOT NULL DEFAULT '',
@@ -326,7 +328,7 @@
327329 img_major_mime VARCHAR(255) DEFAULT 'unknown',
328330 img_minor_mime VARCHAR(32) DEFAULT 'unknown',
329331 img_description VARCHAR(1024) NOT NULL DEFAULT '',
330 - img_user INTEGER NOT NULL DEFAULT 0,
 332+ img_user BIGINT NOT NULL DEFAULT 0,
331333 -- REFERENCES user(user_id) ON DELETE SET NULL,
332334 img_user_text VARCHAR(255) NOT NULL DEFAULT '',
333335 img_timestamp TIMESTAMP(3),
@@ -339,12 +341,12 @@
340342 CREATE TABLE oldimage (
341343 oi_name VARCHAR(255) NOT NULL DEFAULT '',
342344 oi_archive_name VARCHAR(255) NOT NULL,
343 - oi_size INTEGER NOT NULL,
 345+ oi_size BIGINT NOT NULL,
344346 oi_width INTEGER NOT NULL,
345347 oi_height INTEGER NOT NULL,
346348 oi_bits SMALLINT NOT NULL,
347349 oi_description VARCHAR(1024),
348 - oi_user INTEGER NOT NULL DEFAULT 0,
 350+ oi_user BIGINT NOT NULL DEFAULT 0,
349351 -- REFERENCES user(user_id) ON DELETE SET NULL,
350352 oi_user_text VARCHAR(255) NOT NULL,
351353 oi_timestamp TIMESTAMP(3) NOT NULL,
@@ -369,12 +371,12 @@
370372 fa_name VARCHAR(255) NOT NULL,
371373 fa_archive_name VARCHAR(255),
372374 fa_storage_group VARCHAR(255),
373 - fa_storage_key VARCHAR(32),
374 - fa_deleted_user INTEGER NOT NULL DEFAULT 0,
 375+ fa_storage_key VARCHAR(64) DEFAULT '',
 376+ fa_deleted_user BIGINT NOT NULL DEFAULT 0,
375377 -- REFERENCES user(user_id) ON DELETE SET NULL,
376378 fa_deleted_timestamp TIMESTAMP(3) NOT NULL,
377379 fa_deleted_reason VARCHAR(255),
378 - fa_size INTEGER NOT NULL,
 380+ fa_size BIGINT NOT NULL,
379381 fa_width INTEGER NOT NULL,
380382 fa_height INTEGER NOT NULL,
381383 fa_metadata CLOB(16M) INLINE LENGTH 4096 NOT NULL DEFAULT '',
@@ -383,7 +385,7 @@
384386 fa_major_mime VARCHAR(255) DEFAULT 'unknown',
385387 fa_minor_mime VARCHAR(255) DEFAULT 'unknown',
386388 fa_description VARCHAR(1024) NOT NULL,
387 - fa_user INTEGER NOT NULL DEFAULT 0,
 389+ fa_user BIGINT NOT NULL DEFAULT 0,
388390 -- REFERENCES user(user_id) ON DELETE SET NULL,
389391 fa_user_text VARCHAR(255) NOT NULL,
390392 fa_timestamp TIMESTAMP(3),
@@ -400,7 +402,7 @@
401403 --PRIMARY KEY DEFAULT nextval('rc_rc_id_seq'),
402404 rc_timestamp TIMESTAMP(3) NOT NULL,
403405 rc_cur_time TIMESTAMP(3) NOT NULL,
404 - rc_user INTEGER NOT NULL DEFAULT 0,
 406+ rc_user BIGINT NOT NULL DEFAULT 0,
405407 -- REFERENCES user(user_id) ON DELETE SET NULL,
406408 rc_user_text VARCHAR(255) NOT NULL,
407409 rc_namespace SMALLINT NOT NULL,
@@ -409,10 +411,10 @@
410412 rc_minor SMALLINT NOT NULL DEFAULT 0,
411413 rc_bot SMALLINT NOT NULL DEFAULT 0,
412414 rc_new SMALLINT NOT NULL DEFAULT 0,
413 - rc_cur_id INTEGER NOT NULL DEFAULT 0,
 415+ rc_cur_id BIGINT NOT NULL DEFAULT 0,
414416 -- REFERENCES page(page_id) ON DELETE SET NULL,
415 - rc_this_oldid INTEGER NOT NULL,
416 - rc_last_oldid INTEGER NOT NULL,
 417+ rc_this_oldid BIGINT NOT NULL,
 418+ rc_last_oldid BIGINT NOT NULL,
417419 rc_type SMALLINT NOT NULL DEFAULT 0,
418420 rc_moved_to_ns SMALLINT,
419421 rc_moved_to_title VARCHAR(255),
@@ -421,7 +423,7 @@
422424 rc_old_len INTEGER,
423425 rc_new_len INTEGER,
424426 rc_deleted SMALLINT NOT NULL DEFAULT 0,
425 - rc_logid INTEGER NOT NULL DEFAULT 0,
 427+ rc_logid BIGINT NOT NULL DEFAULT 0,
426428 rc_log_type VARCHAR(255),
427429 rc_log_action VARCHAR(255),
428430 rc_params CLOB(64K) INLINE LENGTH 4096
@@ -436,7 +438,7 @@
437439
438440
439441 CREATE TABLE watchlist (
440 - wl_user INTEGER NOT NULL DEFAULT 0,
 442+ wl_user BIGINT NOT NULL DEFAULT 0,
441443 -- REFERENCES user(user_id) ON DELETE CASCADE,
442444 wl_namespace SMALLINT NOT NULL DEFAULT 0,
443445 wl_title VARCHAR(255) NOT NULL,
@@ -464,8 +466,8 @@
465467
466468 CREATE TABLE querycache (
467469 qc_type VARCHAR(255) NOT NULL,
468 - qc_value INTEGER NOT NULL,
469 - qc_namespace SMALLINT NOT NULL,
 470+ qc_value BIGINT NOT NULL,
 471+ qc_namespace INTEGER NOT NULL,
470472 qc_title VARCHAR(255) NOT NULL
471473 );
472474 CREATE INDEX querycache_type_value ON querycache (qc_type, qc_value);
@@ -480,7 +482,7 @@
481483
482484 CREATE TABLE querycachetwo (
483485 qcc_type VARCHAR(255) NOT NULL,
484 - qcc_value INTEGER NOT NULL DEFAULT 0,
 486+ qcc_value BIGINT NOT NULL DEFAULT 0,
485487 qcc_namespace INTEGER NOT NULL DEFAULT 0,
486488 qcc_title VARCHAR(255) NOT NULL DEFAULT '',
487489 qcc_namespacetwo INTEGER NOT NULL DEFAULT 0,
@@ -501,24 +503,24 @@
502504
503505 CREATE TABLE transcache (
504506 tc_url VARCHAR(255) NOT NULL UNIQUE,
505 - tc_contents VARCHAR(255) NOT NULL,
 507+ tc_contents CLOB(64K) INLINE LENGTH 4096 NOT NULL,
506508 tc_time TIMESTAMP(3) NOT NULL
507509 );
508510
509511
510512 CREATE TABLE logging (
511 - log_id INTEGER NOT NULL PRIMARY KEY,
 513+ log_id BIGINT NOT NULL PRIMARY KEY,
512514 --PRIMARY KEY DEFAULT nextval('log_log_id_seq'),
513515 log_type VARCHAR(32) NOT NULL,
514516 log_action VARCHAR(32) NOT NULL,
515517 log_timestamp TIMESTAMP(3) NOT NULL,
516 - log_user INTEGER NOT NULL DEFAULT 0,
 518+ log_user BIGINT NOT NULL DEFAULT 0,
517519 -- REFERENCES user(user_id) ON DELETE SET NULL,
518520 -- Name of the user who performed this action
519521 log_user_text VARCHAR(255) NOT NULL default '',
520522 log_namespace SMALLINT NOT NULL,
521523 log_title VARCHAR(255) NOT NULL,
522 - log_page INTEGER,
 524+ log_page BIGINT,
523525 log_comment VARCHAR(255),
524526 log_params CLOB(64K) INLINE LENGTH 4096,
525527 log_deleted SMALLINT NOT NULL DEFAULT 0
@@ -546,7 +548,7 @@
547549
548550
549551 CREATE TABLE job (
550 - job_id INTEGER NOT NULL PRIMARY KEY,
 552+ job_id BIGINT NOT NULL PRIMARY KEY,
551553 --PRIMARY KEY DEFAULT nextval('job_job_id_seq'),
552554 job_cmd VARCHAR(255) NOT NULL,
553555 job_namespace SMALLINT NOT NULL,
@@ -607,7 +609,7 @@
608610 -- hack implementation
609611 -- should be replaced with OmniFind, Contains(), etc
610612 CREATE TABLE searchindex (
611 - si_page int NOT NULL,
 613+ si_page BIGINT NOT NULL,
612614 si_title varchar(255) NOT NULL default '',
613615 si_text clob NOT NULL
614616 );
@@ -623,9 +625,9 @@
624626 CREATE UNIQUE INDEX pf_name_server ON profiling (pf_name, pf_server);
625627
626628 CREATE TABLE protected_titles (
627 - pt_namespace SMALLINT NOT NULL,
 629+ pt_namespace INTEGER NOT NULL,
628630 pt_title VARCHAR(255) NOT NULL,
629 - pt_user INTEGER NOT NULL DEFAULT 0,
 631+ pt_user BIGINT NOT NULL DEFAULT 0,
630632 -- REFERENCES user(user_id) ON DELETE SET NULL,
631633 pt_reason VARCHAR(1024),
632634 pt_timestamp TIMESTAMP(3) NOT NULL,
@@ -697,7 +699,7 @@
698700 --
699701 CREATE TABLE user_properties (
700702 -- Foreign key to user.user_id
701 - up_user INTEGER NOT NULL,
 703+ up_user BIGINT NOT NULL,
702704
703705 -- Name of the option being saved. This is indexed for bulk lookup.
704706 up_property VARCHAR(32) FOR BIT DATA NOT NULL,
@@ -714,7 +716,7 @@
715717 -- The value of the ID
716718 ls_value varchar(255) NOT NULL,
717719 -- Key to log_id
718 - ls_log_id INTEGER NOT NULL default 0
 720+ ls_log_id BIGINT NOT NULL default 0
719721 );
720722 CREATE UNIQUE INDEX ls_field_val ON log_search (ls_field,ls_value,ls_log_id);
721723 CREATE INDEX ls_log_id ON log_search (ls_log_id);
Index: trunk/phase3/includes/db/DatabaseIbm_db2.php
@@ -85,13 +85,18 @@
8686 class IBM_DB2Blob {
8787 private $mData;
8888
89 - function __construct($data) {
 89+ public function __construct($data) {
9090 $this->mData = $data;
9191 }
9292
93 - function getData() {
 93+ public function getData() {
9494 return $this->mData;
9595 }
 96+
 97+ public function __toString()
 98+ {
 99+ return $this->mData;
 100+ }
96101 }
97102
98103 /**
@@ -770,6 +775,8 @@
771776 return "NULL";
772777 } else if ($s instanceof Blob) {
773778 return "'".$s->fetch($s)."'";
 779+ } else if ($s instanceof IBM_DB2Blob) {
 780+ return "'".$this->decodeBlob($s)."'";
774781 }
775782 $s = $this->strencode($s);
776783 if ( is_numeric($s) ) {

Status & tagging log