| Index: trunk/phase3/maintenance/archives/patch-querycacheinfo.sql |
| — | — | @@ -9,4 +9,4 @@ |
| 10 | 10 | |
| 11 | 11 | UNIQUE KEY ( qci_type ) |
| 12 | 12 | |
| 13 | | -) TYPE=InnoDB; |
| | 13 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-job.sql |
| — | — | @@ -17,4 +17,4 @@ |
| 18 | 18 | |
| 19 | 19 | PRIMARY KEY job_id (job_id), |
| 20 | 20 | KEY (job_cmd, job_namespace, job_title) |
| 21 | | -) TYPE=InnoDB; |
| | 21 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-templatelinks.sql |
| — | — | @@ -15,5 +15,5 @@ |
| 16 | 16 | UNIQUE KEY tl_from(tl_from,tl_namespace,tl_title), |
| 17 | 17 | KEY (tl_namespace,tl_title) |
| 18 | 18 | |
| 19 | | -) TYPE=InnoDB; |
| | 19 | +) /*$wgDBTableOptions*/; |
| 20 | 20 | |
| Index: trunk/phase3/maintenance/archives/patch-user_groups.sql |
| — | — | @@ -22,4 +22,4 @@ |
| 23 | 23 | |
| 24 | 24 | PRIMARY KEY (ug_user,ug_group), |
| 25 | 25 | KEY (ug_group) |
| 26 | | -) TYPE=InnoDB; |
| | 26 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-querycachetwo.sql |
| — | — | @@ -19,4 +19,4 @@ |
| 20 | 20 | KEY qcc_title (qcc_type,qcc_namespace,qcc_title), |
| 21 | 21 | KEY qcc_titletwo (qcc_type,qcc_namespacetwo,qcc_titletwo) |
| 22 | 22 | |
| 23 | | -) TYPE=InnoDB; |
| | 23 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-externallinks.sql |
| — | — | @@ -9,5 +9,5 @@ |
| 10 | 10 | KEY (el_from, el_to(40)), |
| 11 | 11 | KEY (el_to(60), el_from), |
| 12 | 12 | KEY (el_index(60)) |
| 13 | | -) TYPE=InnoDB; |
| | 13 | +) /*$wgDBTableOptions*/; |
| 14 | 14 | |
| Index: trunk/phase3/maintenance/archives/patch-userlevels.sql |
| — | — | @@ -11,7 +11,7 @@ |
| 12 | 12 | gr_rights tinyblob, |
| 13 | 13 | PRIMARY KEY (gr_id) |
| 14 | 14 | |
| 15 | | -) TYPE=InnoDB; |
| | 15 | +) /*$wgDBTableOptions*/; |
| 16 | 16 | |
| 17 | 17 | -- Relation table between user and groups |
| 18 | 18 | CREATE TABLE /*$wgDBprefix*/user_groups ( |
| — | — | @@ -19,4 +19,4 @@ |
| 20 | 20 | ug_group int(5) unsigned NOT NULL default '0', |
| 21 | 21 | PRIMARY KEY (ug_user,ug_group) |
| 22 | 22 | |
| 23 | | -) TYPE=InnoDB; |
| | 23 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-validate.sql |
| — | — | @@ -10,4 +10,4 @@ |
| 11 | 11 | `val_comment` varchar(255) NOT NULL default '', |
| 12 | 12 | `val_ip` varchar(20) NOT NULL default '', |
| 13 | 13 | KEY `val_user` (`val_user`,`val_revision`) |
| 14 | | -) TYPE=InnoDB; |
| | 14 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-objectcache.sql |
| — | — | @@ -6,4 +6,4 @@ |
| 7 | 7 | unique key (keyname), |
| 8 | 8 | key (exptime) |
| 9 | 9 | |
| 10 | | -) TYPE=InnoDB; |
| | 10 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-user_rights.sql |
| — | — | @@ -14,7 +14,7 @@ |
| 15 | 15 | |
| 16 | 16 | UNIQUE KEY ur_user (ur_user) |
| 17 | 17 | |
| 18 | | -) TYPE=InnoDB; |
| | 18 | +) /*$wgDBTableOptions*/; |
| 19 | 19 | |
| 20 | 20 | INSERT INTO /*$wgDBprefix*/user_rights SELECT user_id,user_rights FROM /*$wgDBprefix*/user; |
| 21 | 21 | |
| Index: trunk/phase3/maintenance/archives/patch-interwiki.sql |
| — | — | @@ -17,4 +17,4 @@ |
| 18 | 18 | |
| 19 | 19 | UNIQUE KEY iw_prefix (iw_prefix) |
| 20 | 20 | |
| 21 | | -) TYPE=InnoDB; |
| | 21 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-categorylinks.sql |
| — | — | @@ -36,4 +36,4 @@ |
| 37 | 37 | -- Not really used? |
| 38 | 38 | KEY cl_timestamp(cl_to,cl_timestamp) |
| 39 | 39 | |
| 40 | | -) TYPE=InnoDB; |
| | 40 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-page_restrictions.sql |
| — | — | @@ -19,4 +19,4 @@ |
| 20 | 20 | KEY pr_typelevel (pr_type,pr_level), |
| 21 | 21 | KEY pr_level (pr_level), |
| 22 | 22 | KEY pr_cascade (pr_cascade) |
| 23 | | -) TYPE=InnoDB; |
| \ No newline at end of file |
| | 23 | +) /*$wgDBTableOptions*/; |
| \ No newline at end of file |
| Index: trunk/phase3/maintenance/archives/patch-linkscc.sql |
| — | — | @@ -9,4 +9,4 @@ |
| 10 | 10 | lcc_pageid INT UNSIGNED NOT NULL UNIQUE KEY, |
| 11 | 11 | lcc_cacheobj MEDIUMBLOB NOT NULL |
| 12 | 12 | |
| 13 | | -) TYPE=InnoDB; |
| | 13 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-querycache.sql |
| — | — | @@ -13,4 +13,4 @@ |
| 14 | 14 | |
| 15 | 15 | KEY (qc_type,qc_value) |
| 16 | 16 | |
| 17 | | -) TYPE=InnoDB; |
| | 17 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-redirect.sql |
| — | — | @@ -15,7 +15,7 @@ |
| 16 | 16 | |
| 17 | 17 | PRIMARY KEY rd_from (rd_from), |
| 18 | 18 | KEY rd_ns_title (rd_namespace,rd_title,rd_from) |
| 19 | | -) TYPE=InnoDB; |
| | 19 | +) /*$wgDBTableOptions*/; |
| 20 | 20 | |
| 21 | 21 | -- Import existing redirects |
| 22 | 22 | -- Using ignore because some of the redirect pages contain more than one link |
| Index: trunk/phase3/maintenance/archives/patch-transcache.sql |
| — | — | @@ -3,5 +3,5 @@ |
| 4 | 4 | tc_contents TEXT, |
| 5 | 5 | tc_time INT NOT NULL, |
| 6 | 6 | UNIQUE INDEX tc_url_idx(tc_url) |
| 7 | | -) TYPE=InnoDB; |
| | 7 | +) /*$wgDBTableOptions*/; |
| 8 | 8 | |
| Index: trunk/phase3/maintenance/archives/patch-parsercache.sql |
| — | — | @@ -12,4 +12,4 @@ |
| 13 | 13 | PRIMARY KEY (pc_pageid, pc_prefhash), |
| 14 | 14 | KEY(pc_title), |
| 15 | 15 | KEY(pc_expire) |
| 16 | | -) TYPE=InnoDB; |
| | 16 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-logging.sql |
| — | — | @@ -29,7 +29,7 @@ |
| 30 | 30 | KEY user_time (log_user, log_timestamp), |
| 31 | 31 | KEY page_time (log_namespace, log_title, log_timestamp) |
| 32 | 32 | |
| 33 | | -) TYPE=InnoDB; |
| | 33 | +) /*$wgDBTableOptions*/; |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | -- Change from unsigned to signed so we can store special pages |
| Index: trunk/phase3/maintenance/archives/patch-ipb_anon_only.sql |
| — | — | @@ -30,7 +30,7 @@ |
| 31 | 31 | INDEX ipb_timestamp (ipb_timestamp), |
| 32 | 32 | INDEX ipb_expiry (ipb_expiry) |
| 33 | 33 | |
| 34 | | -) TYPE=InnoDB; |
| | 34 | +) /*$wgDBTableOptions*/; |
| 35 | 35 | |
| 36 | 36 | INSERT IGNORE INTO /*$wgDBprefix*/ipblocks_newunique |
| 37 | 37 | (ipb_id, ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry, ipb_range_start, ipb_range_end, ipb_anon_only, ipb_create_account) |
| Index: trunk/phase3/maintenance/archives/patch-linktables.sql |
| — | — | @@ -16,7 +16,7 @@ |
| 17 | 17 | UNIQUE KEY l_from(l_from,l_to), |
| 18 | 18 | KEY (l_to) |
| 19 | 19 | |
| 20 | | -) TYPE=InnoDB; |
| | 20 | +) /*$wgDBTableOptions*/; |
| 21 | 21 | |
| 22 | 22 | -- |
| 23 | 23 | -- Track links to pages that don't yet exist. |
| — | — | @@ -35,7 +35,7 @@ |
| 36 | 36 | UNIQUE KEY bl_from(bl_from,bl_to), |
| 37 | 37 | KEY (bl_to) |
| 38 | 38 | |
| 39 | | -) TYPE=InnoDB; |
| | 39 | +) /*$wgDBTableOptions*/; |
| 40 | 40 | |
| 41 | 41 | -- |
| 42 | 42 | -- Track links to images *used inline* |
| — | — | @@ -55,7 +55,7 @@ |
| 56 | 56 | UNIQUE KEY il_from(il_from,il_to), |
| 57 | 57 | KEY (il_to) |
| 58 | 58 | |
| 59 | | -) TYPE=InnoDB; |
| | 59 | +) /*$wgDBTableOptions*/; |
| 60 | 60 | |
| 61 | 61 | -- |
| 62 | 62 | -- Stores (possibly gzipped) serialized objects with |
| — | — | @@ -67,4 +67,4 @@ |
| 68 | 68 | lcc_pageid INT UNSIGNED NOT NULL UNIQUE KEY, |
| 69 | 69 | lcc_cacheobj MEDIUMBLOB NOT NULL |
| 70 | 70 | |
| 71 | | -) TYPE=InnoDB; |
| | 71 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-math.sql |
| — | — | @@ -25,4 +25,4 @@ |
| 26 | 26 | |
| 27 | 27 | UNIQUE KEY math_inputhash (math_inputhash) |
| 28 | 28 | |
| 29 | | -) TYPE=InnoDB; |
| | 29 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-pagelinks.sql |
| — | — | @@ -30,7 +30,7 @@ |
| 31 | 31 | UNIQUE KEY pl_from(pl_from,pl_namespace,pl_title), |
| 32 | 32 | KEY (pl_namespace,pl_title) |
| 33 | 33 | |
| 34 | | -) TYPE=InnoDB; |
| | 34 | +) /*$wgDBTableOptions*/; |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | -- Import existing-page links |
| Index: trunk/phase3/maintenance/archives/patch-filearchive.sql |
| — | — | @@ -48,4 +48,4 @@ |
| 49 | 49 | INDEX (fa_deleted_timestamp), -- sort by deletion time |
| 50 | 50 | INDEX (fa_deleted_user) -- sort by deleter |
| 51 | 51 | |
| 52 | | -) TYPE=InnoDB; |
| | 52 | +) /*$wgDBTableOptions*/; |
| Index: trunk/phase3/maintenance/archives/patch-langlinks.sql |
| — | — | @@ -10,5 +10,5 @@ |
| 11 | 11 | |
| 12 | 12 | UNIQUE KEY (ll_from, ll_lang), |
| 13 | 13 | KEY (ll_lang, ll_title) |
| 14 | | -) TYPE=InnoDB; |
| | 14 | +) /*$wgDBTableOptions*/; |
| 15 | 15 | |
| Index: trunk/phase3/maintenance/sql.php |
| — | — | @@ -0,0 +1,67 @@ |
| | 2 | +<?php |
| | 3 | + |
| | 4 | +/** |
| | 5 | + * Send SQL queries from the specified file to the database, performing |
| | 6 | + * variable replacement along the way. |
| | 7 | + */ |
| | 8 | + |
| | 9 | +require_once( dirname(__FILE__) . '/' . 'commandLine.inc' ); |
| | 10 | + |
| | 11 | +if ( isset( $options['help'] ) ) { |
| | 12 | + echo "Send SQL queries to a MediaWiki database.\nUsage: php sql.php [<file>]\n"; |
| | 13 | + exit( 1 ); |
| | 14 | +} |
| | 15 | + |
| | 16 | +if ( isset( $args[0] ) ) { |
| | 17 | + $fileName = $args[0]; |
| | 18 | + $file = fopen( $fileName, 'r' ); |
| | 19 | + $promptCallback = false; |
| | 20 | +} else { |
| | 21 | + $file = STDIN; |
| | 22 | + $promptObject = new SqlPromptPrinter( "> " ); |
| | 23 | + $promptCallback = $promptObject->cb(); |
| | 24 | +} |
| | 25 | + |
| | 26 | +if ( !$file ) { |
| | 27 | + echo "Unable to open input file\n"; |
| | 28 | + exit( 1 ); |
| | 29 | +} |
| | 30 | + |
| | 31 | +$dbw =& wfGetDB( DB_MASTER ); |
| | 32 | +$error = $dbw->sourceStream( $file, $promptCallback, 'sqlPrintResult' ); |
| | 33 | +if ( $error !== true ) { |
| | 34 | + echo $error; |
| | 35 | + exit( 1 ); |
| | 36 | +} else { |
| | 37 | + exit( 0 ); |
| | 38 | +} |
| | 39 | + |
| | 40 | +//----------------------------------------------------------------------------- |
| | 41 | +class SqlPromptPrinter { |
| | 42 | + function __construct( $prompt ) { |
| | 43 | + $this->prompt = $prompt; |
| | 44 | + } |
| | 45 | + |
| | 46 | + function cb() { |
| | 47 | + return array( $this, 'printPrompt' ); |
| | 48 | + } |
| | 49 | + |
| | 50 | + function printPrompt() { |
| | 51 | + echo $this->prompt; |
| | 52 | + } |
| | 53 | +} |
| | 54 | + |
| | 55 | +function sqlPrintResult( $res ) { |
| | 56 | + if ( !$res ) { |
| | 57 | + // Do nothing |
| | 58 | + } elseif ( $res->numRows() ) { |
| | 59 | + while ( $row = $res->fetchObject() ) { |
| | 60 | + print_r( $row ); |
| | 61 | + } |
| | 62 | + } else { |
| | 63 | + $affected = $res->db->affectedRows(); |
| | 64 | + echo "Query OK, $affected row(s) affected\n"; |
| | 65 | + } |
| | 66 | +} |
| | 67 | + |
| | 68 | +?> |
| Property changes on: trunk/phase3/maintenance/sql.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 69 | + native |
| Index: trunk/phase3/maintenance/tables.sql |
| — | — | @@ -130,7 +130,7 @@ |
| 131 | 131 | UNIQUE INDEX user_name (user_name), |
| 132 | 132 | INDEX (user_email_token) |
| 133 | 133 | |
| 134 | | -) TYPE=InnoDB; |
| | 134 | +) /*$wgDBTableOptions*/; |
| 135 | 135 | |
| 136 | 136 | -- |
| 137 | 137 | -- User permissions have been broken out to a separate table; |
| — | — | @@ -156,7 +156,7 @@ |
| 157 | 157 | |
| 158 | 158 | PRIMARY KEY (ug_user,ug_group), |
| 159 | 159 | KEY (ug_group) |
| 160 | | -) TYPE=InnoDB; |
| | 160 | +) /*$wgDBTableOptions*/; |
| 161 | 161 | |
| 162 | 162 | -- Stores notifications of user talk page changes, for the display |
| 163 | 163 | -- of the "you have new messages" box |
| — | — | @@ -169,7 +169,7 @@ |
| 170 | 170 | INDEX user_id (user_id), |
| 171 | 171 | INDEX user_ip (user_ip) |
| 172 | 172 | |
| 173 | | -) TYPE=InnoDB; |
| | 173 | +) /*$wgDBTableOptions*/; |
| 174 | 174 | |
| 175 | 175 | |
| 176 | 176 | -- |
| — | — | @@ -229,7 +229,7 @@ |
| 230 | 230 | INDEX (page_random), |
| 231 | 231 | INDEX (page_len) |
| 232 | 232 | |
| 233 | | -) TYPE=InnoDB; |
| | 233 | +) /*$wgDBTableOptions*/; |
| 234 | 234 | |
| 235 | 235 | -- |
| 236 | 236 | -- Every edit of a page creates also a revision row. |
| — | — | @@ -284,7 +284,7 @@ |
| 285 | 285 | INDEX user_timestamp (rev_user,rev_timestamp), |
| 286 | 286 | INDEX usertext_timestamp (rev_user_text,rev_timestamp) |
| 287 | 287 | |
| 288 | | -) TYPE=InnoDB MAX_ROWS=10000000 AVG_ROW_LENGTH=1024; |
| | 288 | +) /*$wgDBTableOptions*/ MAX_ROWS=10000000 AVG_ROW_LENGTH=1024; |
| 289 | 289 | -- In case tables are created as MyISAM, use row hints for MySQL <5.0 to avoid 4GB limit |
| 290 | 290 | |
| 291 | 291 | -- |
| — | — | @@ -320,7 +320,7 @@ |
| 321 | 321 | |
| 322 | 322 | PRIMARY KEY old_id (old_id) |
| 323 | 323 | |
| 324 | | -) TYPE=InnoDB MAX_ROWS=10000000 AVG_ROW_LENGTH=10240; |
| | 324 | +) /*$wgDBTableOptions*/ MAX_ROWS=10000000 AVG_ROW_LENGTH=10240; |
| 325 | 325 | -- In case tables are created as MyISAM, use row hints for MySQL <5.0 to avoid 4GB limit |
| 326 | 326 | |
| 327 | 327 | -- |
| — | — | @@ -379,7 +379,7 @@ |
| 380 | 380 | |
| 381 | 381 | KEY name_title_timestamp (ar_namespace,ar_title,ar_timestamp) |
| 382 | 382 | |
| 383 | | -) TYPE=InnoDB; |
| | 383 | +) /*$wgDBTableOptions*/; |
| 384 | 384 | |
| 385 | 385 | |
| 386 | 386 | -- |
| — | — | @@ -399,7 +399,7 @@ |
| 400 | 400 | UNIQUE KEY pl_from (pl_from,pl_namespace,pl_title), |
| 401 | 401 | KEY (pl_namespace,pl_title,pl_from) |
| 402 | 402 | |
| 403 | | -) TYPE=InnoDB; |
| | 403 | +) /*$wgDBTableOptions*/; |
| 404 | 404 | |
| 405 | 405 | |
| 406 | 406 | -- |
| — | — | @@ -419,7 +419,7 @@ |
| 420 | 420 | UNIQUE KEY tl_from (tl_from,tl_namespace,tl_title), |
| 421 | 421 | KEY (tl_namespace,tl_title,tl_from) |
| 422 | 422 | |
| 423 | | -) TYPE=InnoDB; |
| | 423 | +) /*$wgDBTableOptions*/; |
| 424 | 424 | |
| 425 | 425 | -- |
| 426 | 426 | -- Track links to images *used inline* |
| — | — | @@ -438,7 +438,7 @@ |
| 439 | 439 | UNIQUE KEY il_from (il_from,il_to), |
| 440 | 440 | KEY (il_to,il_from) |
| 441 | 441 | |
| 442 | | -) TYPE=InnoDB; |
| | 442 | +) /*$wgDBTableOptions*/; |
| 443 | 443 | |
| 444 | 444 | -- |
| 445 | 445 | -- Track category inclusions *used inline* |
| — | — | @@ -478,7 +478,7 @@ |
| 479 | 479 | -- Not really used? |
| 480 | 480 | KEY cl_timestamp (cl_to,cl_timestamp) |
| 481 | 481 | |
| 482 | | -) TYPE=InnoDB; |
| | 482 | +) /*$wgDBTableOptions*/; |
| 483 | 483 | |
| 484 | 484 | -- |
| 485 | 485 | -- Track links to external URLs |
| — | — | @@ -506,7 +506,7 @@ |
| 507 | 507 | KEY (el_from, el_to(40)), |
| 508 | 508 | KEY (el_to(60), el_from), |
| 509 | 509 | KEY (el_index(60)) |
| 510 | | -) TYPE=InnoDB; |
| | 510 | +) /*$wgDBTableOptions*/; |
| 511 | 511 | |
| 512 | 512 | -- |
| 513 | 513 | -- Track interlanguage links |
| — | — | @@ -523,7 +523,7 @@ |
| 524 | 524 | |
| 525 | 525 | UNIQUE KEY (ll_from, ll_lang), |
| 526 | 526 | KEY (ll_lang, ll_title) |
| 527 | | -) TYPE=InnoDB; |
| | 527 | +) /*$wgDBTableOptions*/; |
| 528 | 528 | |
| 529 | 529 | -- |
| 530 | 530 | -- Contains a single row with some aggregate info |
| — | — | @@ -560,7 +560,7 @@ |
| 561 | 561 | |
| 562 | 562 | UNIQUE KEY ss_row_id (ss_row_id) |
| 563 | 563 | |
| 564 | | -) TYPE=InnoDB; |
| | 564 | +) /*$wgDBTableOptions*/; |
| 565 | 565 | |
| 566 | 566 | -- |
| 567 | 567 | -- Stores an ID for every time any article is visited; |
| — | — | @@ -634,7 +634,7 @@ |
| 635 | 635 | INDEX ipb_timestamp (ipb_timestamp), |
| 636 | 636 | INDEX ipb_expiry (ipb_expiry) |
| 637 | 637 | |
| 638 | | -) TYPE=InnoDB; |
| | 638 | +) /*$wgDBTableOptions*/; |
| 639 | 639 | |
| 640 | 640 | |
| 641 | 641 | -- |
| — | — | @@ -691,7 +691,7 @@ |
| 692 | 692 | -- Used by Special:Newimages and Special:Imagelist |
| 693 | 693 | INDEX img_timestamp (img_timestamp) |
| 694 | 694 | |
| 695 | | -) TYPE=InnoDB; |
| | 695 | +) /*$wgDBTableOptions*/; |
| 696 | 696 | |
| 697 | 697 | -- |
| 698 | 698 | -- Previous revisions of uploaded files. |
| — | — | @@ -718,7 +718,7 @@ |
| 719 | 719 | |
| 720 | 720 | INDEX oi_name (oi_name(10)) |
| 721 | 721 | |
| 722 | | -) TYPE=InnoDB; |
| | 722 | +) /*$wgDBTableOptions*/; |
| 723 | 723 | |
| 724 | 724 | -- |
| 725 | 725 | -- Record of deleted file data |
| — | — | @@ -773,7 +773,7 @@ |
| 774 | 774 | INDEX (fa_deleted_timestamp), -- sort by deletion time |
| 775 | 775 | INDEX (fa_deleted_user) -- sort by deleter |
| 776 | 776 | |
| 777 | | -) TYPE=InnoDB; |
| | 777 | +) /*$wgDBTableOptions*/; |
| 778 | 778 | |
| 779 | 779 | -- |
| 780 | 780 | -- Primarily a summary table for Special:Recentchanges, |
| — | — | @@ -856,7 +856,7 @@ |
| 857 | 857 | INDEX rc_ns_usertext (rc_namespace, rc_user_text), |
| 858 | 858 | INDEX rc_user_text (rc_user_text, rc_timestamp) |
| 859 | 859 | |
| 860 | | -) TYPE=InnoDB; |
| | 860 | +) /*$wgDBTableOptions*/; |
| 861 | 861 | |
| 862 | 862 | CREATE TABLE /*$wgDBprefix*/watchlist ( |
| 863 | 863 | -- Key to user.user_id |
| — | — | @@ -875,7 +875,7 @@ |
| 876 | 876 | UNIQUE KEY (wl_user, wl_namespace, wl_title), |
| 877 | 877 | KEY namespace_title (wl_namespace, wl_title) |
| 878 | 878 | |
| 879 | | -) TYPE=InnoDB; |
| | 879 | +) /*$wgDBTableOptions*/; |
| 880 | 880 | |
| 881 | 881 | |
| 882 | 882 | -- |
| — | — | @@ -901,7 +901,7 @@ |
| 902 | 902 | |
| 903 | 903 | UNIQUE KEY math_inputhash (math_inputhash) |
| 904 | 904 | |
| 905 | | -) TYPE=InnoDB; |
| | 905 | +) /*$wgDBTableOptions*/; |
| 906 | 906 | |
| 907 | 907 | -- |
| 908 | 908 | -- When using the default MySQL search backend, page titles |
| — | — | @@ -948,7 +948,7 @@ |
| 949 | 949 | |
| 950 | 950 | UNIQUE KEY iw_prefix (iw_prefix) |
| 951 | 951 | |
| 952 | | -) TYPE=InnoDB; |
| | 952 | +) /*$wgDBTableOptions*/; |
| 953 | 953 | |
| 954 | 954 | -- |
| 955 | 955 | -- Used for caching expensive grouped queries |
| — | — | @@ -966,7 +966,7 @@ |
| 967 | 967 | |
| 968 | 968 | KEY (qc_type,qc_value) |
| 969 | 969 | |
| 970 | | -) TYPE=InnoDB; |
| | 970 | +) /*$wgDBTableOptions*/; |
| 971 | 971 | |
| 972 | 972 | -- |
| 973 | 973 | -- For a few generic cache operations if not using Memcached |
| — | — | @@ -978,7 +978,7 @@ |
| 979 | 979 | UNIQUE KEY (keyname), |
| 980 | 980 | KEY (exptime) |
| 981 | 981 | |
| 982 | | -) TYPE=InnoDB; |
| | 982 | +) /*$wgDBTableOptions*/; |
| 983 | 983 | |
| 984 | 984 | -- |
| 985 | 985 | -- Cache of interwiki transclusion |
| — | — | @@ -988,7 +988,7 @@ |
| 989 | 989 | tc_contents text, |
| 990 | 990 | tc_time int NOT NULL, |
| 991 | 991 | UNIQUE INDEX tc_url_idx (tc_url) |
| 992 | | -) TYPE=InnoDB; |
| | 992 | +) /*$wgDBTableOptions*/; |
| 993 | 993 | |
| 994 | 994 | CREATE TABLE /*$wgDBprefix*/logging ( |
| 995 | 995 | -- Symbolic keys for the general log type and the action type |
| — | — | @@ -1026,7 +1026,7 @@ |
| 1027 | 1027 | KEY page_time (log_namespace, log_title, log_timestamp), |
| 1028 | 1028 | KEY times (log_timestamp) |
| 1029 | 1029 | |
| 1030 | | -) TYPE=InnoDB; |
| | 1030 | +) /*$wgDBTableOptions*/; |
| 1031 | 1031 | |
| 1032 | 1032 | CREATE TABLE /*$wgDBprefix*/trackbacks ( |
| 1033 | 1033 | tb_id int auto_increment, |
| — | — | @@ -1038,7 +1038,7 @@ |
| 1039 | 1039 | |
| 1040 | 1040 | PRIMARY KEY (tb_id), |
| 1041 | 1041 | INDEX (tb_page) |
| 1042 | | -) TYPE=InnoDB; |
| | 1042 | +) /*$wgDBTableOptions*/; |
| 1043 | 1043 | |
| 1044 | 1044 | |
| 1045 | 1045 | -- Jobs performed by parallel apache threads or a command-line daemon |
| — | — | @@ -1059,7 +1059,7 @@ |
| 1060 | 1060 | |
| 1061 | 1061 | PRIMARY KEY job_id (job_id), |
| 1062 | 1062 | KEY (job_cmd, job_namespace, job_title) |
| 1063 | | -) TYPE=InnoDB; |
| | 1063 | +) /*$wgDBTableOptions*/; |
| 1064 | 1064 | |
| 1065 | 1065 | |
| 1066 | 1066 | -- Details of updates to cached special pages |
| — | — | @@ -1074,7 +1074,7 @@ |
| 1075 | 1075 | |
| 1076 | 1076 | UNIQUE KEY ( qci_type ) |
| 1077 | 1077 | |
| 1078 | | -) TYPE=InnoDB; |
| | 1078 | +) /*$wgDBTableOptions*/; |
| 1079 | 1079 | |
| 1080 | 1080 | -- For each redirect, this table contains exactly one row defining its target |
| 1081 | 1081 | CREATE TABLE /*$wgDBprefix*/redirect ( |
| — | — | @@ -1090,7 +1090,7 @@ |
| 1091 | 1091 | |
| 1092 | 1092 | PRIMARY KEY rd_from (rd_from), |
| 1093 | 1093 | KEY rd_ns_title (rd_namespace,rd_title,rd_from) |
| 1094 | | -) TYPE=InnoDB; |
| | 1094 | +) /*$wgDBTableOptions*/; |
| 1095 | 1095 | |
| 1096 | 1096 | -- Used for caching expensive grouped queries that need two links (for example double-redirects) |
| 1097 | 1097 | CREATE TABLE /*$wgDBprefix*/querycachetwo ( |
| — | — | @@ -1112,7 +1112,7 @@ |
| 1113 | 1113 | KEY qcc_title (qcc_type,qcc_namespace,qcc_title), |
| 1114 | 1114 | KEY qcc_titletwo (qcc_type,qcc_namespacetwo,qcc_titletwo) |
| 1115 | 1115 | |
| 1116 | | -) TYPE=InnoDB; |
| | 1116 | +) /*$wgDBTableOptions*/; |
| 1117 | 1117 | |
| 1118 | 1118 | --- Used for storing page restrictions (i.e. protection levels) |
| 1119 | 1119 | CREATE TABLE /*$wgDBprefix*/page_restrictions ( |
| — | — | @@ -1138,6 +1138,6 @@ |
| 1139 | 1139 | KEY pr_typelevel (pr_type,pr_level), |
| 1140 | 1140 | KEY pr_level (pr_level), |
| 1141 | 1141 | KEY pr_cascade (pr_cascade) |
| 1142 | | -) TYPE=InnoDB; |
| | 1142 | +) /*$wgDBTableOptions*/; |
| 1143 | 1143 | |
| 1144 | 1144 | -- vim: sw=2 sts=2 et |
| Index: trunk/phase3/includes/DefaultSettings.php |
| — | — | @@ -505,8 +505,12 @@ |
| 506 | 506 | $wgSearchType = null; |
| 507 | 507 | /** Table name prefix */ |
| 508 | 508 | $wgDBprefix = ''; |
| | 509 | +/** MySQL table options to use during installation or update */ |
| | 510 | +$wgDBTableOptions = 'TYPE=InnoDB'; |
| | 511 | + |
| 509 | 512 | /**#@-*/ |
| 510 | 513 | |
| | 514 | + |
| 511 | 515 | /** Live high performance sites should disable this - some checks acquire giant mysql locks */ |
| 512 | 516 | $wgCheckDBSchema = true; |
| 513 | 517 | |
| — | — | @@ -1168,6 +1172,7 @@ |
| 1169 | 1173 | $wgEnotifRevealEditorAddress = false; # UPO; reply-to address may be filled with page editor's address (if user allowed this in the preferences) |
| 1170 | 1174 | $wgEnotifMinorEdits = true; # UPO; false: "minor edits" on pages do not trigger notification mails. |
| 1171 | 1175 | # # Attention: _every_ change on a user_talk page trigger a notification mail (if the user is not yet notified) |
| | 1176 | +$wgUsersNotifedOnAllChanges = array(); |
| 1172 | 1177 | |
| 1173 | 1178 | /** Show watching users in recent changes, watchlist and page history views */ |
| 1174 | 1179 | $wgRCShowWatchingUsers = false; # UPO |
| Index: trunk/phase3/includes/Database.php |
| — | — | @@ -610,12 +610,19 @@ |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | if ( $success ) { |
| 614 | | - global $wgDBmysql5; |
| 615 | | - if( $wgDBmysql5 ) { |
| | 614 | + $version = $this->getServerVersion(); |
| | 615 | + if ( version_compare( $version, '4.1' ) >= 0 ) { |
| 616 | 616 | // Tell the server we're communicating with it in UTF-8. |
| 617 | 617 | // This may engage various charset conversions. |
| 618 | | - $this->query( 'SET NAMES utf8' ); |
| | 618 | + global $wgDBmysql5; |
| | 619 | + if( $wgDBmysql5 ) { |
| | 620 | + $this->query( 'SET NAMES utf8', __METHOD__ ); |
| | 621 | + } |
| | 622 | + // Turn off strict mode |
| | 623 | + $this->query( "SET sql_mode = ''", __METHOD__ ); |
| 619 | 624 | } |
| | 625 | + |
| | 626 | + // Turn off strict mode if it is on |
| 620 | 627 | } else { |
| 621 | 628 | $this->reportConnectionError(); |
| 622 | 629 | } |
| — | — | @@ -2098,18 +2105,36 @@ |
| 2099 | 2106 | /** |
| 2100 | 2107 | * Read and execute SQL commands from a file. |
| 2101 | 2108 | * Returns true on success, error string on failure |
| | 2109 | + * @param string $filename File name to open |
| | 2110 | + * @param callback $lineCallback Optional function called before reading each line |
| | 2111 | + * @param callback $resultCallback Optional function called for each MySQL result |
| 2102 | 2112 | */ |
| 2103 | | - function sourceFile( $filename ) { |
| | 2113 | + function sourceFile( $filename, $lineCallback = false, $resultCallback = false ) { |
| 2104 | 2114 | $fp = fopen( $filename, 'r' ); |
| 2105 | 2115 | if ( false === $fp ) { |
| 2106 | 2116 | return "Could not open \"{$filename}\".\n"; |
| 2107 | 2117 | } |
| | 2118 | + $error = $this->sourceStream( $fp, $lineCallback, $resultCallback ); |
| | 2119 | + fclose( $fp ); |
| | 2120 | + return $error; |
| | 2121 | + } |
| 2108 | 2122 | |
| | 2123 | + /** |
| | 2124 | + * Read and execute commands from an open file handle |
| | 2125 | + * Returns true on success, error string on failure |
| | 2126 | + * @param string $fp File handle |
| | 2127 | + * @param callback $lineCallback Optional function called before reading each line |
| | 2128 | + * @param callback $resultCallback Optional function called for each MySQL result |
| | 2129 | + */ |
| | 2130 | + function sourceStream( $fp, $lineCallback = false, $resultCallback = false ) { |
| 2109 | 2131 | $cmd = ""; |
| 2110 | 2132 | $done = false; |
| 2111 | 2133 | $dollarquote = false; |
| 2112 | 2134 | |
| 2113 | 2135 | while ( ! feof( $fp ) ) { |
| | 2136 | + if ( $lineCallback ) { |
| | 2137 | + call_user_func( $lineCallback ); |
| | 2138 | + } |
| 2114 | 2139 | $line = trim( fgets( $fp, 1024 ) ); |
| 2115 | 2140 | $sl = strlen( $line ) - 1; |
| 2116 | 2141 | |
| — | — | @@ -2139,7 +2164,10 @@ |
| 2140 | 2165 | if ( $done ) { |
| 2141 | 2166 | $cmd = str_replace(';;', ";", $cmd); |
| 2142 | 2167 | $cmd = $this->replaceVars( $cmd ); |
| 2143 | | - $res = $this->query( $cmd, 'dbsource', true ); |
| | 2168 | + $res = $this->query( $cmd, __METHOD__, true ); |
| | 2169 | + if ( $resultCallback ) { |
| | 2170 | + call_user_func( $resultCallback, $this->resultObject( $res ) ); |
| | 2171 | + } |
| 2144 | 2172 | |
| 2145 | 2173 | if ( false === $res ) { |
| 2146 | 2174 | $err = $this->lastError(); |
| — | — | @@ -2150,10 +2178,10 @@ |
| 2151 | 2179 | $done = false; |
| 2152 | 2180 | } |
| 2153 | 2181 | } |
| 2154 | | - fclose( $fp ); |
| 2155 | 2182 | return true; |
| 2156 | 2183 | } |
| 2157 | 2184 | |
| | 2185 | + |
| 2158 | 2186 | /** |
| 2159 | 2187 | * Replace variables in sourced SQL |
| 2160 | 2188 | */ |
| — | — | @@ -2161,7 +2189,7 @@ |
| 2162 | 2190 | $varnames = array( |
| 2163 | 2191 | 'wgDBserver', 'wgDBname', 'wgDBintlname', 'wgDBuser', |
| 2164 | 2192 | 'wgDBpassword', 'wgDBsqluser', 'wgDBsqlpassword', |
| 2165 | | - 'wgDBadminuser', 'wgDBadminpassword', |
| | 2193 | + 'wgDBadminuser', 'wgDBadminpassword', 'wgDBTableOptions', |
| 2166 | 2194 | ); |
| 2167 | 2195 | |
| 2168 | 2196 | // Ordinary variables |
| Index: trunk/phase3/config/index.php |
| — | — | @@ -226,6 +226,26 @@ |
| 227 | 227 | function getSitename() { return $this->getEncoded( $this->Sitename ); } |
| 228 | 228 | function getSysopName() { return $this->getEncoded( $this->SysopName ); } |
| 229 | 229 | function getSysopPass() { return $this->getEncoded( $this->SysopPass ); } |
| | 230 | + |
| | 231 | + function setSchema( $schema ) { |
| | 232 | + $this->DBschema = $schema; |
| | 233 | + switch ( $this->DBschema ) { |
| | 234 | + case 'mysql5': |
| | 235 | + $this->DBTableOptions = 'ENGINE=InnoDB, DEFAULT CHARSET=utf8'; |
| | 236 | + $this->DBmysql5 = 'true'; |
| | 237 | + break; |
| | 238 | + case 'mysql5-binary': |
| | 239 | + $this->DBTableOptions = 'ENGINE=InnoDB, DEFAULT CHARSET=binary'; |
| | 240 | + $this->DBmysql5 = 'true'; |
| | 241 | + break; |
| | 242 | + default: |
| | 243 | + $this->DBTableOptions = 'TYPE=InnoDB'; |
| | 244 | + $this->DBmysql5 = 'false'; |
| | 245 | + } |
| | 246 | + # Set the global for use during install |
| | 247 | + global $wgDBTableOptions; |
| | 248 | + $wgDBTableOptions = $this->DBTableOptions; |
| | 249 | + } |
| 230 | 250 | } |
| 231 | 251 | |
| 232 | 252 | ?> |
| — | — | @@ -522,10 +542,7 @@ |
| 523 | 543 | |
| 524 | 544 | ## MySQL specific: |
| 525 | 545 | $conf->DBprefix = importPost( "DBprefix" ); |
| 526 | | - $conf->DBschema = importPost( "DBschema", "mysql4" ); |
| 527 | | - $conf->DBmysql5 = ($conf->DBschema == "mysql5" || |
| 528 | | - $conf->DBschema == "mysql5-binary") |
| 529 | | - ? "true" : "false"; |
| | 546 | + $conf->setSchema( importPost( "DBschema", "mysql4" ) ); |
| 530 | 547 | $conf->LanguageCode = importPost( "LanguageCode", "en" ); |
| 531 | 548 | |
| 532 | 549 | ## Postgres specific: |
| — | — | @@ -813,6 +830,32 @@ |
| 814 | 831 | if( $wgDatabase->tableExists( "cur" ) || $wgDatabase->tableExists( "revision" ) ) { |
| 815 | 832 | print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n"; |
| 816 | 833 | |
| | 834 | + # Determine existing default character set |
| | 835 | + if ( $wgDatabase->tableExists( "revision" ) ) { |
| | 836 | + $revision = $wgDatabase->escapeLike( $conf->DBprefix . 'revision' ); |
| | 837 | + $res = $wgDatabase->query( "SHOW TABLE STATUS LIKE '$revision'" ); |
| | 838 | + $row = $wgDatabase->fetchObject( $res ); |
| | 839 | + if ( !$row ) { |
| | 840 | + echo "<li>SHOW TABLE STATUS query failed!</li>\n"; |
| | 841 | + $existingSchema = false; |
| | 842 | + } elseif ( preg_match( '/^latin1/', $row->Collation ) ) { |
| | 843 | + $existingSchema = 'mysql4'; |
| | 844 | + } elseif ( preg_match( '/^utf8/', $row->Collation ) ) { |
| | 845 | + $existingSchema = 'mysql5'; |
| | 846 | + } elseif ( preg_match( '/^binary/', $row->Collation ) ) { |
| | 847 | + $existingSchema = 'mysql5-binary'; |
| | 848 | + } else { |
| | 849 | + $existingSchema = false; |
| | 850 | + echo "<li><strong>Warning:</strong> Unrecognised existing collation</li>\n"; |
| | 851 | + } |
| | 852 | + if ( $existingSchema && $existingSchema != $conf->DBschema ) { |
| | 853 | + print "<li><strong>Warning:</strong> you requested the {$conf->DBschema} schema, " . |
| | 854 | + "but the existing database has the $existingSchema schema. This upgrade script ". |
| | 855 | + "can't convert it, so it will remain $existingSchema.</li>\n"; |
| | 856 | + $conf->setSchema( $existingSchema ); |
| | 857 | + } |
| | 858 | + } |
| | 859 | + |
| 817 | 860 | # Create user if required (todo: other databases) |
| 818 | 861 | if ( $conf->Root && $conf->DBtype == 'mysql') { |
| 819 | 862 | $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); |
| — | — | @@ -828,33 +871,18 @@ |
| 829 | 872 | dbsource( "../maintenance/users.sql", $wgDatabase ); |
| 830 | 873 | } |
| 831 | 874 | } |
| 832 | | - print "<pre>\n"; |
| | 875 | + print "</ul><pre>\n"; |
| 833 | 876 | chdir( ".." ); |
| 834 | 877 | flush(); |
| 835 | 878 | do_all_updates(); |
| 836 | 879 | chdir( "config" ); |
| 837 | 880 | print "</pre>\n"; |
| 838 | | - print "<li>Finished update checks.</li>\n"; |
| | 881 | + print "<ul><li>Finished update checks.</li>\n"; |
| 839 | 882 | } else { |
| 840 | 883 | # FIXME: Check for errors |
| 841 | 884 | print "<li>Creating tables..."; |
| 842 | 885 | if ($conf->DBtype == 'mysql') { |
| 843 | | - switch( $conf->DBschema ) { |
| 844 | | - case "mysql4": |
| 845 | | - print " using MySQL 4 table defs..."; |
| 846 | | - dbsource( "../maintenance/tables.sql", $wgDatabase ); |
| 847 | | - break; |
| 848 | | - case "mysql5": |
| 849 | | - print " using MySQL 5 UTF-8 table defs..."; |
| 850 | | - dbsource( "../maintenance/mysql5/tables.sql", $wgDatabase ); |
| 851 | | - break; |
| 852 | | - case "mysql5-binary": |
| 853 | | - print " using MySQL 5 binary table defs..."; |
| 854 | | - dbsource( "../maintenance/mysql5/tables-binary.sql", $wgDatabase ); |
| 855 | | - break; |
| 856 | | - default: |
| 857 | | - dieout( " <b>invalid schema selection!</b></li>" ); |
| 858 | | - } |
| | 886 | + dbsource( "../maintenance/tables.sql", $wgDatabase ); |
| 859 | 887 | dbsource( "../maintenance/interwiki.sql", $wgDatabase ); |
| 860 | 888 | } else if ($conf->DBtype == 'postgres') { |
| 861 | 889 | $wgDatabase->setup_database(); |
| — | — | @@ -1431,6 +1459,9 @@ |
| 1432 | 1460 | \$wgDBport = \"{$slconf['DBport']}\"; |
| 1433 | 1461 | \$wgDBprefix = \"{$slconf['DBprefix']}\"; |
| 1434 | 1462 | |
| | 1463 | +# MySQL table options to use during installation or update |
| | 1464 | +\$wgDBTableOptions = \"{$slconf['DBTableOptions']}\"; |
| | 1465 | + |
| 1435 | 1466 | # Schemas for Postgres |
| 1436 | 1467 | \$wgDBmwschema = \"{$slconf['DBmwschema']}\"; |
| 1437 | 1468 | \$wgDBts2schema = \"{$slconf['DBts2schema']}\"; |