r89250 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89249‎ | r89250 | r89251 >
Date:08:27, 1 June 2011
Author:freakolowsky
Status:ok
Tags:
Comment:
* upgrade patches for oracle 1.17->1.19
* fixed tableExists to handle possible username-dbname difference
* added indexExists for updater
* fixed a bug in DatabaseUpdater
* tried not to produce bugs (may have failed)
Modified paths:
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/installer/DatabaseUpdater.php (modified) (history)
  • /trunk/phase3/includes/installer/OracleUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/oracle/archives/patch-config.sql (added) (history)
  • /trunk/phase3/maintenance/oracle/archives/patch-up_property.sql (added) (history)
  • /trunk/phase3/maintenance/oracle/archives/patch-user_email_index.sql (added) (history)
  • /trunk/phase3/maintenance/oracle/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/oracle/archives/patch-config.sql
@@ -0,0 +1,8 @@
 2+define mw_prefix='{$wgDBprefix}';
 3+
 4+CREATE TABLE &mw_prefix.config (
 5+ cf_name VARCHAR2(255) NOT NULL,
 6+ cf_value blob NOT NULL
 7+);
 8+ALTER TABLE &mw_prefix.config ADD CONSTRAINT &mw_prefix.config_pk PRIMARY KEY (cf_name);
 9+
Property changes on: trunk/phase3/maintenance/oracle/archives/patch-config.sql
___________________________________________________________________
Added: svn:eol-style
110 + native
Index: trunk/phase3/maintenance/oracle/archives/patch-up_property.sql
@@ -0,0 +1,3 @@
 2+define mw_prefix='{$wgDBprefix}';
 3+
 4+ALTER TABLE &mw_prefix.user_properties MODIFY up_property varchar2(255);
Property changes on: trunk/phase3/maintenance/oracle/archives/patch-up_property.sql
___________________________________________________________________
Added: svn:eol-style
15 + native
Index: trunk/phase3/maintenance/oracle/archives/patch-user_email_index.sql
@@ -0,0 +1,4 @@
 2+define mw_prefix='{$wgDBprefix}';
 3+
 4+CREATE INDEX &mw_prefix.mwuser_i02 ON &mw_prefix.mwuser (user_email, user_name);
 5+
Property changes on: trunk/phase3/maintenance/oracle/archives/patch-user_email_index.sql
___________________________________________________________________
Added: svn:eol-style
16 + native
Index: trunk/phase3/maintenance/oracle/tables.sql
@@ -23,6 +23,7 @@
2424 ALTER TABLE &mw_prefix.mwuser ADD CONSTRAINT &mw_prefix.mwuser_pk PRIMARY KEY (user_id);
2525 CREATE UNIQUE INDEX &mw_prefix.mwuser_u01 ON &mw_prefix.mwuser (user_name);
2626 CREATE INDEX &mw_prefix.mwuser_i01 ON &mw_prefix.mwuser (user_email_token);
 27+CREATE INDEX &mw_prefix.mwuser_i02 ON &mw_prefix.mwuser (user_email, user_name);
2728
2829 -- Create a dummy user to satisfy fk contraints especially with revisions
2930 INSERT INTO &mw_prefix.mwuser
@@ -47,7 +48,7 @@
4849
4950 CREATE TABLE &mw_prefix.user_properties (
5051 up_user NUMBER NOT NULL,
51 - up_property VARCHAR2(32) NOT NULL,
 52+ up_property VARCHAR2(255) NOT NULL,
5253 up_value CLOB
5354 );
5455 CREATE UNIQUE INDEX &mw_prefix.user_properties_u01 on &mw_prefix.user_properties (up_user,up_property);
@@ -636,6 +637,14 @@
637638 );
638639 CREATE UNIQUE INDEX &mw_prefix.module_deps_u01 ON &mw_prefix.module_deps (md_module, md_skin);
639640
 641+CREATE TABLE &mw_prefix.config (
 642+ cf_name VARCHAR2(255) NOT NULL,
 643+ cf_value blob NOT NULL
 644+);
 645+ALTER TABLE &mw_prefix.config ADD CONSTRAINT &mw_prefix.config_pk PRIMARY KEY (cf_name);
 646+-- leaving index out for now ...
 647+
 648+
640649 -- do not prefix this table as it breaks parserTests
641650 CREATE TABLE wiki_field_info_full (
642651 table_name VARCHAR2(35) NOT NULL,
Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -894,11 +894,32 @@
895895 }
896896
897897 /**
 898+ * Query whether a given index exists
 899+ */
 900+ function indexExists( $table, $index, $fname = 'DatabaseOracle::indexExists' ) {
 901+ $table = $this->tableName( $table );
 902+ $table = strtoupper( $this->removeIdentifierQuotes( $table ) );
 903+ $index = strtoupper( $index );
 904+ $owner = strtoupper( $this->mDBname );
 905+ $SQL = "SELECT 1 FROM all_indexes WHERE owner='$owner' AND index_name='{$table}_{$index}'";
 906+ $res = $this->doQuery( $SQL );
 907+ if ( $res ) {
 908+ $count = $res->numRows();
 909+ $res->free();
 910+ } else {
 911+ $count = 0;
 912+ }
 913+ return $count != 0;
 914+ }
 915+
 916+ /**
898917 * Query whether a given table exists (in the given schema, or the default mw one if not given)
899918 */
900919 function tableExists( $table ) {
901 - $table = $this->removeIdentifierQuotes($table);
902 - $SQL = "SELECT 1 FROM user_tables WHERE table_name='$table'";
 920+ $table = $this->tableName( $table );
 921+ $table = strtoupper( $this->removeIdentifierQuotes( $table ) );
 922+ $owner = strtoupper( $this->mDBname );
 923+ $SQL = "SELECT 1 FROM all_tables WHERE owner='$owner' AND table_name='$table'";
903924 $res = $this->doQuery( $SQL );
904925 if ( $res ) {
905926 $count = $res->numRows();
@@ -906,7 +927,7 @@
907928 } else {
908929 $count = 0;
909930 }
910 - return $count;
 931+ return $count != 0;
911932 }
912933
913934 /**
Index: trunk/phase3/includes/installer/DatabaseUpdater.php
@@ -65,7 +65,7 @@
6666 } else {
6767 $this->maintenance = new FakeMaintenance;
6868 }
69 - $maintenance->setDB( $db );
 69+ $this->maintenance->setDB( $db );
7070 $this->initOldGlobals();
7171 wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) );
7272 }
Index: trunk/phase3/includes/installer/OracleUpdater.php
@@ -23,12 +23,20 @@
2424
2525 protected function getCoreUpdateList() {
2626 return array(
27 - // 1.16
 27+ // 1.17
2828 array( 'doNamespaceDefaults' ),
2929 array( 'doFKRenameDeferr' ),
3030 array( 'doFunctions17' ),
3131 array( 'doSchemaUpgrade17' ),
3232 array( 'doInsertPage0' ),
 33+
 34+ //1.18
 35+ array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ),
 36+ array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ),
 37+
 38+ // 1.19
 39+ array( 'addTable', 'config', 'patch-config.sql' ),
 40+
3341 );
3442 }
3543

Follow-up revisions

RevisionCommit summaryAuthorDate
r89252* MFT r89250. only the tableExists function ad 1.17 already supports user-dbn...freakolowsky08:46, 1 June 2011

Status & tagging log