* upgrade patches for oracle 1.17->1.19
authorJure Kajzer <freakolowsky@users.mediawiki.org>
Wed, 1 Jun 2011 08:27:51 +0000 (08:27 +0000)
committerJure Kajzer <freakolowsky@users.mediawiki.org>
Wed, 1 Jun 2011 08:27:51 +0000 (08:27 +0000)
* 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)

includes/db/DatabaseOracle.php
includes/installer/DatabaseUpdater.php
includes/installer/OracleUpdater.php
maintenance/oracle/archives/patch-config.sql [new file with mode: 0644]
maintenance/oracle/archives/patch-up_property.sql [new file with mode: 0644]
maintenance/oracle/archives/patch-user_email_index.sql [new file with mode: 0644]
maintenance/oracle/tables.sql

index 8d86b6f..50ab4f2 100644 (file)
@@ -893,12 +893,33 @@ class DatabaseOracle extends DatabaseBase {
                return $row['version'];
        }
 
+       /**
+        * Query whether a given index exists
+        */
+       function indexExists( $table, $index, $fname = 'DatabaseOracle::indexExists' ) {
+               $table = $this->tableName( $table );
+               $table = strtoupper( $this->removeIdentifierQuotes( $table ) );
+               $index = strtoupper( $index );
+               $owner = strtoupper( $this->mDBname );
+               $SQL = "SELECT 1 FROM all_indexes WHERE owner='$owner' AND index_name='{$table}_{$index}'";
+               $res = $this->doQuery( $SQL );
+               if ( $res ) {
+                       $count = $res->numRows();
+                       $res->free();
+               } else {
+                       $count = 0;
+               }
+               return $count != 0;
+       }
+
        /**
         * Query whether a given table exists (in the given schema, or the default mw one if not given)
         */
        function tableExists( $table ) {
-               $table = $this->removeIdentifierQuotes($table);
-               $SQL = "SELECT 1 FROM user_tables WHERE table_name='$table'";
+               $table = $this->tableName( $table );
+               $table = strtoupper( $this->removeIdentifierQuotes( $table ) );
+               $owner = strtoupper( $this->mDBname );
+               $SQL = "SELECT 1 FROM all_tables WHERE owner='$owner' AND table_name='$table'";
                $res = $this->doQuery( $SQL );
                if ( $res ) {
                        $count = $res->numRows();
@@ -906,7 +927,7 @@ class DatabaseOracle extends DatabaseBase {
                } else {
                        $count = 0;
                }
-               return $count;
+               return $count != 0;
        }
 
        /**
index c931e34..00d2d69 100644 (file)
@@ -65,7 +65,7 @@ abstract class DatabaseUpdater {
                } else {
                        $this->maintenance = new FakeMaintenance;
                }
-               $maintenance->setDB( $db );
+               $this->maintenance->setDB( $db );
                $this->initOldGlobals();
                wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) );
        }
index 96aa2a0..2227198 100644 (file)
@@ -23,12 +23,20 @@ class OracleUpdater extends DatabaseUpdater {
 
        protected function getCoreUpdateList() {
                return array(
-                       // 1.16
+                       // 1.17
                        array( 'doNamespaceDefaults' ),
                        array( 'doFKRenameDeferr' ),
                        array( 'doFunctions17' ),
                        array( 'doSchemaUpgrade17' ),
                        array( 'doInsertPage0' ),
+                       
+                       //1.18
+                       array( 'addIndex',      'user',          'i02',       'patch-user_email_index.sql' ),
+                       array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ),
+
+                       // 1.19
+                       array( 'addTable', 'config', 'patch-config.sql' ),
+                       
                );
        }
 
diff --git a/maintenance/oracle/archives/patch-config.sql b/maintenance/oracle/archives/patch-config.sql
new file mode 100644 (file)
index 0000000..66714a7
--- /dev/null
@@ -0,0 +1,8 @@
+define mw_prefix='{$wgDBprefix}';
+
+CREATE TABLE &mw_prefix.config (
+  cf_name VARCHAR2(255) NOT NULL,
+  cf_value blob NOT NULL
+);
+ALTER TABLE &mw_prefix.config ADD CONSTRAINT &mw_prefix.config_pk PRIMARY KEY (cf_name);
+
diff --git a/maintenance/oracle/archives/patch-up_property.sql b/maintenance/oracle/archives/patch-up_property.sql
new file mode 100644 (file)
index 0000000..c8e2dd9
--- /dev/null
@@ -0,0 +1,3 @@
+define mw_prefix='{$wgDBprefix}';
+
+ALTER TABLE &mw_prefix.user_properties MODIFY up_property varchar2(255);
diff --git a/maintenance/oracle/archives/patch-user_email_index.sql b/maintenance/oracle/archives/patch-user_email_index.sql
new file mode 100644 (file)
index 0000000..975943c
--- /dev/null
@@ -0,0 +1,4 @@
+define mw_prefix='{$wgDBprefix}';
+
+CREATE INDEX &mw_prefix.mwuser_i02 ON &mw_prefix.mwuser (user_email, user_name);
+
index 7312bbe..d40b102 100644 (file)
@@ -23,6 +23,7 @@ CREATE TABLE &mw_prefix.mwuser ( -- replace reserved word 'user'
 ALTER TABLE &mw_prefix.mwuser ADD CONSTRAINT &mw_prefix.mwuser_pk PRIMARY KEY (user_id);
 CREATE UNIQUE INDEX &mw_prefix.mwuser_u01 ON &mw_prefix.mwuser (user_name);
 CREATE INDEX &mw_prefix.mwuser_i01 ON &mw_prefix.mwuser (user_email_token);
+CREATE INDEX &mw_prefix.mwuser_i02 ON &mw_prefix.mwuser (user_email, user_name);
 
 -- Create a dummy user to satisfy fk contraints especially with revisions
 INSERT INTO &mw_prefix.mwuser
@@ -47,7 +48,7 @@ CREATE INDEX &mw_prefix.user_newtalk_i02 ON &mw_prefix.user_newtalk (user_ip);
 
 CREATE TABLE &mw_prefix.user_properties (
   up_user NUMBER NOT NULL,
-  up_property VARCHAR2(32) NOT NULL,
+  up_property VARCHAR2(255) NOT NULL,
   up_value CLOB
 );
 CREATE UNIQUE INDEX &mw_prefix.user_properties_u01 on &mw_prefix.user_properties (up_user,up_property);
@@ -636,6 +637,14 @@ CREATE TABLE &mw_prefix.module_deps (
 );
 CREATE UNIQUE INDEX &mw_prefix.module_deps_u01 ON &mw_prefix.module_deps (md_module, md_skin);
 
+CREATE TABLE &mw_prefix.config (
+  cf_name VARCHAR2(255) NOT NULL,
+  cf_value blob NOT NULL
+);
+ALTER TABLE &mw_prefix.config ADD CONSTRAINT &mw_prefix.config_pk PRIMARY KEY (cf_name);
+-- leaving index out for now ... 
+
+
 -- do not prefix this table as it breaks parserTests
 CREATE TABLE wiki_field_info_full (
 table_name VARCHAR2(35) NOT NULL,