http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90585
Revision: 90585
Author: freakolowsky
Date: 2011-06-22 14:10:55 +0000 (Wed, 22 Jun 2011)
Log Message:
-----------
* removed DEFAULT '' NOT NULL constraints as '' is internaly converted to NULL
in Oracle and throws an error
* fixed tableName handling doSchemaUpgrade17 (must be careful to avoid multiple
tableName calls as names don't get taged in DDL mode)
* exit/reenter DDL mode on updatelog inserts
Modified Paths:
--------------
trunk/phase3/includes/installer/DatabaseUpdater.php
trunk/phase3/includes/installer/OracleUpdater.php
trunk/phase3/maintenance/oracle/tables.sql
Added Paths:
-----------
trunk/phase3/maintenance/oracle/archives/patch_remove_not_null_empty_defs.sql
Modified: trunk/phase3/includes/installer/DatabaseUpdater.php
===================================================================
--- trunk/phase3/includes/installer/DatabaseUpdater.php 2011-06-22 14:04:36 UTC
(rev 90584)
+++ trunk/phase3/includes/installer/DatabaseUpdater.php 2011-06-22 14:10:55 UTC
(rev 90585)
@@ -232,6 +232,7 @@
}
protected function setAppliedUpdates( $version, $updates = array() ) {
+ $this->db->clearFlag( DBO_DDLMODE );
if( !$this->canUseNewUpdatelog() ) {
return;
}
@@ -239,6 +240,7 @@
$this->db->insert( 'updatelog',
array( 'ul_key' => $key, 'ul_value' => serialize(
$updates ) ),
__METHOD__ );
+ $this->db->setFlag( DBO_DDLMODE );
}
/**
@@ -265,11 +267,13 @@
* @param $val String [optional] value to insert along with the key
*/
public function insertUpdateRow( $key, $val = null ) {
+ $this->db->clearFlag( DBO_DDLMODE );
$values = array( 'ul_key' => $key );
if( $val && $this->canUseNewUpdatelog() ) {
$values['ul_value'] = $val;
}
$this->db->insert( 'updatelog', $values, __METHOD__, 'IGNORE' );
+ $this->db->setFlag( DBO_DDLMODE );
}
/**
Modified: trunk/phase3/includes/installer/OracleUpdater.php
===================================================================
--- trunk/phase3/includes/installer/OracleUpdater.php 2011-06-22 14:04:36 UTC
(rev 90584)
+++ trunk/phase3/includes/installer/OracleUpdater.php 2011-06-22 14:10:55 UTC
(rev 90585)
@@ -29,6 +29,7 @@
array( 'doFunctions17' ),
array( 'doSchemaUpgrade17' ),
array( 'doInsertPage0' ),
+ array( 'doRemoveNotNullEmptyDefaults' ),
//1.18
array( 'addIndex', 'user', 'i02',
'patch-user_email_index.sql' ),
@@ -93,7 +94,7 @@
protected function doSchemaUpgrade17() {
$this->output( "Updating schema to 17 ... " );
// check if iwlinks table exists which was added in 1.17
- if ( $this->db->tableExists( $this->db->tableName( 'iwlinks' )
) ) {
+ if ( $this->db->tableExists( 'iwlinks' ) ) {
$this->output( "schema seem to be up to date.\n" );
return;
}
@@ -122,6 +123,20 @@
$this->output( "ok\n" );
}
+ /**
+ * Remove DEFAULT '' NOT NULL constraints from fields as '' is
internally
+ * converted to NULL in Oracle
+ */
+ protected function doRemoveNotNullEmptyDefaults() {
+ $this->output( "Removing not null empty constraints ... " );
+ $meta = $this->db->fieldInfo( 'categorylinks' ,
'cl_sortkey_prefix' );
+ if ( $meta->isNullable() ) {
+ $this->output( "constraints seem to be removed\n" );
+ return;
+ }
+ $this->applyPatch( 'patch_remove_not_null_empty_defs.sql',
false );
+ $this->output( "ok\n" );
+ }
/**
* rebuilding of the function that duplicates tables for tests
Added:
trunk/phase3/maintenance/oracle/archives/patch_remove_not_null_empty_defs.sql
===================================================================
---
trunk/phase3/maintenance/oracle/archives/patch_remove_not_null_empty_defs.sql
(rev 0)
+++
trunk/phase3/maintenance/oracle/archives/patch_remove_not_null_empty_defs.sql
2011-06-22 14:10:55 UTC (rev 90585)
@@ -0,0 +1,9 @@
+define mw_prefix='{$wgDBprefix}';
+
+ALTER TABLE &mw_prefix.categorylinks MODIFY cl_sortkey_prefix DEFAULT NULL
NULL;
+ALTER TABLE &mw_prefix.categorylinks MODIFY cl_collation DEFAULT NULL NULL;
+ALTER TABLE &mw_prefix.iwlinks MODIFY iwl_prefix DEFAULT NULL NULL;
+ALTER TABLE &mw_prefix.iwlinks MODIFY iwl_title DEFAULT NULL NULL;
+ALTER TABLE &mw_prefix.searchindex MODIFY si_title DEFAULT NULL NULL;
+ALTER TABLE &mw_prefix.querycachetwo MODIFY qcc_title DEFAULT NULL NULL;
+ALTER TABLE &mw_prefix.querycachetwo MODIFY qcc_titletwo DEFAULT NULL NULL;
Property changes on:
trunk/phase3/maintenance/oracle/archives/patch_remove_not_null_empty_defs.sql
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/phase3/maintenance/oracle/tables.sql
===================================================================
--- trunk/phase3/maintenance/oracle/tables.sql 2011-06-22 14:04:36 UTC (rev
90584)
+++ trunk/phase3/maintenance/oracle/tables.sql 2011-06-22 14:10:55 UTC (rev
90585)
@@ -27,7 +27,7 @@
-- Create a dummy user to satisfy fk contraints especially with revisions
INSERT INTO &mw_prefix.mwuser
- VALUES
(user_user_id_seq.nextval,'Anonymous','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
'', current_timestamp, current_timestamp, 0);
+ VALUES
(user_user_id_seq.nextval,'Anonymous',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
'', current_timestamp, current_timestamp, 0);
CREATE TABLE &mw_prefix.user_groups (
ug_user NUMBER DEFAULT 0 NOT NULL,
@@ -169,9 +169,9 @@
cl_from NUMBER NOT NULL,
cl_to VARCHAR2(255) NOT NULL,
cl_sortkey VARCHAR2(230),
- cl_sortkey_prefix VARCHAR2(255) DEFAULT '' NOT NULL,
+ cl_sortkey_prefix VARCHAR2(255),
cl_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
- cl_collation VARCHAR2(32) DEFAULT '' NOT NULL,
+ cl_collation VARCHAR2(32),
cl_type VARCHAR2(6) DEFAULT 'page' NOT NULL
);
ALTER TABLE &mw_prefix.categorylinks ADD CONSTRAINT
&mw_prefix.categorylinks_fk1 FOREIGN KEY (cl_from) REFERENCES
&mw_prefix.page(page_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
@@ -221,8 +221,8 @@
CREATE TABLE &mw_prefix.iwlinks (
iwl_from NUMBER DEFAULT 0 NOT NULL,
- iwl_prefix VARCHAR2(20) DEFAULT '' NOT NULL,
- iwl_title VARCHAR2(255) DEFAULT '' NOT NULL
+ iwl_prefix VARCHAR2(20),
+ iwl_title VARCHAR2(255)
);
CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui01 ON &mw_prefix.iwlinks (iwl_from,
iwl_prefix, iwl_title);
CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui02 ON &mw_prefix.iwlinks (iwl_prefix,
iwl_title, iwl_from);
@@ -408,7 +408,7 @@
CREATE TABLE &mw_prefix.searchindex (
si_page NUMBER NOT NULL,
- si_title VARCHAR2(255) DEFAULT '' NOT NULL,
+ si_title VARCHAR2(255),
si_text CLOB NOT NULL
);
CREATE UNIQUE INDEX &mw_prefix.searchindex_u01 ON &mw_prefix.searchindex
(si_page);
@@ -520,9 +520,9 @@
qcc_type VARCHAR2(32) NOT NULL,
qcc_value NUMBER DEFAULT 0 NOT NULL,
qcc_namespace NUMBER DEFAULT 0 NOT NULL,
- qcc_title VARCHAR2(255) DEFAULT '' NOT NULL,
+ qcc_title VARCHAR2(255),
qcc_namespacetwo NUMBER DEFAULT 0 NOT NULL,
- qcc_titletwo VARCHAR2(255) DEFAULT '' NOT NULL
+ qcc_titletwo VARCHAR2(255)
);
CREATE INDEX &mw_prefix.querycachetwo_i01 ON &mw_prefix.querycachetwo
(qcc_type,qcc_value);
CREATE INDEX &mw_prefix.querycachetwo_i02 ON &mw_prefix.querycachetwo
(qcc_type,qcc_namespace,qcc_title);
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs