jenkins-bot has submitted this change and it was merged.
Change subject: Fix some issues with Microsoft SQL Server Driver
......................................................................
Fix some issues with Microsoft SQL Server Driver
* INSERT IGNORE now works properly
* Only return an inserted id if the INSERT was actually successful
* Fix syntax error when doing LIMIT queries
Bug: 71024
Change-Id: I4dddc5c9c234b17040a28937987406511ec6ea9f
---
M includes/db/DatabaseMssql.php
1 file changed, 13 insertions(+), 15 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
Skizzerz: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php
index 3a4bb27..af3cc72 100644
--- a/includes/db/DatabaseMssql.php
+++ b/includes/db/DatabaseMssql.php
@@ -228,7 +228,7 @@
if ( $success ) {
$this->mAffectedRows = 0;
- return true;
+ return $stmt;
}
}
}
@@ -415,10 +415,8 @@
}
$this->mScrollableCursor = true;
$this->mPrepareStatements = true;
-
return $ret;
}
-
return $this->query( $sql, $fname );
}
@@ -614,6 +612,13 @@
// Determine binary/varbinary fields so we can encode data as a
hex string like 0xABCDEF
$binaryColumns = $this->getBinaryColumns( $table );
+ // INSERT IGNORE is not supported by SQL Server
+ // remove IGNORE from options list and set ignore flag to true
+ if ( in_array( 'IGNORE', $options ) ) {
+ $options = array_diff( $options, array( 'IGNORE' ) );
+ $this->mIgnoreDupKeyErrors = true;
+ }
+
foreach ( $arrToInsert as $a ) {
// start out with empty identity column, this is so we
can return
// it as a result of the insert logic
@@ -644,14 +649,6 @@
}
$keys = array_keys( $a );
-
- // INSERT IGNORE is not supported by SQL Server
- // remove IGNORE from options list and set ignore flag
to true
- $ignoreClause = false;
- if ( in_array( 'IGNORE', $options ) ) {
- $options = array_diff( $options, array(
'IGNORE' ) );
- $this->mIgnoreDupKeyErrors = true;
- }
// Build the actual query
$sql = $sqlPre . 'INSERT ' . implode( ' ', $options ) .
@@ -691,15 +688,16 @@
throw $e;
}
$this->mScrollableCursor = true;
- $this->mIgnoreDupKeyErrors = false;
if ( !is_null( $identity ) ) {
// then we want to get the identity column
value we were assigned and save it off
$row = $ret->fetchObject();
- $this->mInsertId = $row->$identity;
+ if( is_object( $row ) ){
+ $this->mInsertId = $row->$identity;
+ }
}
}
-
+ $this->mIgnoreDupKeyErrors = false;
return $ret;
}
@@ -921,7 +919,7 @@
}
if ( !$s2 ) {
// no ORDER BY
- $overOrder = 'ORDER BY 1';
+ $overOrder = 'ORDER BY (SELECT 1)';
} else {
if ( !isset( $orderby[2] ) || !$orderby[2] ) {
// don't need to strip it out if we're
using a FOR XML clause
--
To view, visit https://gerrit.wikimedia.org/r/161349
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4dddc5c9c234b17040a28937987406511ec6ea9f
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Emadelwany <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: Skizzerz <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits