Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
1b3e0d3b
Commit
1b3e0d3b
authored
Oct 01, 2010
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DBAL-55 - Final cleanups
parent
6abf6aaf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
30 deletions
+44
-30
Connection.php
lib/Doctrine/DBAL/Connection.php
+3
-3
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+12
-0
ConnectionTest.php
tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
+29
-27
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
1b3e0d3b
...
...
@@ -803,7 +803,7 @@ class Connection implements DriverConnection
if
(
$this
->
_transactionNestingLevel
==
1
)
{
$this
->
_conn
->
beginTransaction
();
}
else
{
$savepointName
=
$this
->
_getNestedTransactionSavePointName
(
$this
->
_transactionNestingLevel
);
$savepointName
=
$this
->
_getNestedTransactionSavePointName
();
if
(
$savepointName
)
{
$this
->
createSavePoint
(
$savepointName
);
}
...
...
@@ -831,7 +831,7 @@ class Connection implements DriverConnection
if
(
$this
->
_transactionNestingLevel
==
1
)
{
$this
->
_conn
->
commit
();
}
else
{
$savepointName
=
$this
->
_getNestedTransactionSavePointName
(
$this
->
_transactionNestingLevel
);
$savepointName
=
$this
->
_getNestedTransactionSavePointName
();
if
(
$savepointName
&&
$this
->
_platform
->
supportsReleaseSavepoints
())
{
$this
->
releaseSavePoint
(
$savepointName
);
}
...
...
@@ -861,7 +861,7 @@ class Connection implements DriverConnection
$this
->
_conn
->
rollback
();
$this
->
_isRollbackOnly
=
false
;
}
else
{
$savepointName
=
$this
->
_getNestedTransactionSavePointName
(
$this
->
_transactionNestingLevel
);
$savepointName
=
$this
->
_getNestedTransactionSavePointName
();
if
(
!
$this
->
_isRollbackOnly
&&
$savepointName
)
{
$this
->
rollbackSavePoint
(
$savepointName
);
}
else
{
...
...
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
1b3e0d3b
...
...
@@ -549,4 +549,16 @@ class DB2Platform extends AbstractPlatform
{
return
'SELECT 1 FROM sysibm.sysdummy1'
;
}
/**
* DB2 supports savepoints, but they work semantically different than on other vendor platforms.
*
* TODO: We have to investigate how to get DB2 up and running with savepoints.
*
* @return bool
*/
public
function
supportsSavepoints
()
{
return
false
;
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
View file @
1b3e0d3b
...
...
@@ -56,38 +56,40 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public
function
testTransactionNestingBehaviorWithSavepoints
()
{
if
(
$this
->
_conn
->
getDatabasePlatform
()
->
supportsSavepoints
())
{
$this
->
_conn
->
setNestTransactionsWithSavepoints
(
true
);
if
(
!
$this
->
_conn
->
getDatabasePlatform
()
->
supportsSavepoints
())
{
$this
->
markTestSkipped
(
'This test requires the platform to support savepoints.'
);
}
$this
->
_conn
->
setNestTransactionsWithSavepoints
(
true
);
try
{
$this
->
_conn
->
beginTransaction
();
$this
->
assertEquals
(
1
,
$this
->
_conn
->
getTransactionNestingLevel
());
try
{
$this
->
_conn
->
beginTransaction
();
$this
->
assertEquals
(
2
,
$this
->
_conn
->
getTransactionNestingLevel
());
$this
->
_conn
->
beginTransaction
();
$this
->
assertEquals
(
3
,
$this
->
_conn
->
getTransactionNestingLevel
());
$this
->
_conn
->
commit
();
$this
->
assertEquals
(
2
,
$this
->
_conn
->
getTransactionNestingLevel
());
throw
new
\Exception
;
$this
->
_conn
->
commit
();
// never reached
}
catch
(
\Exception
$e
)
{
$this
->
_conn
->
rollback
();
$this
->
assertEquals
(
1
,
$this
->
_conn
->
getTransactionNestingLevel
());
try
{
$this
->
_conn
->
beginTransaction
();
$this
->
assertEquals
(
2
,
$this
->
_conn
->
getTransactionNestingLevel
());
$this
->
_conn
->
beginTransaction
();
$this
->
assertEquals
(
3
,
$this
->
_conn
->
getTransactionNestingLevel
());
$this
->
_conn
->
commit
();
$this
->
assertEquals
(
2
,
$this
->
_conn
->
getTransactionNestingLevel
());
throw
new
\Exception
;
$this
->
_conn
->
commit
();
// never reached
}
catch
(
\Exception
$e
)
{
$this
->
_conn
->
rollback
();
$this
->
assertEquals
(
1
,
$this
->
_conn
->
getTransactionNestingLevel
());
//no rethrow
}
$this
->
assertFalse
(
$this
->
_conn
->
isRollbackOnly
());
try
{
$this
->
_conn
->
setNestTransactionsWithSavepoints
(
false
);
$this
->
fail
(
'Should not be able to disable savepoints in usage for nested transactions inside an open transaction.'
);
}
catch
(
ConnectionException
$e
)
{
$this
->
assertTrue
(
$this
->
_conn
->
getNestTransactionsWithSavepoints
());
}
$this
->
_conn
->
commit
();
// should not throw exception
//no rethrow
}
$this
->
assertFalse
(
$this
->
_conn
->
isRollbackOnly
());
try
{
$this
->
_conn
->
setNestTransactionsWithSavepoints
(
false
);
$this
->
fail
(
'Should not be able to disable savepoints in usage for nested transactions inside an open transaction.'
);
}
catch
(
ConnectionException
$e
)
{
$this
->
fail
(
'Transaction commit after failed nested transaction should not fail when using savepoints.'
);
$this
->
_conn
->
rollback
();
$this
->
assertTrue
(
$this
->
_conn
->
getNestTransactionsWithSavepoints
());
}
$this
->
_conn
->
commit
();
// should not throw exception
}
catch
(
ConnectionException
$e
)
{
$this
->
fail
(
'Transaction commit after failed nested transaction should not fail when using savepoints.'
);
$this
->
_conn
->
rollback
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment