r76946 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76945‎ | r76946 | r76947 >
Date:13:17, 18 November 2010
Author:freakolowsky
Status:ok
Tags:
Comment:
* Oracle: prefetching column names in ORAResult so i can release statement after constructor.
This fixes too many open cursors issue, importing of large sets now works.
Modified paths:
  • /trunk/phase3/includes/db/DatabaseOracle.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseOracle.php
@@ -30,8 +30,9 @@
3131 class ORAResult {
3232 private $rows;
3333 private $cursor;
34 - private $stmt;
3534 private $nrows;
 35+
 36+ private $columns = array();
3637
3738 private function array_unique_md( $array_in ) {
3839 $array_out = array();
@@ -63,12 +64,18 @@
6465 $this->nrows = count( $this->rows );
6566 }
6667
 68+ if ($this->nrows > 0) {
 69+ foreach ( $this->rows[0] as $k => $v ) {
 70+ $this->columns[$k] = strtolower( oci_field_name( $stmt, $k + 1 ) );
 71+ }
 72+ }
 73+
6774 $this->cursor = 0;
68 - $this->stmt = $stmt;
 75+ oci_free_statement( $stmt );
6976 }
7077
7178 public function free() {
72 - oci_free_statement( $this->stmt );
 79+ unset($this->db);
7380 }
7481
7582 public function seek( $row ) {
@@ -80,7 +87,7 @@
8188 }
8289
8390 public function numFields() {
84 - return oci_num_fields( $this->stmt );
 91+ return count($this->columns);
8592 }
8693
8794 public function fetchObject() {
@@ -90,7 +97,7 @@
9198 $row = $this->rows[$this->cursor++];
9299 $ret = new stdClass();
93100 foreach ( $row as $k => $v ) {
94 - $lc = strtolower( oci_field_name( $this->stmt, $k + 1 ) );
 101+ $lc = $this->columns[$k];
95102 $ret->$lc = $v;
96103 }
97104
@@ -105,7 +112,7 @@
106113 $row = $this->rows[$this->cursor++];
107114 $ret = array();
108115 foreach ( $row as $k => $v ) {
109 - $lc = strtolower( oci_field_name( $this->stmt, $k + 1 ) );
 116+ $lc = $this->columns[$k];
110117 $ret[$lc] = $v;
111118 $ret[$k] = $v;
112119 }
@@ -349,43 +356,43 @@
350357 }
351358
352359 function freeResult( $res ) {
353 - if ( $res instanceof ORAResult ) {
354 - $res->free();
355 - } else {
356 - $res->result->free();
 360+ if ( $res instanceof ResultWrapper ) {
 361+ $res = $res->result;
357362 }
 363+
 364+ $res->free();
358365 }
359366
360367 function fetchObject( $res ) {
361 - if ( $res instanceof ORAResult ) {
362 - return $res->numRows();
363 - } else {
364 - return $res->result->fetchObject();
 368+ if ( $res instanceof ResultWrapper ) {
 369+ $res = $res->result;
365370 }
 371+
 372+ return $res->fetchObject();
366373 }
367374
368375 function fetchRow( $res ) {
369 - if ( $res instanceof ORAResult ) {
370 - return $res->fetchRow();
371 - } else {
372 - return $res->result->fetchRow();
 376+ if ( $res instanceof ResultWrapper ) {
 377+ $res = $res->result;
373378 }
 379+
 380+ return $res->fetchRow();
374381 }
375382
376383 function numRows( $res ) {
377 - if ( $res instanceof ORAResult ) {
378 - return $res->numRows();
379 - } else {
380 - return $res->result->numRows();
 384+ if ( $res instanceof ResultWrapper ) {
 385+ $res = $res->result;
381386 }
 387+
 388+ return $res->numRows();
382389 }
383390
384391 function numFields( $res ) {
385 - if ( $res instanceof ORAResult ) {
386 - return $res->numFields();
387 - } else {
388 - return $res->result->numFields();
 392+ if ( $res instanceof ResultWrapper ) {
 393+ $res = $res->result;
389394 }
 395+
 396+ return $res->numFields();
390397 }
391398
392399 function fieldName( $stmt, $n ) {

Status & tagging log