(bug 47070) check content model namespace on import.
[lhc/web/wiklou.git] / includes / db / DatabaseOracle.php
1 <?php
2 /**
3 * This is the Oracle database abstraction layer.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Database
22 */
23
24 /**
25 * The oci8 extension is fairly weak and doesn't support oci_num_rows, among
26 * other things. We use a wrapper class to handle that and other
27 * Oracle-specific bits, like converting column names back to lowercase.
28 * @ingroup Database
29 */
30 class ORAResult {
31 private $rows;
32 private $cursor;
33 private $nrows;
34
35 private $columns = array();
36
37 private function array_unique_md( $array_in ) {
38 $array_out = array();
39 $array_hashes = array();
40
41 foreach ( $array_in as $item ) {
42 $hash = md5( serialize( $item ) );
43 if ( !isset( $array_hashes[$hash] ) ) {
44 $array_hashes[$hash] = $hash;
45 $array_out[] = $item;
46 }
47 }
48
49 return $array_out;
50 }
51
52 /**
53 * @param $db DatabaseBase
54 * @param $stmt
55 * @param bool $unique
56 */
57 function __construct( &$db, $stmt, $unique = false ) {
58 $this->db =& $db;
59
60 $this->nrows = oci_fetch_all( $stmt, $this->rows, 0, -1, OCI_FETCHSTATEMENT_BY_ROW | OCI_NUM );
61 if ( $this->nrows === false ) {
62 $e = oci_error( $stmt );
63 $db->reportQueryError( $e['message'], $e['code'], '', __METHOD__ );
64 $this->free();
65
66 return;
67 }
68
69 if ( $unique ) {
70 $this->rows = $this->array_unique_md( $this->rows );
71 $this->nrows = count( $this->rows );
72 }
73
74 if ( $this->nrows > 0 ) {
75 foreach ( $this->rows[0] as $k => $v ) {
76 $this->columns[$k] = strtolower( oci_field_name( $stmt, $k + 1 ) );
77 }
78 }
79
80 $this->cursor = 0;
81 oci_free_statement( $stmt );
82 }
83
84 public function free() {
85 unset( $this->db );
86 }
87
88 public function seek( $row ) {
89 $this->cursor = min( $row, $this->nrows );
90 }
91
92 public function numRows() {
93 return $this->nrows;
94 }
95
96 public function numFields() {
97 return count( $this->columns );
98 }
99
100 public function fetchObject() {
101 if ( $this->cursor >= $this->nrows ) {
102 return false;
103 }
104 $row = $this->rows[$this->cursor++];
105 $ret = new stdClass();
106 foreach ( $row as $k => $v ) {
107 $lc = $this->columns[$k];
108 $ret->$lc = $v;
109 }
110
111 return $ret;
112 }
113
114 public function fetchRow() {
115 if ( $this->cursor >= $this->nrows ) {
116 return false;
117 }
118
119 $row = $this->rows[$this->cursor++];
120 $ret = array();
121 foreach ( $row as $k => $v ) {
122 $lc = $this->columns[$k];
123 $ret[$lc] = $v;
124 $ret[$k] = $v;
125 }
126
127 return $ret;
128 }
129 }
130
131 /**
132 * Utility class.
133 * @ingroup Database
134 */
135 class ORAField implements Field {
136 private $name, $tablename, $default, $max_length, $nullable,
137 $is_pk, $is_unique, $is_multiple, $is_key, $type;
138
139 function __construct( $info ) {
140 $this->name = $info['column_name'];
141 $this->tablename = $info['table_name'];
142 $this->default = $info['data_default'];
143 $this->max_length = $info['data_length'];
144 $this->nullable = $info['not_null'];
145 $this->is_pk = isset( $info['prim'] ) && $info['prim'] == 1 ? 1 : 0;
146 $this->is_unique = isset( $info['uniq'] ) && $info['uniq'] == 1 ? 1 : 0;
147 $this->is_multiple = isset( $info['nonuniq'] ) && $info['nonuniq'] == 1 ? 1 : 0;
148 $this->is_key = ( $this->is_pk || $this->is_unique || $this->is_multiple );
149 $this->type = $info['data_type'];
150 }
151
152 function name() {
153 return $this->name;
154 }
155
156 function tableName() {
157 return $this->tablename;
158 }
159
160 function defaultValue() {
161 return $this->default;
162 }
163
164 function maxLength() {
165 return $this->max_length;
166 }
167
168 function isNullable() {
169 return $this->nullable;
170 }
171
172 function isKey() {
173 return $this->is_key;
174 }
175
176 function isMultipleKey() {
177 return $this->is_multiple;
178 }
179
180 function type() {
181 return $this->type;
182 }
183 }
184
185 /**
186 * @ingroup Database
187 */
188 class DatabaseOracle extends DatabaseBase {
189 var $mInsertId = null;
190 var $mLastResult = null;
191 var $lastResult = null;
192 var $cursor = 0;
193 var $mAffectedRows;
194
195 var $ignore_DUP_VAL_ON_INDEX = false;
196 var $sequenceData = null;
197
198 var $defaultCharset = 'AL32UTF8';
199
200 var $mFieldInfoCache = array();
201
202 function __construct( $p = null ) {
203 global $wgDBprefix;
204
205 if ( !is_array( $p ) ) { // legacy calling pattern
206 wfDeprecated( __METHOD__ . " method called without parameter array.", "1.22" );
207 $args = func_get_args();
208 $p = array(
209 'host' => isset( $args[0] ) ? $args[0] : false,
210 'user' => isset( $args[1] ) ? $args[1] : false,
211 'password' => isset( $args[2] ) ? $args[2] : false,
212 'dbname' => isset( $args[3] ) ? $args[3] : false,
213 'flags' => isset( $args[4] ) ? $args[4] : 0,
214 'tablePrefix' => isset( $args[5] ) ? $args[5] : 'get from global',
215 'foreign' => isset( $args[6] ) ? $args[6] : false
216 );
217 }
218 if ( $p['tablePrefix'] == 'get from global' ) {
219 $p['tablePrefix'] = $wgDBprefix;
220 }
221 $p['tablePrefix'] = strtoupper( $p['tablePrefix'] );
222 parent::__construct( $p );
223 wfRunHooks( 'DatabaseOraclePostInit', array( $this ) );
224 }
225
226 function __destruct() {
227 if ( $this->mOpened ) {
228 wfSuppressWarnings();
229 $this->close();
230 wfRestoreWarnings();
231 }
232 }
233
234 function getType() {
235 return 'oracle';
236 }
237
238 function cascadingDeletes() {
239 return true;
240 }
241
242 function cleanupTriggers() {
243 return true;
244 }
245
246 function strictIPs() {
247 return true;
248 }
249
250 function realTimestamps() {
251 return true;
252 }
253
254 function implicitGroupby() {
255 return false;
256 }
257
258 function implicitOrderby() {
259 return false;
260 }
261
262 function searchableIPs() {
263 return true;
264 }
265
266 /**
267 * Usually aborts on failure
268 * @param string $server
269 * @param string $user
270 * @param string $password
271 * @param string $dbName
272 * @throws DBConnectionError
273 * @return DatabaseBase|null
274 */
275 function open( $server, $user, $password, $dbName ) {
276 global $wgDBOracleDRCP;
277 if ( !function_exists( 'oci_connect' ) ) {
278 throw new DBConnectionError(
279 $this,
280 "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n " .
281 "(Note: if you recently installed PHP, you may need to restart your webserver\n " .
282 "and database)\n" );
283 }
284
285 $this->close();
286 $this->mUser = $user;
287 $this->mPassword = $password;
288 // changed internal variables functions
289 // mServer now holds the TNS endpoint
290 // mDBname is schema name if different from username
291 if ( !$server ) {
292 // backward compatibillity (server used to be null and TNS was supplied in dbname)
293 $this->mServer = $dbName;
294 $this->mDBname = $user;
295 } else {
296 $this->mServer = $server;
297 if ( !$dbName ) {
298 $this->mDBname = $user;
299 } else {
300 $this->mDBname = $dbName;
301 }
302 }
303
304 if ( !strlen( $user ) ) { # e.g. the class is being loaded
305 return;
306 }
307
308 if ( $wgDBOracleDRCP ) {
309 $this->setFlag( DBO_PERSISTENT );
310 }
311
312 $session_mode = $this->mFlags & DBO_SYSDBA ? OCI_SYSDBA : OCI_DEFAULT;
313
314 wfSuppressWarnings();
315 if ( $this->mFlags & DBO_PERSISTENT ) {
316 $this->mConn = oci_pconnect(
317 $this->mUser,
318 $this->mPassword,
319 $this->mServer,
320 $this->defaultCharset,
321 $session_mode
322 );
323 } elseif ( $this->mFlags & DBO_DEFAULT ) {
324 $this->mConn = oci_new_connect(
325 $this->mUser,
326 $this->mPassword,
327 $this->mServer,
328 $this->defaultCharset,
329 $session_mode
330 );
331 } else {
332 $this->mConn = oci_connect(
333 $this->mUser,
334 $this->mPassword,
335 $this->mServer,
336 $this->defaultCharset,
337 $session_mode
338 );
339 }
340 wfRestoreWarnings();
341
342 if ( $this->mUser != $this->mDBname ) {
343 //change current schema in session
344 $this->selectDB( $this->mDBname );
345 }
346
347 if ( !$this->mConn ) {
348 throw new DBConnectionError( $this, $this->lastError() );
349 }
350
351 $this->mOpened = true;
352
353 # removed putenv calls because they interfere with the system globaly
354 $this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' );
355 $this->doQuery( 'ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT=\'DD-MM-YYYY HH24:MI:SS.FF6\'' );
356 $this->doQuery( 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS=\'.,\'' );
357
358 return $this->mConn;
359 }
360
361 /**
362 * Closes a database connection, if it is open
363 * Returns success, true if already closed
364 * @return bool
365 */
366 protected function closeConnection() {
367 return oci_close( $this->mConn );
368 }
369
370 function execFlags() {
371 return $this->mTrxLevel ? OCI_NO_AUTO_COMMIT : OCI_COMMIT_ON_SUCCESS;
372 }
373
374 protected function doQuery( $sql ) {
375 wfDebug( "SQL: [$sql]\n" );
376 if ( !StringUtils::isUtf8( $sql ) ) {
377 throw new MWException( "SQL encoding is invalid\n$sql" );
378 }
379
380 // handle some oracle specifics
381 // remove AS column/table/subquery namings
382 if ( !$this->getFlag( DBO_DDLMODE ) ) {
383 $sql = preg_replace( '/ as /i', ' ', $sql );
384 }
385
386 // Oracle has issues with UNION clause if the statement includes LOB fields
387 // So we do a UNION ALL and then filter the results array with array_unique
388 $union_unique = ( preg_match( '/\/\* UNION_UNIQUE \*\/ /', $sql ) != 0 );
389 // EXPLAIN syntax in Oracle is EXPLAIN PLAN FOR and it return nothing
390 // you have to select data from plan table after explain
391 $explain_id = MWTimestamp::getLocalInstance()->format( 'dmYHis' );
392
393 $sql = preg_replace(
394 '/^EXPLAIN /',
395 'EXPLAIN PLAN SET STATEMENT_ID = \'' . $explain_id . '\' FOR',
396 $sql,
397 1,
398 $explain_count
399 );
400
401 wfSuppressWarnings();
402
403 if ( ( $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql ) ) === false ) {
404 $e = oci_error( $this->mConn );
405 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
406
407 return false;
408 }
409
410 if ( !oci_execute( $stmt, $this->execFlags() ) ) {
411 $e = oci_error( $stmt );
412 if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) {
413 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
414
415 return false;
416 }
417 }
418
419 wfRestoreWarnings();
420
421 if ( $explain_count > 0 ) {
422 return $this->doQuery( 'SELECT id, cardinality "ROWS" FROM plan_table ' .
423 'WHERE statement_id = \'' . $explain_id . '\'' );
424 } elseif ( oci_statement_type( $stmt ) == 'SELECT' ) {
425 return new ORAResult( $this, $stmt, $union_unique );
426 } else {
427 $this->mAffectedRows = oci_num_rows( $stmt );
428
429 return true;
430 }
431 }
432
433 function queryIgnore( $sql, $fname = '' ) {
434 return $this->query( $sql, $fname, true );
435 }
436
437 function freeResult( $res ) {
438 if ( $res instanceof ResultWrapper ) {
439 $res = $res->result;
440 }
441
442 $res->free();
443 }
444
445 function fetchObject( $res ) {
446 if ( $res instanceof ResultWrapper ) {
447 $res = $res->result;
448 }
449
450 return $res->fetchObject();
451 }
452
453 function fetchRow( $res ) {
454 if ( $res instanceof ResultWrapper ) {
455 $res = $res->result;
456 }
457
458 return $res->fetchRow();
459 }
460
461 function numRows( $res ) {
462 if ( $res instanceof ResultWrapper ) {
463 $res = $res->result;
464 }
465
466 return $res->numRows();
467 }
468
469 function numFields( $res ) {
470 if ( $res instanceof ResultWrapper ) {
471 $res = $res->result;
472 }
473
474 return $res->numFields();
475 }
476
477 function fieldName( $stmt, $n ) {
478 return oci_field_name( $stmt, $n );
479 }
480
481 /**
482 * This must be called after nextSequenceVal
483 * @return null
484 */
485 function insertId() {
486 return $this->mInsertId;
487 }
488
489 function dataSeek( $res, $row ) {
490 if ( $res instanceof ORAResult ) {
491 $res->seek( $row );
492 } else {
493 $res->result->seek( $row );
494 }
495 }
496
497 function lastError() {
498 if ( $this->mConn === false ) {
499 $e = oci_error();
500 } else {
501 $e = oci_error( $this->mConn );
502 }
503
504 return $e['message'];
505 }
506
507 function lastErrno() {
508 if ( $this->mConn === false ) {
509 $e = oci_error();
510 } else {
511 $e = oci_error( $this->mConn );
512 }
513
514 return $e['code'];
515 }
516
517 function affectedRows() {
518 return $this->mAffectedRows;
519 }
520
521 /**
522 * Returns information about an index
523 * If errors are explicitly ignored, returns NULL on failure
524 * @return bool
525 */
526 function indexInfo( $table, $index, $fname = __METHOD__ ) {
527 return false;
528 }
529
530 function indexUnique( $table, $index, $fname = __METHOD__ ) {
531 return false;
532 }
533
534 function insert( $table, $a, $fname = __METHOD__, $options = array() ) {
535 if ( !count( $a ) ) {
536 return true;
537 }
538
539 if ( !is_array( $options ) ) {
540 $options = array( $options );
541 }
542
543 if ( in_array( 'IGNORE', $options ) ) {
544 $this->ignore_DUP_VAL_ON_INDEX = true;
545 }
546
547 if ( !is_array( reset( $a ) ) ) {
548 $a = array( $a );
549 }
550
551 foreach ( $a as &$row ) {
552 $this->insertOneRow( $table, $row, $fname );
553 }
554 $retVal = true;
555
556 if ( in_array( 'IGNORE', $options ) ) {
557 $this->ignore_DUP_VAL_ON_INDEX = false;
558 }
559
560 return $retVal;
561 }
562
563 private function fieldBindStatement( $table, $col, &$val, $includeCol = false ) {
564 $col_info = $this->fieldInfoMulti( $table, $col );
565 $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
566
567 $bind = '';
568 if ( is_numeric( $col ) ) {
569 $bind = $val;
570 $val = null;
571
572 return $bind;
573 } elseif ( $includeCol ) {
574 $bind = "$col = ";
575 }
576
577 if ( $val == '' && $val !== 0 && $col_type != 'BLOB' && $col_type != 'CLOB' ) {
578 $val = null;
579 }
580
581 if ( $val === 'NULL' ) {
582 $val = null;
583 }
584
585 if ( $val === null ) {
586 if ( $col_info != false && $col_info->isNullable() == 0 && $col_info->defaultValue() != null ) {
587 $bind .= 'DEFAULT';
588 } else {
589 $bind .= 'NULL';
590 }
591 } else {
592 $bind .= ':' . $col;
593 }
594
595 return $bind;
596 }
597
598 private function insertOneRow( $table, $row, $fname ) {
599 global $wgContLang;
600
601 $table = $this->tableName( $table );
602 // "INSERT INTO tables (a, b, c)"
603 $sql = "INSERT INTO " . $table . " (" . join( ',', array_keys( $row ) ) . ')';
604 $sql .= " VALUES (";
605
606 // for each value, append ":key"
607 $first = true;
608 foreach ( $row as $col => &$val ) {
609 if ( !$first ) {
610 $sql .= ', ';
611 } else {
612 $first = false;
613 }
614
615 $sql .= $this->fieldBindStatement( $table, $col, $val );
616 }
617 $sql .= ')';
618
619 if ( ( $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql ) ) === false ) {
620 $e = oci_error( $this->mConn );
621 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
622
623 return false;
624 }
625 foreach ( $row as $col => &$val ) {
626 $col_info = $this->fieldInfoMulti( $table, $col );
627 $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
628
629 if ( $val === null ) {
630 // do nothing ... null was inserted in statement creation
631 } elseif ( $col_type != 'BLOB' && $col_type != 'CLOB' ) {
632 if ( is_object( $val ) ) {
633 $val = $val->fetch();
634 }
635
636 // backward compatibility
637 if ( preg_match( '/^timestamp.*/i', $col_type ) == 1 && strtolower( $val ) == 'infinity' ) {
638 $val = $this->getInfinity();
639 }
640
641 $val = ( $wgContLang != null ) ? $wgContLang->checkTitleEncoding( $val ) : $val;
642 if ( oci_bind_by_name( $stmt, ":$col", $val, -1, SQLT_CHR ) === false ) {
643 $e = oci_error( $stmt );
644 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
645
646 return false;
647 }
648 } else {
649 if ( ( $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB ) ) === false ) {
650 $e = oci_error( $stmt );
651 throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] );
652 }
653
654 if ( is_object( $val ) ) {
655 $val = $val->fetch();
656 }
657
658 if ( $col_type == 'BLOB' ) {
659 $lob[$col]->writeTemporary( $val, OCI_TEMP_BLOB );
660 oci_bind_by_name( $stmt, ":$col", $lob[$col], -1, OCI_B_BLOB );
661 } else {
662 $lob[$col]->writeTemporary( $val, OCI_TEMP_CLOB );
663 oci_bind_by_name( $stmt, ":$col", $lob[$col], -1, OCI_B_CLOB );
664 }
665 }
666 }
667
668 wfSuppressWarnings();
669
670 if ( oci_execute( $stmt, $this->execFlags() ) === false ) {
671 $e = oci_error( $stmt );
672 if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) {
673 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
674
675 return false;
676 } else {
677 $this->mAffectedRows = oci_num_rows( $stmt );
678 }
679 } else {
680 $this->mAffectedRows = oci_num_rows( $stmt );
681 }
682
683 wfRestoreWarnings();
684
685 if ( isset( $lob ) ) {
686 foreach ( $lob as $lob_v ) {
687 $lob_v->free();
688 }
689 }
690
691 if ( !$this->mTrxLevel ) {
692 oci_commit( $this->mConn );
693 }
694
695 oci_free_statement( $stmt );
696 }
697
698 function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = __METHOD__,
699 $insertOptions = array(), $selectOptions = array()
700 ) {
701 $destTable = $this->tableName( $destTable );
702 if ( !is_array( $selectOptions ) ) {
703 $selectOptions = array( $selectOptions );
704 }
705 list( $startOpts, $useIndex, $tailOpts ) = $this->makeSelectOptions( $selectOptions );
706 if ( is_array( $srcTable ) ) {
707 $srcTable = implode( ',', array_map( array( &$this, 'tableName' ), $srcTable ) );
708 } else {
709 $srcTable = $this->tableName( $srcTable );
710 }
711
712 if ( ( $sequenceData = $this->getSequenceData( $destTable ) ) !== false &&
713 !isset( $varMap[$sequenceData['column']] )
714 ) {
715 $varMap[$sequenceData['column']] = 'GET_SEQUENCE_VALUE(\'' . $sequenceData['sequence'] . '\')';
716 }
717
718 // count-alias subselect fields to avoid abigious definition errors
719 $i = 0;
720 foreach ( $varMap as &$val ) {
721 $val = $val . ' field' . ( $i++ );
722 }
723
724 $sql = "INSERT INTO $destTable (" . implode( ',', array_keys( $varMap ) ) . ')' .
725 " SELECT $startOpts " . implode( ',', $varMap ) .
726 " FROM $srcTable $useIndex ";
727 if ( $conds != '*' ) {
728 $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
729 }
730 $sql .= " $tailOpts";
731
732 if ( in_array( 'IGNORE', $insertOptions ) ) {
733 $this->ignore_DUP_VAL_ON_INDEX = true;
734 }
735
736 $retval = $this->query( $sql, $fname );
737
738 if ( in_array( 'IGNORE', $insertOptions ) ) {
739 $this->ignore_DUP_VAL_ON_INDEX = false;
740 }
741
742 return $retval;
743 }
744
745 function tableName( $name, $format = 'quoted' ) {
746 /*
747 Replace reserved words with better ones
748 Using uppercase because that's the only way Oracle can handle
749 quoted tablenames
750 */
751 switch ( $name ) {
752 case 'user':
753 $name = 'MWUSER';
754 break;
755 case 'text':
756 $name = 'PAGECONTENT';
757 break;
758 }
759
760 return strtoupper( parent::tableName( $name, $format ) );
761 }
762
763 function tableNameInternal( $name ) {
764 $name = $this->tableName( $name );
765
766 return preg_replace( '/.*\.(.*)/', '$1', $name );
767 }
768
769 /**
770 * Return the next in a sequence, save the value for retrieval via insertId()
771 * @return null
772 */
773 function nextSequenceValue( $seqName ) {
774 $res = $this->query( "SELECT $seqName.nextval FROM dual" );
775 $row = $this->fetchRow( $res );
776 $this->mInsertId = $row[0];
777
778 return $this->mInsertId;
779 }
780
781 /**
782 * Return sequence_name if table has a sequence
783 * @return bool
784 */
785 private function getSequenceData( $table ) {
786 if ( $this->sequenceData == null ) {
787 $result = $this->doQuery( "SELECT lower(asq.sequence_name),
788 lower(atc.table_name),
789 lower(atc.column_name)
790 FROM all_sequences asq, all_tab_columns atc
791 WHERE decode(
792 atc.table_name,
793 '{$this->mTablePrefix}MWUSER',
794 '{$this->mTablePrefix}USER',
795 atc.table_name
796 ) || '_' ||
797 atc.column_name || '_SEQ' = '{$this->mTablePrefix}' || asq.sequence_name
798 AND asq.sequence_owner = upper('{$this->mDBname}')
799 AND atc.owner = upper('{$this->mDBname}')" );
800
801 while ( ( $row = $result->fetchRow() ) !== false ) {
802 $this->sequenceData[$row[1]] = array(
803 'sequence' => $row[0],
804 'column' => $row[2]
805 );
806 }
807 }
808 $table = strtolower( $this->removeIdentifierQuotes( $this->tableName( $table ) ) );
809
810 return ( isset( $this->sequenceData[$table] ) ) ? $this->sequenceData[$table] : false;
811 }
812
813 # Returns the size of a text field, or -1 for "unlimited"
814 function textFieldSize( $table, $field ) {
815 $fieldInfoData = $this->fieldInfo( $table, $field );
816
817 return $fieldInfoData->maxLength();
818 }
819
820 function limitResult( $sql, $limit, $offset = false ) {
821 if ( $offset === false ) {
822 $offset = 0;
823 }
824
825 return "SELECT * FROM ($sql) WHERE rownum >= (1 + $offset) AND rownum < (1 + $limit + $offset)";
826 }
827
828 function encodeBlob( $b ) {
829 return new Blob( $b );
830 }
831
832 function decodeBlob( $b ) {
833 if ( $b instanceof Blob ) {
834 $b = $b->fetch();
835 }
836
837 return $b;
838 }
839
840 function unionQueries( $sqls, $all ) {
841 $glue = ' UNION ALL ';
842
843 return 'SELECT * ' . ( $all ? '' : '/* UNION_UNIQUE */ ' ) .
844 'FROM (' . implode( $glue, $sqls ) . ')';
845 }
846
847 function wasDeadlock() {
848 return $this->lastErrno() == 'OCI-00060';
849 }
850
851 function duplicateTableStructure( $oldName, $newName, $temporary = false,
852 $fname = __METHOD__
853 ) {
854 $temporary = $temporary ? 'TRUE' : 'FALSE';
855
856 $newName = strtoupper( $newName );
857 $oldName = strtoupper( $oldName );
858
859 $tabName = substr( $newName, strlen( $this->mTablePrefix ) );
860 $oldPrefix = substr( $oldName, 0, strlen( $oldName ) - strlen( $tabName ) );
861 $newPrefix = strtoupper( $this->mTablePrefix );
862
863 return $this->doQuery( "BEGIN DUPLICATE_TABLE( '$tabName', " .
864 "'$oldPrefix', '$newPrefix', $temporary ); END;" );
865 }
866
867 function listTables( $prefix = null, $fname = __METHOD__ ) {
868 $listWhere = '';
869 if ( !empty( $prefix ) ) {
870 $listWhere = ' AND table_name LIKE \'' . strtoupper( $prefix ) . '%\'';
871 }
872
873 $owner = strtoupper( $this->mDBname );
874 $result = $this->doQuery( "SELECT table_name FROM all_tables " .
875 "WHERE owner='$owner' AND table_name NOT LIKE '%!_IDX\$_' ESCAPE '!' $listWhere" );
876
877 // dirty code ... i know
878 $endArray = array();
879 $endArray[] = strtoupper( $prefix . 'MWUSER' );
880 $endArray[] = strtoupper( $prefix . 'PAGE' );
881 $endArray[] = strtoupper( $prefix . 'IMAGE' );
882 $fixedOrderTabs = $endArray;
883 while ( ( $row = $result->fetchRow() ) !== false ) {
884 if ( !in_array( $row['table_name'], $fixedOrderTabs ) ) {
885 $endArray[] = $row['table_name'];
886 }
887 }
888
889 return $endArray;
890 }
891
892 public function dropTable( $tableName, $fName = __METHOD__ ) {
893 $tableName = $this->tableName( $tableName );
894 if ( !$this->tableExists( $tableName ) ) {
895 return false;
896 }
897
898 return $this->doQuery( "DROP TABLE $tableName CASCADE CONSTRAINTS PURGE" );
899 }
900
901 function timestamp( $ts = 0 ) {
902 return wfTimestamp( TS_ORACLE, $ts );
903 }
904
905 /**
906 * Return aggregated value function call
907 */
908 public function aggregateValue( $valuedata, $valuename = 'value' ) {
909 return $valuedata;
910 }
911
912 function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
913 # Ignore errors during error handling to avoid infinite
914 # recursion
915 $ignore = $this->ignoreErrors( true );
916 ++$this->mErrorCount;
917
918 if ( $ignore || $tempIgnore ) {
919 wfDebug( "SQL ERROR (ignored): $error\n" );
920 $this->ignoreErrors( $ignore );
921 } else {
922 throw new DBQueryError( $this, $error, $errno, $sql, $fname );
923 }
924 }
925
926 /**
927 * @return string wikitext of a link to the server software's web site
928 */
929 public function getSoftwareLink() {
930 return '[http://www.oracle.com/ Oracle]';
931 }
932
933 /**
934 * @return string Version information from the database
935 */
936 function getServerVersion() {
937 //better version number, fallback on driver
938 $rset = $this->doQuery(
939 'SELECT version FROM product_component_version ' .
940 'WHERE UPPER(product) LIKE \'ORACLE DATABASE%\''
941 );
942 if ( !( $row = $rset->fetchRow() ) ) {
943 return oci_server_version( $this->mConn );
944 }
945
946 return $row['version'];
947 }
948
949 /**
950 * Query whether a given index exists
951 * @return bool
952 */
953 function indexExists( $table, $index, $fname = __METHOD__ ) {
954 $table = $this->tableName( $table );
955 $table = strtoupper( $this->removeIdentifierQuotes( $table ) );
956 $index = strtoupper( $index );
957 $owner = strtoupper( $this->mDBname );
958 $SQL = "SELECT 1 FROM all_indexes WHERE owner='$owner' AND index_name='{$table}_{$index}'";
959 $res = $this->doQuery( $SQL );
960 if ( $res ) {
961 $count = $res->numRows();
962 $res->free();
963 } else {
964 $count = 0;
965 }
966
967 return $count != 0;
968 }
969
970 /**
971 * Query whether a given table exists (in the given schema, or the default mw one if not given)
972 * @return bool
973 */
974 function tableExists( $table, $fname = __METHOD__ ) {
975 $table = $this->tableName( $table );
976 $table = $this->addQuotes( strtoupper( $this->removeIdentifierQuotes( $table ) ) );
977 $owner = $this->addQuotes( strtoupper( $this->mDBname ) );
978 $SQL = "SELECT 1 FROM all_tables WHERE owner=$owner AND table_name=$table";
979 $res = $this->doQuery( $SQL );
980 if ( $res && $res->numRows() > 0 ) {
981 $exists = true;
982 } else {
983 $exists = false;
984 }
985
986 $res->free();
987
988 return $exists;
989 }
990
991 /**
992 * Function translates mysql_fetch_field() functionality on ORACLE.
993 * Caching is present for reducing query time.
994 * For internal calls. Use fieldInfo for normal usage.
995 * Returns false if the field doesn't exist
996 *
997 * @param $table Array
998 * @param $field String
999 * @return ORAField|ORAResult
1000 */
1001 private function fieldInfoMulti( $table, $field ) {
1002 $field = strtoupper( $field );
1003 if ( is_array( $table ) ) {
1004 $table = array_map( array( &$this, 'tableNameInternal' ), $table );
1005 $tableWhere = 'IN (';
1006 foreach ( $table as &$singleTable ) {
1007 $singleTable = $this->removeIdentifierQuotes( $singleTable );
1008 if ( isset( $this->mFieldInfoCache["$singleTable.$field"] ) ) {
1009 return $this->mFieldInfoCache["$singleTable.$field"];
1010 }
1011 $tableWhere .= '\'' . $singleTable . '\',';
1012 }
1013 $tableWhere = rtrim( $tableWhere, ',' ) . ')';
1014 } else {
1015 $table = $this->removeIdentifierQuotes( $this->tableNameInternal( $table ) );
1016 if ( isset( $this->mFieldInfoCache["$table.$field"] ) ) {
1017 return $this->mFieldInfoCache["$table.$field"];
1018 }
1019 $tableWhere = '= \'' . $table . '\'';
1020 }
1021
1022 $fieldInfoStmt = oci_parse(
1023 $this->mConn,
1024 'SELECT * FROM wiki_field_info_full WHERE table_name ' .
1025 $tableWhere . ' and column_name = \'' . $field . '\''
1026 );
1027 if ( oci_execute( $fieldInfoStmt, $this->execFlags() ) === false ) {
1028 $e = oci_error( $fieldInfoStmt );
1029 $this->reportQueryError( $e['message'], $e['code'], 'fieldInfo QUERY', __METHOD__ );
1030
1031 return false;
1032 }
1033 $res = new ORAResult( $this, $fieldInfoStmt );
1034 if ( $res->numRows() == 0 ) {
1035 if ( is_array( $table ) ) {
1036 foreach ( $table as &$singleTable ) {
1037 $this->mFieldInfoCache["$singleTable.$field"] = false;
1038 }
1039 } else {
1040 $this->mFieldInfoCache["$table.$field"] = false;
1041 }
1042 $fieldInfoTemp = null;
1043 } else {
1044 $fieldInfoTemp = new ORAField( $res->fetchRow() );
1045 $table = $fieldInfoTemp->tableName();
1046 $this->mFieldInfoCache["$table.$field"] = $fieldInfoTemp;
1047 }
1048 $res->free();
1049
1050 return $fieldInfoTemp;
1051 }
1052
1053 /**
1054 * @throws DBUnexpectedError
1055 * @param $table
1056 * @param $field
1057 * @return ORAField
1058 */
1059 function fieldInfo( $table, $field ) {
1060 if ( is_array( $table ) ) {
1061 throw new DBUnexpectedError( $this, 'DatabaseOracle::fieldInfo called with table array!' );
1062 }
1063
1064 return $this->fieldInfoMulti( $table, $field );
1065 }
1066
1067 protected function doBegin( $fname = __METHOD__ ) {
1068 $this->mTrxLevel = 1;
1069 $this->doQuery( 'SET CONSTRAINTS ALL DEFERRED' );
1070 }
1071
1072 protected function doCommit( $fname = __METHOD__ ) {
1073 if ( $this->mTrxLevel ) {
1074 $ret = oci_commit( $this->mConn );
1075 if ( !$ret ) {
1076 throw new DBUnexpectedError( $this, $this->lastError() );
1077 }
1078 $this->mTrxLevel = 0;
1079 $this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' );
1080 }
1081 }
1082
1083 protected function doRollback( $fname = __METHOD__ ) {
1084 if ( $this->mTrxLevel ) {
1085 oci_rollback( $this->mConn );
1086 $this->mTrxLevel = 0;
1087 $this->doQuery( 'SET CONSTRAINTS ALL IMMEDIATE' );
1088 }
1089 }
1090
1091 /* defines must comply with ^define\s*([^\s=]*)\s*=\s?'\{\$([^\}]*)\}'; */
1092 function sourceStream( $fp, $lineCallback = false, $resultCallback = false,
1093 $fname = __METHOD__, $inputCallback = false ) {
1094 $cmd = '';
1095 $done = false;
1096 $dollarquote = false;
1097
1098 $replacements = array();
1099
1100 while ( !feof( $fp ) ) {
1101 if ( $lineCallback ) {
1102 call_user_func( $lineCallback );
1103 }
1104 $line = trim( fgets( $fp, 1024 ) );
1105 $sl = strlen( $line ) - 1;
1106
1107 if ( $sl < 0 ) {
1108 continue;
1109 }
1110 if ( '-' == $line[0] && '-' == $line[1] ) {
1111 continue;
1112 }
1113
1114 // Allow dollar quoting for function declarations
1115 if ( substr( $line, 0, 8 ) == '/*$mw$*/' ) {
1116 if ( $dollarquote ) {
1117 $dollarquote = false;
1118 $line = str_replace( '/*$mw$*/', '', $line ); // remove dollarquotes
1119 $done = true;
1120 } else {
1121 $dollarquote = true;
1122 }
1123 } elseif ( !$dollarquote ) {
1124 if ( ';' == $line[$sl] && ( $sl < 2 || ';' != $line[$sl - 1] ) ) {
1125 $done = true;
1126 $line = substr( $line, 0, $sl );
1127 }
1128 }
1129
1130 if ( $cmd != '' ) {
1131 $cmd .= ' ';
1132 }
1133 $cmd .= "$line\n";
1134
1135 if ( $done ) {
1136 $cmd = str_replace( ';;', ";", $cmd );
1137 if ( strtolower( substr( $cmd, 0, 6 ) ) == 'define' ) {
1138 if ( preg_match( '/^define\s*([^\s=]*)\s*=\s*\'\{\$([^\}]*)\}\'/', $cmd, $defines ) ) {
1139 $replacements[$defines[2]] = $defines[1];
1140 }
1141 } else {
1142 foreach ( $replacements as $mwVar => $scVar ) {
1143 $cmd = str_replace( '&' . $scVar . '.', '`{$' . $mwVar . '}`', $cmd );
1144 }
1145
1146 $cmd = $this->replaceVars( $cmd );
1147 if ( $inputCallback ) {
1148 call_user_func( $inputCallback, $cmd );
1149 }
1150 $res = $this->doQuery( $cmd );
1151 if ( $resultCallback ) {
1152 call_user_func( $resultCallback, $res, $this );
1153 }
1154
1155 if ( false === $res ) {
1156 $err = $this->lastError();
1157
1158 return "Query \"{$cmd}\" failed with error code \"$err\".\n";
1159 }
1160 }
1161
1162 $cmd = '';
1163 $done = false;
1164 }
1165 }
1166
1167 return true;
1168 }
1169
1170 function selectDB( $db ) {
1171 $this->mDBname = $db;
1172 if ( $db == null || $db == $this->mUser ) {
1173 return true;
1174 }
1175 $sql = 'ALTER SESSION SET CURRENT_SCHEMA=' . strtoupper( $db );
1176 $stmt = oci_parse( $this->mConn, $sql );
1177 wfSuppressWarnings();
1178 $success = oci_execute( $stmt );
1179 wfRestoreWarnings();
1180 if ( !$success ) {
1181 $e = oci_error( $stmt );
1182 if ( $e['code'] != '1435' ) {
1183 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
1184 }
1185
1186 return false;
1187 }
1188
1189 return true;
1190 }
1191
1192 function strencode( $s ) {
1193 return str_replace( "'", "''", $s );
1194 }
1195
1196 function addQuotes( $s ) {
1197 global $wgContLang;
1198 if ( isset( $wgContLang->mLoaded ) && $wgContLang->mLoaded ) {
1199 $s = $wgContLang->checkTitleEncoding( $s );
1200 }
1201
1202 return "'" . $this->strencode( $s ) . "'";
1203 }
1204
1205 public function addIdentifierQuotes( $s ) {
1206 if ( !$this->getFlag( DBO_DDLMODE ) ) {
1207 $s = '/*Q*/' . $s;
1208 }
1209
1210 return $s;
1211 }
1212
1213 public function removeIdentifierQuotes( $s ) {
1214 return strpos( $s, '/*Q*/' ) === false ? $s : substr( $s, 5 );
1215 }
1216
1217 public function isQuotedIdentifier( $s ) {
1218 return strpos( $s, '/*Q*/' ) !== false;
1219 }
1220
1221 private function wrapFieldForWhere( $table, &$col, &$val ) {
1222 global $wgContLang;
1223
1224 $col_info = $this->fieldInfoMulti( $table, $col );
1225 $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
1226 if ( $col_type == 'CLOB' ) {
1227 $col = 'TO_CHAR(' . $col . ')';
1228 $val = $wgContLang->checkTitleEncoding( $val );
1229 } elseif ( $col_type == 'VARCHAR2' ) {
1230 $val = $wgContLang->checkTitleEncoding( $val );
1231 }
1232 }
1233
1234 private function wrapConditionsForWhere( $table, $conds, $parentCol = null ) {
1235 $conds2 = array();
1236 foreach ( $conds as $col => $val ) {
1237 if ( is_array( $val ) ) {
1238 $conds2[$col] = $this->wrapConditionsForWhere( $table, $val, $col );
1239 } else {
1240 if ( is_numeric( $col ) && $parentCol != null ) {
1241 $this->wrapFieldForWhere( $table, $parentCol, $val );
1242 } else {
1243 $this->wrapFieldForWhere( $table, $col, $val );
1244 }
1245 $conds2[$col] = $val;
1246 }
1247 }
1248
1249 return $conds2;
1250 }
1251
1252 function selectRow( $table, $vars, $conds, $fname = __METHOD__,
1253 $options = array(), $join_conds = array()
1254 ) {
1255 if ( is_array( $conds ) ) {
1256 $conds = $this->wrapConditionsForWhere( $table, $conds );
1257 }
1258
1259 return parent::selectRow( $table, $vars, $conds, $fname, $options, $join_conds );
1260 }
1261
1262 /**
1263 * Returns an optional USE INDEX clause to go after the table, and a
1264 * string to go at the end of the query
1265 *
1266 * @private
1267 *
1268 * @param array $options an associative array of options to be turned into
1269 * an SQL query, valid keys are listed in the function.
1270 * @return array
1271 */
1272 function makeSelectOptions( $options ) {
1273 $preLimitTail = $postLimitTail = '';
1274 $startOpts = '';
1275
1276 $noKeyOptions = array();
1277 foreach ( $options as $key => $option ) {
1278 if ( is_numeric( $key ) ) {
1279 $noKeyOptions[$option] = true;
1280 }
1281 }
1282
1283 $preLimitTail .= $this->makeGroupByWithHaving( $options );
1284
1285 $preLimitTail .= $this->makeOrderBy( $options );
1286
1287 if ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
1288 $postLimitTail .= ' FOR UPDATE';
1289 }
1290
1291 if ( isset( $noKeyOptions['DISTINCT'] ) || isset( $noKeyOptions['DISTINCTROW'] ) ) {
1292 $startOpts .= 'DISTINCT';
1293 }
1294
1295 if ( isset( $options['USE INDEX'] ) && !is_array( $options['USE INDEX'] ) ) {
1296 $useIndex = $this->useIndexClause( $options['USE INDEX'] );
1297 } else {
1298 $useIndex = '';
1299 }
1300
1301 return array( $startOpts, $useIndex, $preLimitTail, $postLimitTail );
1302 }
1303
1304 public function delete( $table, $conds, $fname = __METHOD__ ) {
1305 if ( is_array( $conds ) ) {
1306 $conds = $this->wrapConditionsForWhere( $table, $conds );
1307 }
1308 // a hack for deleting pages, users and images (which have non-nullable FKs)
1309 // all deletions on these tables have transactions so final failure rollbacks these updates
1310 $table = $this->tableName( $table );
1311 if ( $table == $this->tableName( 'user' ) ) {
1312 $this->update( 'archive', array( 'ar_user' => 0 ),
1313 array( 'ar_user' => $conds['user_id'] ), $fname );
1314 $this->update( 'ipblocks', array( 'ipb_user' => 0 ),
1315 array( 'ipb_user' => $conds['user_id'] ), $fname );
1316 $this->update( 'image', array( 'img_user' => 0 ),
1317 array( 'img_user' => $conds['user_id'] ), $fname );
1318 $this->update( 'oldimage', array( 'oi_user' => 0 ),
1319 array( 'oi_user' => $conds['user_id'] ), $fname );
1320 $this->update( 'filearchive', array( 'fa_deleted_user' => 0 ),
1321 array( 'fa_deleted_user' => $conds['user_id'] ), $fname );
1322 $this->update( 'filearchive', array( 'fa_user' => 0 ),
1323 array( 'fa_user' => $conds['user_id'] ), $fname );
1324 $this->update( 'uploadstash', array( 'us_user' => 0 ),
1325 array( 'us_user' => $conds['user_id'] ), $fname );
1326 $this->update( 'recentchanges', array( 'rc_user' => 0 ),
1327 array( 'rc_user' => $conds['user_id'] ), $fname );
1328 $this->update( 'logging', array( 'log_user' => 0 ),
1329 array( 'log_user' => $conds['user_id'] ), $fname );
1330 } elseif ( $table == $this->tableName( 'image' ) ) {
1331 $this->update( 'oldimage', array( 'oi_name' => 0 ),
1332 array( 'oi_name' => $conds['img_name'] ), $fname );
1333 }
1334
1335 return parent::delete( $table, $conds, $fname );
1336 }
1337
1338 function update( $table, $values, $conds, $fname = __METHOD__, $options = array() ) {
1339 global $wgContLang;
1340
1341 $table = $this->tableName( $table );
1342 $opts = $this->makeUpdateOptions( $options );
1343 $sql = "UPDATE $opts $table SET ";
1344
1345 $first = true;
1346 foreach ( $values as $col => &$val ) {
1347 $sqlSet = $this->fieldBindStatement( $table, $col, $val, true );
1348
1349 if ( !$first ) {
1350 $sqlSet = ', ' . $sqlSet;
1351 } else {
1352 $first = false;
1353 }
1354 $sql .= $sqlSet;
1355 }
1356
1357 if ( $conds !== array() && $conds !== '*' ) {
1358 $conds = $this->wrapConditionsForWhere( $table, $conds );
1359 $sql .= ' WHERE ' . $this->makeList( $conds, LIST_AND );
1360 }
1361
1362 if ( ( $this->mLastResult = $stmt = oci_parse( $this->mConn, $sql ) ) === false ) {
1363 $e = oci_error( $this->mConn );
1364 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
1365
1366 return false;
1367 }
1368 foreach ( $values as $col => &$val ) {
1369 $col_info = $this->fieldInfoMulti( $table, $col );
1370 $col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
1371
1372 if ( $val === null ) {
1373 // do nothing ... null was inserted in statement creation
1374 } elseif ( $col_type != 'BLOB' && $col_type != 'CLOB' ) {
1375 if ( is_object( $val ) ) {
1376 $val = $val->getData();
1377 }
1378
1379 if ( preg_match( '/^timestamp.*/i', $col_type ) == 1 && strtolower( $val ) == 'infinity' ) {
1380 $val = '31-12-2030 12:00:00.000000';
1381 }
1382
1383 $val = ( $wgContLang != null ) ? $wgContLang->checkTitleEncoding( $val ) : $val;
1384 if ( oci_bind_by_name( $stmt, ":$col", $val ) === false ) {
1385 $e = oci_error( $stmt );
1386 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
1387
1388 return false;
1389 }
1390 } else {
1391 if ( ( $lob[$col] = oci_new_descriptor( $this->mConn, OCI_D_LOB ) ) === false ) {
1392 $e = oci_error( $stmt );
1393 throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] );
1394 }
1395
1396 if ( $col_type == 'BLOB' ) {
1397 $lob[$col]->writeTemporary( $val );
1398 oci_bind_by_name( $stmt, ":$col", $lob[$col], -1, SQLT_BLOB );
1399 } else {
1400 $lob[$col]->writeTemporary( $val );
1401 oci_bind_by_name( $stmt, ":$col", $lob[$col], -1, OCI_B_CLOB );
1402 }
1403 }
1404 }
1405
1406 wfSuppressWarnings();
1407
1408 if ( oci_execute( $stmt, $this->execFlags() ) === false ) {
1409 $e = oci_error( $stmt );
1410 if ( !$this->ignore_DUP_VAL_ON_INDEX || $e['code'] != '1' ) {
1411 $this->reportQueryError( $e['message'], $e['code'], $sql, __METHOD__ );
1412
1413 return false;
1414 } else {
1415 $this->mAffectedRows = oci_num_rows( $stmt );
1416 }
1417 } else {
1418 $this->mAffectedRows = oci_num_rows( $stmt );
1419 }
1420
1421 wfRestoreWarnings();
1422
1423 if ( isset( $lob ) ) {
1424 foreach ( $lob as $lob_v ) {
1425 $lob_v->free();
1426 }
1427 }
1428
1429 if ( !$this->mTrxLevel ) {
1430 oci_commit( $this->mConn );
1431 }
1432
1433 oci_free_statement( $stmt );
1434 }
1435
1436 function bitNot( $field ) {
1437 // expecting bit-fields smaller than 4bytes
1438 return 'BITNOT(' . $field . ')';
1439 }
1440
1441 function bitAnd( $fieldLeft, $fieldRight ) {
1442 return 'BITAND(' . $fieldLeft . ', ' . $fieldRight . ')';
1443 }
1444
1445 function bitOr( $fieldLeft, $fieldRight ) {
1446 return 'BITOR(' . $fieldLeft . ', ' . $fieldRight . ')';
1447 }
1448
1449 function setFakeMaster( $enabled = true ) {
1450 }
1451
1452 function getDBname() {
1453 return $this->mDBname;
1454 }
1455
1456 function getServer() {
1457 return $this->mServer;
1458 }
1459
1460 public function buildGroupConcatField(
1461 $delim, $table, $field, $conds = '', $join_conds = array()
1462 ) {
1463 $fld = "LISTAGG($field," . $this->addQuotes( $delim ) . ") WITHIN GROUP (ORDER BY $field)";
1464
1465 return '(' . $this->selectSQLText( $table, $fld, $conds, null, array(), $join_conds ) . ')';
1466 }
1467
1468 public function getSearchEngine() {
1469 return 'SearchOracle';
1470 }
1471
1472 public function getInfinity() {
1473 return '31-12-2030 12:00:00.000000';
1474 }
1475 } // end DatabaseOracle class