Skip to content

Commit

Permalink
bug #15074 Fixing DbalSessionHandler to work with a Oracle "limitatio…
Browse files Browse the repository at this point in the history
…n" or bug? (nuncanada)

This PR was submitted for the 2.8 branch but it was merged into the 2.3 branch instead (closes #15074).

Discussion
----------

Fixing DbalSessionHandler to work with a Oracle "limitation" or bug?

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15050
| License       | MIT
| Doc PR        |

Commits
-------

c314659 Fixing DbalSessionHandler to work with a Oracle "limitation" or bug?
  • Loading branch information
fabpot committed Aug 1, 2015
2 parents 041c489 + c314659 commit 69171d4
Showing 1 changed file with 9 additions and 1 deletion.
Expand Up @@ -159,6 +159,14 @@ public function write($sessionId, $data)
$mergeStmt->bindParam(':id', $sessionId, \PDO::PARAM_STR);
$mergeStmt->bindParam(':data', $encoded, \PDO::PARAM_STR);
$mergeStmt->bindValue(':time', time(), \PDO::PARAM_INT);

//Oracle has a bug that will intermitently happen if you
//have only 1 bind on a CLOB field for 2 different statements
//(INSERT and UPDATE in this case)
if ('oracle' == $this->con->getDatabasePlatform()->getName()) {
$mergeStmt->bindParam(':data2', $encoded, \PDO::PARAM_STR);
}

$mergeStmt->execute();

return true;
Expand Down Expand Up @@ -224,7 +232,7 @@ private function getMergeSql()
// DUAL is Oracle specific dummy table
return "MERGE INTO $this->table USING DUAL ON ($this->idCol = :id) ".
"WHEN NOT MATCHED THEN INSERT ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ".
"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time";
"WHEN MATCHED THEN UPDATE SET $this->dataCol = :data2, $this->timeCol = :time";
case $this->con->getDatabasePlatform() instanceof SQLServer2008Platform:
// MERGE is only available since SQL Server 2008 and must be terminated by semicolon
// It also requires HOLDLOCK according to http://weblogs.sqlteam.com/dang/archive/2009/01/31/UPSERT-Race-Condition-With-MERGE.aspx
Expand Down

0 comments on commit 69171d4

Please sign in to comment.