private function fieldBindStatement ( $table, $col, &$val, $includeCol = false ) {
$col_info = $this->fieldInfoMulti( $table, $col );
$col_type = $col_info != false ? $col_info->type() : 'CONSTANT';
-
+
$bind = '';
if ( is_numeric( $col ) ) {
$bind = $val;
return $retval;
}
- function tableName( $name, $quoted ) {
+ function tableName( $name, $quoted = true ) {
/*
Replace reserved words with better ones
Using uppercase because that's the only way Oracle can handle
* Query whether a given table exists (in the given schema, or the default mw one if not given)
*/
function tableExists( $table ) {
- $table = trim($this->tableName($table), '"');
+ $table = $this->removeIdentifierQuotes($table);
$SQL = "SELECT 1 FROM user_tables WHERE table_name='$table'";
$res = $this->doQuery( $SQL );
if ( $res ) {
$table = array_map( array( &$this, 'tableName' ), $table );
$tableWhere = 'IN (';
foreach( $table as &$singleTable ) {
- $singleTable = strtoupper( trim( $singleTable, '"' ) );
+ $singleTable = $this->removeIdentifierQuotes($singleTable);
if ( isset( $this->mFieldInfoCache["$singleTable.$field"] ) ) {
return $this->mFieldInfoCache["$singleTable.$field"];
}
}
$tableWhere = rtrim( $tableWhere, ',' ) . ')';
} else {
- $table = strtoupper( trim( $this->tableName( $table ), '"' ) );
+ $table = $this->removeIdentifierQuotes($table);
if ( isset( $this->mFieldInfoCache["$table.$field"] ) ) {
return $this->mFieldInfoCache["$table.$field"];
}
}
public function addIdentifierQuotes( $s ) {
- return parent::addIdentifierQuotes( $s );
-
- /* Does this old code make any sense?
- * We could always use quoted identifier.
- * See http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements008.htm
- */
- if ( !$this->mFlags & DBO_DDLMODE ) {
- $s = '"' . str_replace( '"', '""', $s ) . '"';
+ if ( !$this->getFlag( DBO_DDLMODE ) ) {
+ $s = '/*Q*/' . $s;
}
return $s;
}
+ public function removeIdentifierQuotes( $s ) {
+ return strpos($s, '/*Q*/') === FALSE ? $s : substr($s, 5); ;
+ }
+
+ public function isQuotedIdentifier( $s ) {
+ return strpos($s, '/*Q*/') !== FALSE;
+ }
+
function selectRow( $table, $vars, $conds, $fname = 'DatabaseOracle::selectRow', $options = array(), $join_conds = array() ) {
global $wgContLang;
// ALTER SESSION SET CURRENT_SCHEMA = ...
// was used.
$dbw->query( "CALL ctx_ddl.sync_index(" .
- $dbw->addQuotes( $dbw->getDBname() . '.' . trim( $dbw->tableName( 'si_text_idx' ), '"' ) ) . ")" );
+ $dbw->addQuotes( $dbw->getDBname() . '.' . $dbw->tableName( 'si_text_idx', false ) ) . ")" );
$dbw->query( "CALL ctx_ddl.sync_index(" .
- $dbw->addQuotes( $dbw->getDBname() . '.' . trim( $dbw->tableName( 'si_title_idx' ), '"' ) ) . ")" );
+ $dbw->addQuotes( $dbw->getDBname() . '.' . $dbw->tableName( 'si_title_idx', false ) ) . ")" );
}
/**