8 * This is the Oracle database abstraction layer.
14 function __construct($data) {
24 * The oci8 extension is fairly weak and doesn't support oci_num_rows, among
25 * other things. We use a wrapper class to handle that and other
26 * Oracle-specific bits, like converting column names back to lowercase.
37 function __construct(&$db, $stmt, $unique = false) {
40 if (($this->nrows
= oci_fetch_all($stmt, $this->rows
, 0, -1, OCI_FETCHSTATEMENT_BY_ROW | OCI_NUM
)) === false) {
41 $e = oci_error($stmt);
42 $db->reportQueryError($e['message'], $e['code'], '', __FUNCTION__
);
47 $this->rows
= array_unique($this->rows
);
48 $this->nrows
= count($this->rows
);
55 public function free() {
56 oci_free_statement($this->stmt
);
59 public function seek($row) {
60 $this->cursor
= min($row, $this->nrows
);
63 public function numRows() {
67 public function numFields() {
68 return oci_num_fields($this->stmt
);
71 public function fetchObject() {
72 if ($this->cursor
>= $this->nrows
)
74 $row = $this->rows
[$this->cursor++
];
75 $ret = new stdClass();
76 foreach ($row as $k => $v) {
77 $lc = strtolower(oci_field_name($this->stmt
, $k +
1));
84 public function fetchRow() {
85 if ($this->cursor
>= $this->nrows
)
88 $row = $this->rows
[$this->cursor++
];
90 foreach ($row as $k => $v) {
91 $lc = strtolower(oci_field_name($this->stmt
, $k +
1));
104 private $name, $tablename, $default, $max_length, $nullable,
105 $is_pk, $is_unique, $is_multiple, $is_key, $type;
107 function __construct($info) {
108 $this->name
= $info['column_name'];
109 $this->tablename
= $info['table_name'];
110 $this->default = $info['data_default'];
111 $this->max_length
= $info['data_length'];
112 $this->nullable
= $info['not_null'];
113 $this->is_pk
= isset($info['prim']) && $info['prim'] == 1 ?
1 : 0;
114 $this->is_unique
= isset($info['uniq']) && $info['uniq'] == 1 ?
1 : 0;
115 $this->is_multiple
= isset($info['nonuniq']) && $info['nonuniq'] == 1 ?
1 : 0;
116 $this->is_key
= ($this->is_pk ||
$this->is_unique ||
$this->is_multiple
);
117 $this->type
= $info['data_type'];
124 function tableName() {
125 return $this->tablename
;
128 function defaultValue() {
129 return $this->default;
132 function maxLength() {
133 return $this->max_length
;
136 function nullable() {
137 return $this->nullable
;
141 return $this->is_key
;
144 function isMultipleKey() {
145 return $this->is_multiple
;
156 class DatabaseOracle
extends Database
{
157 var $mInsertId = NULL;
158 var $mLastResult = NULL;
159 var $numeric_version = NULL;
160 var $lastResult = null;
164 var $ignore_DUP_VAL_ON_INDEX = false;
166 function DatabaseOracle($server = false, $user = false, $password = false, $dbName = false,
167 $failFunction = false, $flags = 0, $tablePrefix = 'get from global' )
169 $tablePrefix = $tablePrefix == 'get from global' ?
$tablePrefix : strtoupper($tablePrefix);
170 parent
::__construct($server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix);
171 wfRunHooks( 'DatabaseOraclePostInit', array(&$this));
174 function cascadingDeletes() {
177 function cleanupTriggers() {
180 function strictIPs() {
183 function realTimestamps() {
186 function implicitGroupby() {
189 function implicitOrderby() {
192 function searchableIPs() {
196 static function newFromParams( $server = false, $user = false, $password = false, $dbName = false,
197 $failFunction = false, $flags = 0)
199 return new DatabaseOracle( $server, $user, $password, $dbName, $failFunction, $flags );
203 * Usually aborts on failure
204 * If the failFunction is set to a non-zero integer, returns success
206 function open( $server, $user, $password, $dbName ) {
207 if ( !function_exists( 'oci_connect' ) ) {
208 throw new DBConnectionError( $this, "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n (Note: if you recently installed PHP, you may need to restart your webserver and database)\n" );
211 putenv("NLS_LANG=AMERICAN_AMERICA.AL32UTF8");
214 $this->mServer
= $server;
215 $this->mUser
= $user;
216 $this->mPassword
= $password;
217 $this->mDBname
= $dbName;
219 if (!strlen($user)) { ## e.g. the class is being loaded
223 //error_reporting( E_ALL ); //whoever had this bright idea
224 if ( $this->mFlags
& DBO_DEFAULT
)
225 $this->mConn
= oci_new_connect($user, $password, $dbName);
227 $this->mConn
= oci_connect($user, $password, $dbName);
229 if ($this->mConn
== false) {
230 wfDebug("DB connection error\n");
231 wfDebug("Server: $server, Database: $dbName, User: $user, Password: " . substr( $password, 0, 3 ) . "...\n");
232 wfDebug($this->lastError()."\n");
236 $this->mOpened
= true;
238 #removed putenv calls because they interfere with the system globaly
239 $this->doQuery('ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'');
240 $this->doQuery('ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'');
246 * Closes a database connection, if it is open
247 * Returns success, true if already closed
250 $this->mOpened
= false;
251 if ( $this->mConn
) {
252 return oci_close( $this->mConn
);
258 function execFlags() {
259 return $this->mTrxLevel ? OCI_DEFAULT
: OCI_COMMIT_ON_SUCCESS
;
262 function doQuery($sql) {
263 wfDebug("SQL: [$sql]\n");
264 if (!mb_check_encoding($sql)) {
265 throw new MWException("SQL encoding is invalid");
268 //handle some oracle specifics
269 //remove AS column/table/subquery namings
270 $sql = preg_replace('/ as /i', ' ', $sql);
271 // Oracle has issues with UNION clause if the statement includes LOB fields
272 // So we do a UNION ALL and then filter the results array with array_unique
273 $union_unique = (preg_match('/\/\* UNION_UNIQUE \*\/ /', $sql) != 0);
274 //EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing
275 //you have to select data from plan table after explain
276 $explain_id = date('dmYHis');
277 $sql = preg_replace('/^EXPLAIN /', 'EXPLAIN PLAN SET STATEMENT_ID = \''.$explain_id.'\' FOR', $sql, 1, $explain_count);
280 if (($this->mLastResult
= $stmt = oci_parse($this->mConn
, $sql)) === false) {
281 $e = oci_error($this->mConn
);
282 $this->reportQueryError($e['message'], $e['code'], $sql, __FUNCTION__
);
285 $olderr = error_reporting(E_ERROR
);
286 if (oci_execute($stmt, $this->execFlags()) == false) {
287 $e = oci_error($stmt);
288 if (!$this->ignore_DUP_VAL_ON_INDEX ||
$e['code'] != '1')
289 $this->reportQueryError($e['message'], $e['code'], $sql, __FUNCTION__
);
291 error_reporting($olderr);
293 if ($explain_count > 0) {
294 return $this->doQuery('SELECT id, cardinality "ROWS" FROM plan_table WHERE statement_id = \''.$explain_id.'\'');
295 } elseif (oci_statement_type($stmt) == "SELECT") {
296 return new ORAResult($this, $stmt, $union_unique);
298 $this->mAffectedRows
= oci_num_rows($stmt);
303 function queryIgnore($sql, $fname = '') {
304 return $this->query($sql, $fname, true);
307 function freeResult($res) {
308 if ( $res instanceof ORAResult
) {
311 $res->result
->free();
315 function fetchObject($res) {
316 if ( $res instanceof ORAResult
) {
317 return $res->numRows();
319 return $res->result
->fetchObject();
323 function fetchRow($res) {
324 if ( $res instanceof ORAResult
) {
325 return $res->fetchRow();
327 return $res->result
->fetchRow();
331 function numRows($res) {
332 if ( $res instanceof ORAResult
) {
333 return $res->numRows();
335 return $res->result
->numRows();
339 function numFields($res) {
340 if ( $res instanceof ORAResult
) {
341 return $res->numFields();
343 return $res->result
->numFields();
347 function fieldName($stmt, $n) {
348 return oci_field_name($stmt, $n);
352 * This must be called after nextSequenceVal
354 function insertId() {
355 return $this->mInsertId
;
358 function dataSeek($res, $row) {
359 if ( $res instanceof ORAResult
) {
362 $res->result
->seek($row);
366 function lastError() {
367 if ($this->mConn
=== false)
370 $e = oci_error($this->mConn
);
371 return $e['message'];
374 function lastErrno() {
375 if ($this->mConn
=== false)
378 $e = oci_error($this->mConn
);
382 function affectedRows() {
383 return $this->mAffectedRows
;
387 * Returns information about an index
388 * If errors are explicitly ignored, returns NULL on failure
390 function indexInfo( $table, $index, $fname = 'DatabaseOracle::indexExists' ) {
394 function indexUnique ($table, $index, $fname = 'DatabaseOracle::indexUnique' ) {
398 function insert( $table, $a, $fname = 'DatabaseOracle::insert', $options = array() ) {
402 if (!is_array($options))
403 $options = array($options);
405 if (in_array('IGNORE', $options))
406 $this->ignore_DUP_VAL_ON_INDEX
= true;
408 if (!is_array(reset($a))) {
411 foreach ($a as $row) {
412 $this->insertOneRow($table, $row, $fname);
416 if (in_array('IGNORE', $options))
417 $this->ignore_DUP_VAL_ON_INDEX
= false;
422 function insertOneRow($table, $row, $fname) {
425 // "INSERT INTO tables (a, b, c)"
426 $sql = "INSERT INTO " . $this->tableName($table) . " (" . join(',', array_keys($row)) . ')';
429 // for each value, append ":key"
431 foreach ($row as $col => $val) {
441 $stmt = oci_parse($this->mConn
, $sql);
442 foreach ($row as $col => $val) {
443 if (!is_object($val)) {
444 if (oci_bind_by_name($stmt, ":$col", $row[$col]) === false)
445 $this->reportQueryError($this->lastErrno(), $this->lastError(), $sql, __METHOD__
);
449 $stmt = oci_parse($this->mConn
, $sql);
450 foreach ($row as $col => $val) {
451 $col_type=$this->fieldInfo($this->tableName($table), $col)->type();
452 if ($col_type != 'BLOB' && $col_type != 'CLOB') {
454 $val = $val->getData();
456 if (preg_match('/^timestamp.*/i', $col_type) == 1 && strtolower($val) == 'infinity')
457 $val = '31-12-2030 12:00:00.000000';
459 if (oci_bind_by_name($stmt, ":$col", $wgLang->checkTitleEncoding($val)) === false)
460 $this->reportQueryError($this->lastErrno(), $this->lastError(), $sql, __METHOD__
);
462 if (($lob[$col] = oci_new_descriptor($this->mConn
, OCI_D_LOB
)) === false) {
463 $e = oci_error($stmt);
464 throw new DBUnexpectedError($this, "Cannot create LOB descriptor: " . $e['message']);
467 if (is_object($val)) {
468 $lob[$col]->writeTemporary($val->getData());
469 oci_bind_by_name($stmt, ":$col", $lob[$col], -1, SQLT_BLOB
);
471 $lob[$col]->writeTemporary($val);
472 oci_bind_by_name($stmt, ":$col", $lob[$col], -1, OCI_B_CLOB
);
477 $olderr = error_reporting(E_ERROR
);
478 if (oci_execute($stmt, OCI_DEFAULT
) === false) {
479 $e = oci_error($stmt);
481 if (!$this->ignore_DUP_VAL_ON_INDEX ||
$e['code'] != '1')
482 $this->reportQueryError($e['message'], $e['code'], $sql, __METHOD__
);
484 $this->mAffectedRows
= oci_num_rows($stmt);
486 $this->mAffectedRows
= oci_num_rows($stmt);
487 error_reporting($olderr);
490 foreach ($lob as $lob_i => $lob_v) {
495 if (!$this->mTrxLevel
)
496 oci_commit($this->mConn
);
498 oci_free_statement($stmt);
501 function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'DatabaseOracle::insertSelect',
502 $insertOptions = array(), $selectOptions = array() )
504 $destTable = $this->tableName( $destTable );
505 if( !is_array( $selectOptions ) ) {
506 $selectOptions = array( $selectOptions );
508 list( $startOpts, $useIndex, $tailOpts ) = $this->makeSelectOptions( $selectOptions );
509 if( is_array( $srcTable ) ) {
510 $srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) );
512 $srcTable = $this->tableName( $srcTable );
514 $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' .
515 " SELECT $startOpts " . implode( ',', $varMap ) .
516 " FROM $srcTable $useIndex ";
517 if ( $conds != '*' ) {
518 $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND
);
520 $sql .= " $tailOpts";
522 if (in_array('IGNORE', $insertOptions))
523 $this->ignore_DUP_VAL_ON_INDEX
= true;
525 $retval = $this->query( $sql, $fname );
527 if (in_array('IGNORE', $insertOptions))
528 $this->ignore_DUP_VAL_ON_INDEX
= false;
533 function tableName( $name ) {
534 global $wgSharedDB, $wgSharedPrefix, $wgSharedTables;
536 Replace reserved words with better ones
537 Useing uppercase, because that's the only way oracle can handle
542 $name = 'MWUSER'; break;
544 $name = 'PAGECONTENT'; break;
548 The rest of procedure is equal to generic Databse class
549 except for the quoting style
551 if ( $name[0] == '"' && substr( $name, -1, 1 ) == '"' ) return $name;
553 if( preg_match( '/(^|\s)(DISTINCT|JOIN|ON|AS)(\s|$)/i', $name ) !== 0 ) return $name;
554 $dbDetails = array_reverse( explode( '.', $name, 2 ) );
555 if( isset( $dbDetails[1] ) ) @list
( $table, $database ) = $dbDetails;
556 else @list
( $table ) = $dbDetails;
558 $prefix = $this->mTablePrefix
;
560 if( isset($database) ) $table = ( $table[0] == '`' ?
$table : "`{$table}`" );
562 if( !isset( $database )
563 && isset( $wgSharedDB )
565 && isset( $wgSharedTables )
566 && is_array( $wgSharedTables )
567 && in_array( $table, $wgSharedTables ) ) {
568 $database = $wgSharedDB;
569 $prefix = isset( $wgSharedPrefix ) ?
$wgSharedPrefix : $prefix;
572 if( isset($database) ) $database = ( $database[0] == '"' ?
$database : "\"{$database}\"" );
573 $table = ( $table[0] == '"' ?
$table : "\"{$prefix}{$table}\"" );
575 $tableName = ( isset($database) ?
"{$database}.{$table}" : "{$table}" );
577 return strtoupper($tableName);
581 * Return the next in a sequence, save the value for retrieval via insertId()
583 function nextSequenceValue($seqName) {
584 $res = $this->query("SELECT $seqName.nextval FROM dual");
585 $row = $this->fetchRow($res);
586 $this->mInsertId
= $row[0];
587 $this->freeResult($res);
588 return $this->mInsertId
;
592 * Oracle does not have a "USE INDEX" clause, so return an empty string
594 function useIndexClause($index) {
598 # REPLACE query wrapper
599 # Oracle simulates this with a DELETE followed by INSERT
600 # $row is the row to insert, an associative array
601 # $uniqueIndexes is an array of indexes. Each element may be either a
602 # field name or an array of field names
604 # It may be more efficient to leave off unique indexes which are unlikely to collide.
605 # However if you do this, you run the risk of encountering errors which wouldn't have
607 function replace( $table, $uniqueIndexes, $rows, $fname = 'DatabaseOracle::replace' ) {
608 $table = $this->tableName($table);
610 if (count($rows)==0) {
615 if (!is_array(reset($rows))) {
616 $rows = array($rows);
619 foreach( $rows as $row ) {
620 # Delete rows which collide
621 if ( $uniqueIndexes ) {
622 $sql = "DELETE FROM $table WHERE ";
624 foreach ( $uniqueIndexes as $index ) {
631 if ( is_array( $index ) ) {
633 foreach ( $index as $col ) {
639 $sql .= $col.'=' . $this->addQuotes( $row[$col] );
642 $sql .= $index.'=' . $this->addQuotes( $row[$index] );
646 $this->query( $sql, $fname );
650 $this->insert( $table, $row, $fname );
654 # DELETE where the condition is a join
655 function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = "DatabaseOracle::deleteJoin" ) {
657 throw new DBUnexpectedError($this, 'DatabaseOracle::deleteJoin() called with empty $conds' );
660 $delTable = $this->tableName( $delTable );
661 $joinTable = $this->tableName( $joinTable );
662 $sql = "DELETE FROM $delTable WHERE $delVar IN (SELECT $joinVar FROM $joinTable ";
663 if ( $conds != '*' ) {
664 $sql .= 'WHERE ' . $this->makeList( $conds, LIST_AND
);
668 $this->query( $sql, $fname );
671 # Returns the size of a text field, or -1 for "unlimited"
672 function textFieldSize( $table, $field ) {
673 $table = $this->tableName( $table );
674 $sql = "SELECT t.typname as ftype,a.atttypmod as size
675 FROM pg_class c, pg_attribute a, pg_type t
676 WHERE relname='$table' AND a.attrelid=c.oid AND
677 a.atttypid=t.oid and a.attname='$field'";
678 $res =$this->query($sql);
679 $row=$this->fetchObject($res);
680 if ($row->ftype
=="varchar") {
685 $this->freeResult( $res );
689 function lowPriorityOption() {
693 function limitResult($sql, $limit, $offset) {
694 if ($offset === false)
696 return "SELECT * FROM ($sql) WHERE rownum >= (1 + $offset) AND rownum < (1 + $limit + $offset)";
700 function unionQueries($sqls, $all = false) {
701 $glue = ' UNION ALL ';
702 return 'SELECT * '.($all?
'':'/* UNION_UNIQUE */ ').'FROM ('.implode( $glue, $sqls ).')' ;
706 * Returns an SQL expression for a simple conditional.
707 * Uses CASE on Oracle
709 * @param $cond String: SQL expression which will result in a boolean value
710 * @param $trueVal String: SQL expression to return if true
711 * @param $falseVal String: SQL expression to return if false
712 * @return String: SQL fragment
714 function conditional( $cond, $trueVal, $falseVal ) {
715 return " (CASE WHEN $cond THEN $trueVal ELSE $falseVal END) ";
718 function wasDeadlock() {
719 return $this->lastErrno() == 'OCI-00060';
722 function timestamp($ts = 0) {
723 return wfTimestamp(TS_ORACLE
, $ts);
727 * Return aggregated value function call
729 function aggregateValue ($valuedata,$valuename='value') {
733 function reportQueryError($error, $errno, $sql, $fname, $tempIgnore = false) {
734 # Ignore errors during error handling to avoid infinite
736 $ignore = $this->ignoreErrors(true);
737 ++
$this->mErrorCount
;
739 if ($ignore ||
$tempIgnore) {
740 //echo "error ignored! query = [$sql]\n";
741 wfDebug("SQL ERROR (ignored): $error\n");
742 $this->ignoreErrors( $ignore );
746 $message = "A database error has occurred\n" .
748 "Function: $fname\n" .
749 "Error: $errno $error\n";
750 throw new DBUnexpectedError($this, $message);
755 * @return string wikitext of a link to the server software's web site
757 function getSoftwareLink() {
758 return "[http://www.oracle.com/ Oracle]";
762 * @return string Version information from the database
764 function getServerVersion() {
765 return oci_server_version($this->mConn
);
769 * Query whether a given table exists (in the given schema, or the default mw one if not given)
771 function tableExists($table) {
772 $SQL = "SELECT 1 FROM user_tables WHERE table_name='$table'";
773 $res = $this->doQuery($SQL);
775 $count = $res->numRows();
784 * Query whether a given column exists in the mediawiki schema
785 * based on prebuilt table to simulate MySQL field info and keep query speed minimal
787 function fieldExists( $table, $field ) {
788 if (!isset($this->fieldInfo_stmt
))
789 $this->fieldInfo_stmt
= oci_parse($this->mConn
, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)');
791 oci_bind_by_name($this->fieldInfo_stmt
, ':tab', trim($table, '"'));
792 oci_bind_by_name($this->fieldInfo_stmt
, ':col', $field);
794 if (oci_execute($this->fieldInfo_stmt
, OCI_DEFAULT
) === false) {
795 $e = oci_error($this->fieldInfo_stmt
);
796 $this->reportQueryError($e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__
);
799 $res = new ORAResult($this,$this->fieldInfo_stmt
);
800 return $res->numRows() != 0;
803 function fieldInfo( $table, $field ) {
804 if (!isset($this->fieldInfo_stmt
))
805 $this->fieldInfo_stmt
= oci_parse($this->mConn
, 'SELECT * FROM wiki_field_info_full WHERE table_name = upper(:tab) and column_name = UPPER(:col)');
807 oci_bind_by_name($this->fieldInfo_stmt
, ':tab', trim($table, '"'));
808 oci_bind_by_name($this->fieldInfo_stmt
, ':col', $field);
810 if (oci_execute($this->fieldInfo_stmt
, OCI_DEFAULT
) === false) {
811 $e = oci_error($this->fieldInfo_stmt
);
812 $this->reportQueryError($e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__
);
815 $res = new ORAResult($this,$this->fieldInfo_stmt
);
816 return new ORAField($res->fetchRow());
819 function begin( $fname = '' ) {
820 $this->mTrxLevel
= 1;
822 function immediateCommit( $fname = '' ) {
825 function commit( $fname = '' ) {
826 oci_commit($this->mConn
);
827 $this->mTrxLevel
= 0;
830 /* Not even sure why this is used in the main codebase... */
831 function limitResultForUpdate($sql, $num) {
835 function strencode($s) {
836 return str_replace("'", "''", $s);
839 function encodeBlob($b) {
840 return new ORABlob($b);
842 function decodeBlob($b) {
843 return $b; //return $b->load();
846 function addQuotes( $s ) {
848 if (isset($wgLang->mLoaded
) && $wgLang->mLoaded
)
849 $s = $wgLang->checkTitleEncoding($s);
850 return "'" . $this->strencode($s) . "'";
853 function quote_ident( $s ) {
857 /* For now, does nothing */
858 function selectDB( $db ) {
862 function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) {
863 if (is_array($table))
864 foreach ($table as $tab)
865 $tab = $this->tableName($tab);
867 $table = $this->tableName($table);
868 return parent
::selectRow($table, $vars, $conds, $fname, $options, $join_conds);
872 * Returns an optional USE INDEX clause to go after the table, and a
873 * string to go at the end of the query
877 * @param $options Array: an associative array of options to be turned into
878 * an SQL query, valid keys are listed in the function.
881 function makeSelectOptions( $options ) {
882 $preLimitTail = $postLimitTail = '';
885 $noKeyOptions = array();
886 foreach ( $options as $key => $option ) {
887 if ( is_numeric( $key ) ) {
888 $noKeyOptions[$option] = true;
892 if ( isset( $options['GROUP BY'] ) ) $preLimitTail .= " GROUP BY {$options['GROUP BY']}";
893 if ( isset( $options['ORDER BY'] ) ) $preLimitTail .= " ORDER BY {$options['ORDER BY']}";
895 #if ( isset( $noKeyOptions['FOR UPDATE'] ) ) $tailOpts .= ' FOR UPDATE';
896 #if ( isset( $noKeyOptions['LOCK IN SHARE MODE'] ) ) $tailOpts .= ' LOCK IN SHARE MODE';
897 if ( isset( $noKeyOptions['DISTINCT'] ) ||
isset( $noKeyOptions['DISTINCTROW'] ) ) $startOpts .= 'DISTINCT';
899 if ( isset( $options['USE INDEX'] ) && ! is_array( $options['USE INDEX'] ) ) {
900 $useIndex = $this->useIndexClause( $options['USE INDEX'] );
905 return array( $startOpts, $useIndex, $preLimitTail, $postLimitTail );
908 public function makeList( $a, $mode = LIST_COMMA
) {
909 if ( !is_array( $a ) ) {
910 throw new DBUnexpectedError( $this, 'DatabaseOracle::makeList called with incorrect parameters' );
913 foreach ($a as $key => $value) {
914 if (strpos($key, ' & ') !== FALSE)
915 $a2[preg_replace('/(.*)\s&\s(.*)/', 'BITAND($1, $2)', $key)] = $value;
916 elseif (strpos($key, ' | ') !== FALSE)
917 $a2[preg_replace('/(.*)\s|\s(.*)/', 'BITOR($1, $2)', $key)] = $value;
918 elseif (!is_array($value)) {
919 if (strpos($value, ' = ') !== FALSE) {
920 if (strpos($value, ' & ') !== FALSE)
921 $a2[$key] = preg_replace('/(.*)\s&\s(.*?)\s=\s(.*)/', 'BITAND($1, $2) = $3', $value);
922 elseif (strpos($value, ' | ') !== FALSE)
923 $a2[$key] = preg_replace('/(.*)\s|\s(.*?)\s=\s(.*)/', 'BITOR($1, $2) = $3', $value);
924 else $a2[$key] = $value;
926 elseif (strpos($value, ' & ') !== FALSE)
927 $a2[$key] = preg_replace('/(.*)\s&\s(.*)/', 'BITAND($1, $2)', $value);
928 elseif (strpos($value, ' | ') !== FALSE)
929 $a2[$key] = preg_replace('/(.*)\s|\s(.*)/', 'BITOR($1, $2)', $value);
937 return parent
::makeList($a2, $mode);
940 public function setTimeout( $timeout ) {
945 wfDebug( "Function ping() not written for DatabaseOracle.php yet");
950 * How lagged is this slave?
954 public function getLag() {
955 # Not implemented for Oracle
959 function setFakeSlaveLag( $lag ) {}
960 function setFakeMaster( $enabled = true ) {}
962 function getDBname() {
963 return $this->mDBname
;
966 function getServer() {
967 return $this->mServer
;
971 * No-op lock functions
973 public function lock( $lockName, $method ) {
976 public function unlock( $lockName, $method ) {
980 public function getSearchEngine() {
981 return "SearchOracle";
985 public function setBigSelects( $value = true ) {}
987 } // end DatabaseOracle class