r90585 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90584‎ | r90585 | r90586 >
Date:14:10, 22 June 2011
Author:freakolowsky
Status:ok (Comments)
Tags:
Comment:
* 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 (modified) (history)
  • /trunk/phase3/includes/installer/OracleUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/oracle/archives/patch_remove_not_null_empty_defs.sql (added) (history)
  • /trunk/phase3/maintenance/oracle/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/oracle/archives/patch_remove_not_null_empty_defs.sql
@@ -0,0 +1,9 @@
 2+define mw_prefix='{$wgDBprefix}';
 3+
 4+ALTER TABLE &mw_prefix.categorylinks MODIFY cl_sortkey_prefix DEFAULT NULL NULL;
 5+ALTER TABLE &mw_prefix.categorylinks MODIFY cl_collation DEFAULT NULL NULL;
 6+ALTER TABLE &mw_prefix.iwlinks MODIFY iwl_prefix DEFAULT NULL NULL;
 7+ALTER TABLE &mw_prefix.iwlinks MODIFY iwl_title DEFAULT NULL NULL;
 8+ALTER TABLE &mw_prefix.searchindex MODIFY si_title DEFAULT NULL NULL;
 9+ALTER TABLE &mw_prefix.querycachetwo MODIFY qcc_title DEFAULT NULL NULL;
 10+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
111 + native
Index: trunk/phase3/maintenance/oracle/tables.sql
@@ -27,7 +27,7 @@
2828
2929 -- Create a dummy user to satisfy fk contraints especially with revisions
3030 INSERT INTO &mw_prefix.mwuser
31 - VALUES (user_user_id_seq.nextval,'Anonymous','',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, '', current_timestamp, current_timestamp, 0);
 31+ VALUES (user_user_id_seq.nextval,'Anonymous',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, '', current_timestamp, current_timestamp, 0);
3232
3333 CREATE TABLE &mw_prefix.user_groups (
3434 ug_user NUMBER DEFAULT 0 NOT NULL,
@@ -169,9 +169,9 @@
170170 cl_from NUMBER NOT NULL,
171171 cl_to VARCHAR2(255) NOT NULL,
172172 cl_sortkey VARCHAR2(230),
173 - cl_sortkey_prefix VARCHAR2(255) DEFAULT '' NOT NULL,
 173+ cl_sortkey_prefix VARCHAR2(255),
174174 cl_timestamp TIMESTAMP(6) WITH TIME ZONE NOT NULL,
175 - cl_collation VARCHAR2(32) DEFAULT '' NOT NULL,
 175+ cl_collation VARCHAR2(32),
176176 cl_type VARCHAR2(6) DEFAULT 'page' NOT NULL
177177 );
178178 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 @@
222222
223223 CREATE TABLE &mw_prefix.iwlinks (
224224 iwl_from NUMBER DEFAULT 0 NOT NULL,
225 - iwl_prefix VARCHAR2(20) DEFAULT '' NOT NULL,
226 - iwl_title VARCHAR2(255) DEFAULT '' NOT NULL
 225+ iwl_prefix VARCHAR2(20),
 226+ iwl_title VARCHAR2(255)
227227 );
228228 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui01 ON &mw_prefix.iwlinks (iwl_from, iwl_prefix, iwl_title);
229229 CREATE UNIQUE INDEX &mw_prefix.iwlinks_ui02 ON &mw_prefix.iwlinks (iwl_prefix, iwl_title, iwl_from);
@@ -408,7 +408,7 @@
409409
410410 CREATE TABLE &mw_prefix.searchindex (
411411 si_page NUMBER NOT NULL,
412 - si_title VARCHAR2(255) DEFAULT '' NOT NULL,
 412+ si_title VARCHAR2(255),
413413 si_text CLOB NOT NULL
414414 );
415415 CREATE UNIQUE INDEX &mw_prefix.searchindex_u01 ON &mw_prefix.searchindex (si_page);
@@ -520,9 +520,9 @@
521521 qcc_type VARCHAR2(32) NOT NULL,
522522 qcc_value NUMBER DEFAULT 0 NOT NULL,
523523 qcc_namespace NUMBER DEFAULT 0 NOT NULL,
524 - qcc_title VARCHAR2(255) DEFAULT '' NOT NULL,
 524+ qcc_title VARCHAR2(255),
525525 qcc_namespacetwo NUMBER DEFAULT 0 NOT NULL,
526 - qcc_titletwo VARCHAR2(255) DEFAULT '' NOT NULL
 526+ qcc_titletwo VARCHAR2(255)
527527 );
528528 CREATE INDEX &mw_prefix.querycachetwo_i01 ON &mw_prefix.querycachetwo (qcc_type,qcc_value);
529529 CREATE INDEX &mw_prefix.querycachetwo_i02 ON &mw_prefix.querycachetwo (qcc_type,qcc_namespace,qcc_title);
Index: trunk/phase3/includes/installer/DatabaseUpdater.php
@@ -232,6 +232,7 @@
233233 }
234234
235235 protected function setAppliedUpdates( $version, $updates = array() ) {
 236+ $this->db->clearFlag( DBO_DDLMODE );
236237 if( !$this->canUseNewUpdatelog() ) {
237238 return;
238239 }
@@ -239,6 +240,7 @@
240241 $this->db->insert( 'updatelog',
241242 array( 'ul_key' => $key, 'ul_value' => serialize( $updates ) ),
242243 __METHOD__ );
 244+ $this->db->setFlag( DBO_DDLMODE );
243245 }
244246
245247 /**
@@ -265,11 +267,13 @@
266268 * @param $val String [optional] value to insert along with the key
267269 */
268270 public function insertUpdateRow( $key, $val = null ) {
 271+ $this->db->clearFlag( DBO_DDLMODE );
269272 $values = array( 'ul_key' => $key );
270273 if( $val && $this->canUseNewUpdatelog() ) {
271274 $values['ul_value'] = $val;
272275 }
273276 $this->db->insert( 'updatelog', $values, __METHOD__, 'IGNORE' );
 277+ $this->db->setFlag( DBO_DDLMODE );
274278 }
275279
276280 /**
Index: trunk/phase3/includes/installer/OracleUpdater.php
@@ -29,6 +29,7 @@
3030 array( 'doFunctions17' ),
3131 array( 'doSchemaUpgrade17' ),
3232 array( 'doInsertPage0' ),
 33+ array( 'doRemoveNotNullEmptyDefaults' ),
3334
3435 //1.18
3536 array( 'addIndex', 'user', 'i02', 'patch-user_email_index.sql' ),
@@ -93,7 +94,7 @@
9495 protected function doSchemaUpgrade17() {
9596 $this->output( "Updating schema to 17 ... " );
9697 // check if iwlinks table exists which was added in 1.17
97 - if ( $this->db->tableExists( $this->db->tableName( 'iwlinks' ) ) ) {
 98+ if ( $this->db->tableExists( 'iwlinks' ) ) {
9899 $this->output( "schema seem to be up to date.\n" );
99100 return;
100101 }
@@ -122,6 +123,20 @@
123124 $this->output( "ok\n" );
124125 }
125126
 127+ /**
 128+ * Remove DEFAULT '' NOT NULL constraints from fields as '' is internally
 129+ * converted to NULL in Oracle
 130+ */
 131+ protected function doRemoveNotNullEmptyDefaults() {
 132+ $this->output( "Removing not null empty constraints ... " );
 133+ $meta = $this->db->fieldInfo( 'categorylinks' , 'cl_sortkey_prefix' );
 134+ if ( $meta->isNullable() ) {
 135+ $this->output( "constraints seem to be removed\n" );
 136+ return;
 137+ }
 138+ $this->applyPatch( 'patch_remove_not_null_empty_defs.sql', false );
 139+ $this->output( "ok\n" );
 140+ }
126141
127142 /**
128143 * rebuilding of the function that duplicates tables for tests

Follow-up revisions

RevisionCommit summaryAuthorDate
r90586* MFT r90585 (i know it's late ... ready for 1.17.1 :D)...freakolowsky14:34, 22 June 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   22:29, 5 July 2011

I hope no one joins on these tables and does an existence check by seeing if one of these fields is null.

#Comment by Freakolowsky (talk | contribs)   06:55, 6 July 2011

I tried finding a workaround for this one but this is too deep inside oracle.

The only way this could work is by converting fields to static character fields, but that has a pile of problems on it's own.

Well ... we shall see ...

Status & tagging log