mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-15 16:11:42 +00:00
improve transaction rollback
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@38109 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0f06c9b7fc
commit
c035f9cf39
1 changed files with 9 additions and 4 deletions
13
SQLClient.m
13
SQLClient.m
|
@ -3201,6 +3201,7 @@ static unsigned int maxConnections = 8;
|
|||
if (_count > 0)
|
||||
{
|
||||
NSMutableArray *info = nil;
|
||||
BOOL wrap = [_db isInTransaction] ? NO : YES;
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
|
@ -3216,14 +3217,14 @@ static unsigned int maxConnections = 8;
|
|||
sql = [[NSMutableString alloc] initWithCapacity: sqlSize + 13];
|
||||
[info addObject: sql];
|
||||
[sql release];
|
||||
if ([_db isInTransaction] == NO)
|
||||
if (YES == wrap)
|
||||
{
|
||||
[sql appendString: @"begin;"];
|
||||
}
|
||||
|
||||
[self _addSQL: sql andArgs: info];
|
||||
|
||||
if ([_db isInTransaction] == NO)
|
||||
if (YES == wrap)
|
||||
{
|
||||
[sql appendString: @"commit;"];
|
||||
}
|
||||
|
@ -3233,8 +3234,10 @@ static unsigned int maxConnections = 8;
|
|||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
NSException *e = localException;
|
||||
|
||||
[info release];
|
||||
if ([_db isInTransaction] == NO)
|
||||
if (YES == wrap)
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
|
@ -3242,10 +3245,12 @@ static unsigned int maxConnections = 8;
|
|||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
[_db disconnect];
|
||||
NSLog(@"Disconnected due to failed rollback after %@", e);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
[localException raise];
|
||||
[e raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue