X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FDatabaseOracle.php;h=38485481c69f5c09febc3597e87c80cb9f00f00c;hb=c07e337da68a87e7e877c65194778f4b098bf7c2;hp=a15978edba37fc0247332665c91afec4829dc7be;hpb=5fef2333d43faed0571878e848d6c40ade2c9810;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/DatabaseOracle.php b/includes/DatabaseOracle.php index a15978edba..38485481c6 100644 --- a/includes/DatabaseOracle.php +++ b/includes/DatabaseOracle.php @@ -2,6 +2,7 @@ /** * This is the Oracle database abstraction layer. + * @addtogroup Database */ class ORABlob { var $mData; @@ -19,6 +20,7 @@ class ORABlob { * The oci8 extension is fairly weak and doesn't support oci_num_rows, among * other things. We use a wrapper class to handle that and other * Oracle-specific bits, like converting column names back to lowercase. + * @addtogroup Database */ class ORAResult { private $rows; @@ -31,7 +33,7 @@ class ORAResult { $this->db =& $db; if (($this->nrows = oci_fetch_all($stmt, $this->rows, 0, -1, OCI_FETCHSTATEMENT_BY_ROW | OCI_NUM)) === false) { $e = oci_error($stmt); - $db->reportQueryError('', $e['message'], $e['code']); + $db->reportQueryError($e['message'], $e['code'], '', __FUNCTION__); return; } @@ -82,8 +84,11 @@ class ORAResult { } return $ret; } -}; +} +/** + * @addtogroup Database + */ class DatabaseOracle extends Database { var $mInsertId = NULL; var $mLastResult = NULL; @@ -123,6 +128,9 @@ class DatabaseOracle extends Database { function implicitGroupby() { return false; } + function implicitOrderby() { + return false; + } function searchableIPs() { return true; } @@ -188,10 +196,18 @@ class DatabaseOracle extends Database { function doQuery($sql) { wfDebug("SQL: [$sql]\n"); - $this->mLastResult = $stmt = oci_parse($this->mConn, $sql); + if (!mb_check_encoding($sql)) { + throw new MWException("SQL encoding is invalid"); + } + + if (($this->mLastResult = $stmt = oci_parse($this->mConn, $sql)) === false) { + $e = oci_error($this->mConn); + $this->reportQueryError($e['message'], $e['code'], $sql, __FUNCTION__); + } + if (oci_execute($stmt, $this->execFlags()) == false) { $e = oci_error($stmt); - $this->reportQueryError($sql, $e['message'], $e['code'], ''); + $this->reportQueryError($e['message'], $e['code'], $sql, __FUNCTION__); } if (oci_statement_type($stmt) == "SELECT") return new ORAResult($this, $stmt); @@ -276,8 +292,8 @@ class DatabaseOracle extends Database { if (!is_array($options)) $options = array($options); - if (in_array('IGNORE', $options)) - $oldIgnore = $this->ignoreErrors(true); + #if (in_array('IGNORE', $options)) + # $oldIgnore = $this->ignoreErrors(true); # IGNORE is performed using single-row inserts, ignoring errors in each # FIXME: need some way to distiguish between key collision and other types of error @@ -291,8 +307,8 @@ class DatabaseOracle extends Database { //$this->ignoreErrors($oldIgnore); $retVal = true; - if (in_array('IGNORE', $options)) - $this->ignoreErrors($oldIgnore); + //if (in_array('IGNORE', $options)) + // $this->ignoreErrors($oldIgnore); return $retVal; } @@ -330,7 +346,11 @@ class DatabaseOracle extends Database { } } - $bval = oci_new_descriptor($this->mConn, OCI_D_LOB); + if (($bval = oci_new_descriptor($this->mConn, OCI_D_LOB)) === false) { + $e = oci_error($stmt); + throw new DBUnexpectedError($this, "Cannot create LOB descriptor: " . $e['message']); + } + if (strlen($returning)) oci_bind_by_name($stmt, ":bval", $bval, -1, SQLT_BLOB); @@ -372,7 +392,7 @@ class DatabaseOracle extends Database { } /** - * ORacle does not have a "USE INDEX" clause, so return an empty string + * Oracle does not have a "USE INDEX" clause, so return an empty string */ function useIndexClause($index) { return ''; @@ -510,15 +530,18 @@ class DatabaseOracle extends Database { } function reportQueryError($error, $errno, $sql, $fname, $tempIgnore = false) { - # Ignore errors during error handling to avoid infinite recursion + # Ignore errors during error handling to avoid infinite + # recursion $ignore = $this->ignoreErrors(true); ++$this->mErrorCount; if ($ignore || $tempIgnore) { +echo "error ignored! query = [$sql]\n"; wfDebug("SQL ERROR (ignored): $error\n"); $this->ignoreErrors( $ignore ); } else { +echo "error!\n"; $message = "A database error has occurred\n" . "Query: $sql\n" . "Function: $fname\n" . @@ -593,6 +616,8 @@ class DatabaseOracle extends Database { } function addQuotes( $s ) { + global $wgLang; + $s = $wgLang->checkTitleEncoding($s); return "'" . $this->strencode($s) . "'"; } @@ -637,7 +662,7 @@ class DatabaseOracle extends Database { #if ( isset( $noKeyOptions['FOR UPDATE'] ) ) $tailOpts .= ' FOR UPDATE'; #if ( isset( $noKeyOptions['LOCK IN SHARE MODE'] ) ) $tailOpts .= ' LOCK IN SHARE MODE'; - if ( isset( $noKeyOptions['DISTINCT'] ) && isset( $noKeyOptions['DISTINCTROW'] ) ) $startOpts .= 'DISTINCT'; + if ( isset( $noKeyOptions['DISTINCT'] ) || isset( $noKeyOptions['DISTINCTROW'] ) ) $startOpts .= 'DISTINCT'; if ( isset( $options['USE INDEX'] ) && ! is_array( $options['USE INDEX'] ) ) { $useIndex = $this->useIndexClause( $options['USE INDEX'] ); @@ -649,15 +674,24 @@ class DatabaseOracle extends Database { } public function setTimeout( $timeout ) { - /// @fixme no-op + // @todo fixme no-op } function ping() { - wfDebug( "Function ping() not written for DatabasePostgres.php yet"); + wfDebug( "Function ping() not written for DatabaseOracle.php yet"); return true; } + /** + * How lagged is this slave? + * + * @return int + */ + public function getLag() { + # Not implemented for Oracle + return 0; + } } // end DatabaseOracle class -?> +