summaryrefslogtreecommitdiff
path: root/includes/db
diff options
context:
space:
mode:
Diffstat (limited to 'includes/db')
-rw-r--r--includes/db/DatabaseMysqli.php13
-rw-r--r--includes/db/DatabaseOracle.php32
-rw-r--r--includes/db/DatabasePostgres.php16
3 files changed, 51 insertions, 10 deletions
diff --git a/includes/db/DatabaseMysqli.php b/includes/db/DatabaseMysqli.php
index 7761abe9..0ec54314 100644
--- a/includes/db/DatabaseMysqli.php
+++ b/includes/db/DatabaseMysqli.php
@@ -51,6 +51,17 @@ class DatabaseMysqli extends DatabaseMysqlBase {
. " have you compiled PHP with the --with-mysqli option?\n" );
}
+ // Other than mysql_connect, mysqli_real_connect expects an explicit port
+ // parameter. So we need to parse the port out of $realServer
+ $port = null;
+ $hostAndPort = IP::splitHostAndPort( $realServer );
+ if ( $hostAndPort ) {
+ $realServer = $hostAndPort[0];
+ if ( $hostAndPort[1] ) {
+ $port = $hostAndPort[1];
+ }
+ }
+
$connFlags = 0;
if ( $this->mFlags & DBO_SSL ) {
$connFlags |= MYSQLI_CLIENT_SSL;
@@ -70,7 +81,7 @@ class DatabaseMysqli extends DatabaseMysqlBase {
usleep( 1000 );
}
if ( $mysqli->real_connect( $realServer, $this->mUser,
- $this->mPassword, $this->mDBname, null, null, $connFlags ) )
+ $this->mPassword, $this->mDBname, $port, null, $connFlags ) )
{
return $mysqli;
}
diff --git a/includes/db/DatabaseOracle.php b/includes/db/DatabaseOracle.php
index 32d4d984..fb2d4359 100644
--- a/includes/db/DatabaseOracle.php
+++ b/includes/db/DatabaseOracle.php
@@ -551,8 +551,12 @@ class DatabaseOracle extends DatabaseBase {
} else {
$first = false;
}
-
- $sql .= $this->fieldBindStatement( $table, $col, $val );
+ if ( $this->isQuotedIdentifier( $val ) ) {
+ $sql .= $this->removeIdentifierQuotes( $val );
+ unset( $row[$col] );
+ } else {
+ $sql .= $this->fieldBindStatement( $table, $col, $val );
+ }
}
$sql .= ')';
@@ -679,6 +683,30 @@ class DatabaseOracle extends DatabaseBase {
return $retval;
}
+ public function upsert( $table, array $rows, array $uniqueIndexes, array $set,
+ $fname = __METHOD__
+ ) {
+ if ( !count( $rows ) ) {
+ return true; // nothing to do
+ }
+
+ if ( !is_array( reset( $rows ) ) ) {
+ $rows = array( $rows );
+ }
+
+ $sequenceData = $this->getSequenceData( $table );
+ if ( $sequenceData !== false ) {
+ // add sequence column to each list of columns, when not set
+ foreach ( $rows as &$row ) {
+ if ( !isset( $row[$sequenceData['column']] ) ) {
+ $row[$sequenceData['column']] = $this->addIdentifierQuotes('GET_SEQUENCE_VALUE(\'' . $sequenceData['sequence'] . '\')');
+ }
+ }
+ }
+
+ return parent::upsert( $table, $rows, $uniqueIndexes, $set, $fname );
+ }
+
function tableName( $name, $format = 'quoted' ) {
/*
Replace reserved words with better ones
diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php
index aed35f10..0bd966ba 100644
--- a/includes/db/DatabasePostgres.php
+++ b/includes/db/DatabasePostgres.php
@@ -729,13 +729,15 @@ __INDEXATTR__;
* so causes a DB error. This wrapper checks which tables can be locked and adjusts it accordingly.
*/
function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array() ) {
- $forUpdateKey = array_search( 'FOR UPDATE', $options );
- if ( $forUpdateKey !== false && $join_conds ) {
- unset( $options[$forUpdateKey] );
-
- foreach ( $join_conds as $table => $join_cond ) {
- if ( 0 === preg_match( '/^(?:LEFT|RIGHT|FULL)(?: OUTER)? JOIN$/i', $join_cond[0] ) ) {
- $options['FOR UPDATE'][] = $table;
+ if ( is_array( $options ) ) {
+ $forUpdateKey = array_search( 'FOR UPDATE', $options );
+ if ( $forUpdateKey !== false && $join_conds ) {
+ unset( $options[$forUpdateKey] );
+
+ foreach ( $join_conds as $table_cond => $join_cond ) {
+ if ( 0 === preg_match( '/^(?:LEFT|RIGHT|FULL)(?: OUTER)? JOIN$/i', $join_cond[0] ) ) {
+ $options['FOR UPDATE'][] = $table_cond;
+ }
}
}
}