r86701 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86700‎ | r86701 | r86702 >
Date:11:31, 22 April 2011
Author:freakolowsky
Status:resolved (Comments)
Tags:
Comment:
* begin, commit, rollback functions updated
* using ->execFlags instead of hardcoded OCI_DEFAULT
* added dummy page (id=0) to satisfy FK checks
Modified paths:
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/maintenance/oracle/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/oracle/tables.sql
@@ -72,6 +72,10 @@
7373 CREATE INDEX &mw_prefix.page_i01 ON &mw_prefix.page (page_random);
7474 CREATE INDEX &mw_prefix.page_i02 ON &mw_prefix.page (page_len);
7575
 76+-- Create a dummy page to satisfy fk contraints especially with revisions
 77+INSERT INTO &mw_prefix.page
 78+ VALUES (0, 0, ' ', NULL, 0, 0, 0, 0, current_timestamp, 0, 0);
 79+
7680 /*$mw$*/
7781 CREATE TRIGGER &mw_prefix.page_set_random BEFORE INSERT ON &mw_prefix.page
7882 FOR EACH ROW WHEN (new.page_random IS NULL)
Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -275,6 +275,9 @@
276276 function close() {
277277 $this->mOpened = false;
278278 if ( $this->mConn ) {
 279+ if ( $this->mTrxLevel ) {
 280+ $this->commit();
 281+ }
279282 return oci_close( $this->mConn );
280283 } else {
281284 return true;
@@ -559,7 +562,7 @@
560563
561564 wfSuppressWarnings();
562565
563 - if ( oci_execute( $stmt, OCI_DEFAULT ) === false ) {
 566+ if ( oci_execute( $stmt, $this->execFlags() ) === false ) {
564567 $e = oci_error( $stmt );
565568 if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) {
566569 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
@@ -921,7 +924,7 @@
922925 }
923926
924927 $fieldInfoStmt = oci_parse( $this->mConn, 'SELECT * FROM wiki_field_info_full WHERE table_name '.$tableWhere.' and column_name = \''.$field.'\'' );
925 - if ( oci_execute( $fieldInfoStmt, OCI_DEFAULT ) === false ) {
 928+ if ( oci_execute( $fieldInfoStmt, $this->execFlags() ) === false ) {
926929 $e = oci_error( $fieldInfoStmt );
927930 $this->reportQueryError( $e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__ );
928931 return false;
@@ -958,15 +961,24 @@
959962 return $this->fieldInfoMulti ($table, $field);
960963 }
961964
962 - function begin( $fname = '' ) {
 965+ function begin( $fname = 'DatabaseOracle::begin' ) {
963966 $this->mTrxLevel = 1;
964967 }
965968
966 - function commit( $fname = '' ) {
967 - oci_commit( $this->mConn );
968 - $this->mTrxLevel = 0;
 969+ function commit( $fname = 'DatabaseOracle::commit' ) {
 970+ if ( $this->mTrxLevel ) {
 971+ oci_commit( $this->mConn );
 972+ $this->mTrxLevel = 0;
 973+ }
969974 }
970975
 976+ function rollback( $fname = 'DatabaseOracle::rollback' ) {
 977+ if ( $this->mTrxLevel ) {
 978+ oci_rollback( $this->mConn );
 979+ $this->mTrxLevel = 0;
 980+ }
 981+ }
 982+
971983 /* Not even sure why this is used in the main codebase... */
972984 function limitResultForUpdate( $sql, $num ) {
973985 return $sql;
@@ -1085,7 +1097,7 @@
10861098 }
10871099
10881100 public function removeIdentifierQuotes( $s ) {
1089 - return strpos($s, '/*Q*/') === FALSE ? $s : substr($s, 5);
 1101+ return strpos($s, '/*Q*/') === FALSE ? $s : substr($s, 5); ;
10901102 }
10911103
10921104 public function isQuotedIdentifier( $s ) {
@@ -1255,7 +1267,7 @@
12561268
12571269 wfSuppressWarnings();
12581270
1259 - if ( oci_execute( $stmt, OCI_DEFAULT ) === false ) {
 1271+ if ( oci_execute( $stmt, $this->execFlags() ) === false ) {
12601272 $e = oci_error( $stmt );
12611273 if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) {
12621274 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );

Follow-up revisions

RevisionCommit summaryAuthorDate
r86702* merge of r86701freakolowsky11:32, 22 April 2011
r86708* insert page 0 (for FK) if updatingfreakolowsky14:23, 22 April 2011

Comments

#Comment by Bryan (talk | contribs)   12:35, 22 April 2011

Don't you need an updater so that the dummy page is added on upgrade?

#Comment by Freakolowsky (talk | contribs)   14:06, 22 April 2011

ummm ... yes, forgot about that ... 10x for noticing

Status & tagging log